-
public class MessengerUtilsUtilities 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
Fields Modifier and Type Field Description private final StringPACKAGE_NAMEprivate final StringEXTRA_PROTOCOL_VERSIONprivate final StringEXTRA_APP_IDprivate final StringEXTRA_REPLY_TOKEN_KEYprivate final StringEXTRA_THREAD_TOKEN_KEYprivate final StringEXTRA_METADATAprivate final StringEXTRA_EXTERNAL_URIprivate final StringEXTRA_PARTICIPANTSprivate final StringEXTRA_IS_REPLYprivate final StringEXTRA_IS_COMPOSEprivate final IntegerPROTOCOL_VERSION_20150314private final StringORCA_THREAD_CATEGORY_20150314public final static MessengerUtilsINSTANCE
-
Method Summary
Modifier and Type Method Description 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 Intentfrom 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()-
-
Method Detail
-
shareToMessenger
final Unit shareToMessenger(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 contentrequestCode- a unique request code for Activity.startActivityForResultshareToMessengerParams- parameters for what to share
-
getMessengerThreadParamsForIntent
final MessengerThreadParams getMessengerThreadParamsForIntent(Intent intent)
When handling an
Intentfrom Messenger, call this to parse the parameters of the intent.- Parameters:
intent- the intent of the activity
-
finishShareToMessenger
final Unit finishShareToMessenger(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 MessengershareToMessengerParams- parameters for what to share
-
hasMessengerInstalled
final Boolean hasMessengerInstalled(Context context)
Checks whether any version of messenger is installed.
- Parameters:
context- an android context
-
openMessengerInPlayStore
final Unit openMessengerInPlayStore(Context context)
Opens the play store to install Messenger.
- Parameters:
context- an android context.
-
getPACKAGE_NAME
final String getPACKAGE_NAME()
-
getEXTRA_PROTOCOL_VERSION
final String getEXTRA_PROTOCOL_VERSION()
-
getEXTRA_APP_ID
final String getEXTRA_APP_ID()
-
getEXTRA_REPLY_TOKEN_KEY
final String getEXTRA_REPLY_TOKEN_KEY()
-
getEXTRA_THREAD_TOKEN_KEY
final String getEXTRA_THREAD_TOKEN_KEY()
-
getEXTRA_METADATA
final String getEXTRA_METADATA()
-
getEXTRA_EXTERNAL_URI
final String getEXTRA_EXTERNAL_URI()
-
getEXTRA_PARTICIPANTS
final String getEXTRA_PARTICIPANTS()
-
getEXTRA_IS_REPLY
final String getEXTRA_IS_REPLY()
-
getEXTRA_IS_COMPOSE
final String getEXTRA_IS_COMPOSE()
-
getPROTOCOL_VERSION_20150314
final Integer getPROTOCOL_VERSION_20150314()
-
getORCA_THREAD_CATEGORY_20150314
final String getORCA_THREAD_CATEGORY_20150314()
-
-
-
-