Facebook Messenger Sends Metadata (Android)

I am following this tutorial to create an application that sends an image to a 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 the actual Facebook sample code. The image is correctly sent to the messenger which recognizes my app for optimization and provides a REPLY button. However, I am having problems sending the metadata. When you press the REPLY everything that should be included in the supplementary ( EXTRA_IS_REPLY

, EXTRA_THREAD_TOKEN

, EXTRA_PARTICIPANTS

), is sent back to the application, but not the metadata. Any help would be greatly appreciated.

Below is a snippet from the 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>

      

+1


source to share


2 answers


So, here is a workaround for those having the same problem.

If an app sends the same image to Facebook Messenger multiple times, Messenger treats everything except the first image as duplicates and doesn't attach any metadata. (There is a possible timeout, but he can't help but figure out the exact duration)



My workaround looks like this: every time your app messages are sent to the messenger, make it a random pixel in a random place to make sure the image signature has changed. I haven't tried it, but I think changing the alpha value of a pixel will work better in terms of making it less visible to users.

+3


source


Yes, I can confirm that using a different image each time fixes this problem.



0


source







All Articles