-
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
Fields Modifier and Type Field Description private final String
PACKAGE_NAME
private final String
EXTRA_PROTOCOL_VERSION
private final String
EXTRA_APP_ID
private final String
EXTRA_REPLY_TOKEN_KEY
private final String
EXTRA_THREAD_TOKEN_KEY
private final String
EXTRA_METADATA
private final String
EXTRA_EXTERNAL_URI
private final String
EXTRA_PARTICIPANTS
private final String
EXTRA_IS_REPLY
private final String
EXTRA_IS_COMPOSE
private final Integer
PROTOCOL_VERSION_20150314
private final String
ORCA_THREAD_CATEGORY_20150314
public final static MessengerUtils
INSTANCE
-
Method Summary
Modifier and Type Method Description 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. final MessengerThreadParams
getMessengerThreadParamsForIntent(Intent intent)
When handling an Intent
from Messenger, call this to parse the parameters of the intent.final Unit
finishShareToMessenger(Activity activity, ShareToMessengerParams shareToMessengerParams)
Finishes the activity and returns the media item the user picked to Messenger. final Boolean
hasMessengerInstalled(Context context)
Checks whether any version of messenger is installed. final Unit
openMessengerInPlayStore(Context context)
Opens the play store to install Messenger. final String
getPACKAGE_NAME()
final String
getEXTRA_PROTOCOL_VERSION()
final String
getEXTRA_APP_ID()
final String
getEXTRA_REPLY_TOKEN_KEY()
final String
getEXTRA_THREAD_TOKEN_KEY()
final String
getEXTRA_METADATA()
final String
getEXTRA_EXTERNAL_URI()
final String
getEXTRA_PARTICIPANTS()
final String
getEXTRA_IS_REPLY()
final String
getEXTRA_IS_COMPOSE()
final Integer
getPROTOCOL_VERSION_20150314()
final String
getORCA_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
Intent
from 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()
-
-
-
-