Facebook的Messenger的发送元数据(Android版) [英] Facebook Messenger sending metadata (Android)

查看:484
本文介绍了Facebook的Messenger的发送元数据(Android版)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在下面的本指南来创建一个发送图像的Facebook应用程序使者。

 字符串mime类型=图像/ PNG
乌里contentUri = Uri.parse(android.resource://com.test.test/drawable/foobar);字符串元={\\名称\\:\\巴兹\\};
ShareToMessengerParams PARAMS = ShareToMessengerParams.newBuilder(contentUri,mime类型).setMetaData(元数据).build();
MessengerUtils.shareToMessenger(这一点,REQUEST_ code_SHARE_TO_MESSENGER,则params);

在code是pretty简单,几乎等同于Facebook的自己的样品code。影像是否正确发送到承认我的应用程序进行优化,并提供回复按钮使者。不过,我遇到了麻烦跨越发送的元数据。当回复按钮pssed $ P $,这应该是在额外捆绑一切( EXTRA_IS_REPLY EXTRA_THREAD_TOKEN EXTRA_PARTICIPANTS )被发送回应用程序,但没有元数据。任何帮助将大大AP preciated。

下面是明显的一个片段:

 <! - 活动 - >
    <活动
        机器人:名字=。MainActivity
        机器人:windowSoftInputMode =stateHidden
        机器人:标签=@字符串/ APP_NAME>
        &所述;意图滤光器>
            <作用机器人:名字=android.intent.action.MAIN/>
            <类机器人:名字=android.intent.category.LAUNCHER/>
        &所述; /意图滤光器>
        &所述;意图滤光器>
            <作用机器人:名字=android.intent.action.PICK/>
            <类机器人:名字=android.intent.category.DEFAULT/>
            <类机器人:名字=com.facebook.orca.category.PLATFORM_THREAD_20150311/>
        &所述; /意图滤光器>
        &所述;意图滤光器>
            <作用机器人:名字=android.intent.action.PICK/>
            <类机器人:名字=android.intent.category.DEFAULT/>
            <类机器人:名字=com.facebook.orca.category.PLATFORM_THREAD_20150314/>
        &所述; /意图滤光器>
    < /活性GT;


解决方案

好了,所以这里是为那些有同样的问题的解决方法。

如果一个应用程序的职位相同的图像给Facebook Messenger的多次使者对待所有,但第一个图像为重复和不重视的元数据。 (这里有一个最终超时,但不能不在乎找出确切的时间)

我的解决方法如下:每次您的应用程序员额的使者,使其放置一个随机像素的随机位置,以确保图像的签名的变化。我还没有试过,但我想改变一个像素的Alpha值将使其不那么显眼的用户来讲更好地工作。

I'm following this guide to create an app which sends an image to Facebook messenger.

String mimeType = "image/png";
Uri contentUri = Uri.parse("android.resource://com.test.test/drawable/foobar");

String metadata = "{ \"name\": \"baz\" }";
ShareToMessengerParams params = ShareToMessengerParams.newBuilder(contentUri, mimeType).setMetaData(metadata).build();
MessengerUtils.shareToMessenger(this, REQUEST_CODE_SHARE_TO_MESSENGER, params);

The code is pretty simple and almost identical to Facebook's own sample code. The image is properly sent to the messenger which recognizes my app to be optimized and supplies the REPLY button. However, I am having trouble getting the metadata sent across. When the REPLY button is pressed, everything that's supposed to be in the extra bundle (EXTRA_IS_REPLY, EXTRA_THREAD_TOKEN, EXTRA_PARTICIPANTS) is sent back to the app but not the metadata. Any help will be greatly appreciated.

Below is a snippet from manifest:

    <!-- Activities -->
    <activity
        android:name=".MainActivity"
        android:windowSoftInputMode="stateHidden"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.PICK" />
            <category android:name="android.intent.category.DEFAULT"/>
            <category android:name="com.facebook.orca.category.PLATFORM_THREAD_20150311"/>
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.PICK" />
            <category android:name="android.intent.category.DEFAULT"/>
            <category android:name="com.facebook.orca.category.PLATFORM_THREAD_20150314"/>
        </intent-filter>
    </activity>

解决方案

Ok so here's the workaround for those having the same problem.

If an app posts a same image to Facebook Messenger multiple times, the Messenger treats all but the first image as duplicates and doesn't attach the metadata. (There's an eventual timeout but can't care less to figure out the exact duration)

My workaround is as follows: Every time your app posts to the messenger, make it place a random pixel in a random location to make sure the image's signature changes. I haven't tried but I think changing the alpha value of a pixel will work better in terms of making it less conspicuous to the users.

这篇关于Facebook的Messenger的发送元数据(Android版)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆