Android SDK Version


public class MessengerUtils
Utilities for Messenger Content Platform.
Applications should specify the app id in their manifest or call com.facebook.FacebookSdk.setApplicationId in their application startup path. For specifying in the manifest, add a meta tag in your <application> tag.
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="YOUR_APP_ID"/>
When sharing to Messenger, apps should call the shareToMessenger method. For example,
val params = ShareToMessengerParams.newBuilder(uri, "image/ *") .setMetaData(metaData) .build(); MessengerUtils.shareToMessenger(this, REQUEST_CODE_SHARE_TO_MESSENGER, params);
To handle receiving a composer shortcut or reply intent from Messenger, apps should put the following intent filter in their manifest for the activity that receives the intent:
<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>
When handling the intent, then call getMessengerThreadParamsForIntent to receive the parameters for messenger. When the user has clicked the Send button to send the content to Messenger, then call finishShareToMessenger to return the data back to Messenger.
Field Summary
Modifier and TypeFieldDescription
private final StringPACKAGE_NAME
private final StringEXTRA_PROTOCOL_VERSION
private final StringEXTRA_APP_ID
private final StringEXTRA_REPLY_TOKEN_KEY
private final StringEXTRA_THREAD_TOKEN_KEY
private final StringEXTRA_METADATA
private final StringEXTRA_EXTERNAL_URI
private final StringEXTRA_PARTICIPANTS
private final StringEXTRA_IS_REPLY
private final StringEXTRA_IS_COMPOSE
private final IntegerPROTOCOL_VERSION_20150314
private final StringORCA_THREAD_CATEGORY_20150314
public final static MessengerUtilsINSTANCE
Method Summary
Modifier and TypeMethodDescription
final UnitshareToMessenger(Activity activity, Integer requestCode, ShareToMessengerParams shareToMessengerParams) Starts an intent to share a piece of media on Messenger using the messenger content platform.
final MessengerThreadParamsgetMessengerThreadParamsForIntent(Intent intent) When handling an Intent from Messenger, call this to parse the parameters of the intent.
final UnitfinishShareToMessenger(Activity activity, ShareToMessengerParams shareToMessengerParams) Finishes the activity and returns the media item the user picked to Messenger.
final BooleanhasMessengerInstalled(Context context) Checks whether any version of messenger is installed.
final UnitopenMessengerInPlayStore(Context context) Opens the play store to install Messenger.
final StringgetPACKAGE_NAME()
final StringgetEXTRA_PROTOCOL_VERSION()
final StringgetEXTRA_APP_ID()
final StringgetEXTRA_REPLY_TOKEN_KEY()
final StringgetEXTRA_THREAD_TOKEN_KEY()
final StringgetEXTRA_METADATA()
final StringgetEXTRA_EXTERNAL_URI()
final StringgetEXTRA_PARTICIPANTS()
final StringgetEXTRA_IS_REPLY()
final StringgetEXTRA_IS_COMPOSE()
final IntegergetPROTOCOL_VERSION_20150314()
final StringgetORCA_THREAD_CATEGORY_20150314()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Method Detail

shareToMessenger

 final UnitshareToMessenger(Activity activity, Integer requestCode, ShareToMessengerParams shareToMessengerParams)
Starts an intent to share a piece of media on Messenger using the messenger content platform.
Parameters:
activity - the activity sharing the content
requestCode - a unique request code for Activity.startActivityForResult
shareToMessengerParams - parameters for what to share

getMessengerThreadParamsForIntent

 final MessengerThreadParamsgetMessengerThreadParamsForIntent(Intent intent)
When handling an Intent from Messenger, call this to parse the parameters of the intent.
Parameters:
intent - the intent of the activity

finishShareToMessenger

 final UnitfinishShareToMessenger(Activity activity, ShareToMessengerParams shareToMessengerParams)
Finishes the activity and returns the media item the user picked to Messenger.
Parameters:
activity - the activity that received the original intent from Messenger
shareToMessengerParams - parameters for what to share

hasMessengerInstalled

 final BooleanhasMessengerInstalled(Context context)
Checks whether any version of messenger is installed.
Parameters:
context - an android context

openMessengerInPlayStore

 final UnitopenMessengerInPlayStore(Context context)
Opens the play store to install Messenger.
Parameters:
context - an android context.

getPACKAGE_NAME

 final StringgetPACKAGE_NAME()

getEXTRA_PROTOCOL_VERSION

 final StringgetEXTRA_PROTOCOL_VERSION()

getEXTRA_APP_ID

 final StringgetEXTRA_APP_ID()

getEXTRA_REPLY_TOKEN_KEY

 final StringgetEXTRA_REPLY_TOKEN_KEY()

getEXTRA_THREAD_TOKEN_KEY

 final StringgetEXTRA_THREAD_TOKEN_KEY()

getEXTRA_METADATA

 final StringgetEXTRA_METADATA()

getEXTRA_EXTERNAL_URI

 final StringgetEXTRA_EXTERNAL_URI()

getEXTRA_PARTICIPANTS

 final StringgetEXTRA_PARTICIPANTS()

getEXTRA_IS_REPLY

 final StringgetEXTRA_IS_REPLY()

getEXTRA_IS_COMPOSE

 final StringgetEXTRA_IS_COMPOSE()

getPROTOCOL_VERSION_20150314

 final IntegergetPROTOCOL_VERSION_20150314()

getORCA_THREAD_CATEGORY_20150314

 final StringgetORCA_THREAD_CATEGORY_20150314()