Questions? Contact us on Facebook.
Entrepreneur

How to integrate Android apps with Facebook Messenger Platform

Update: If you would like the Messenger to be integrated by Experts, you can check out these folks HERE

Both users and businesses are shifting their focus from social networking to one-to-one messaging. IM Apps like WhatsApp, WeChat, and Line have huge number of users that are active way more on these platforms than on social networking sites. Facebook has both WhatsApp and its own Messenger app and probably has much overlap in that massive user base.  At the recent F8 Developer Conference, Facebook announced big plans for its Messenger Platform (WhatsApp stays independent; for now!). The 600 million users of Messenger will now be able to install apps and make purchases from Messenger. It is not exactly a new idea (WeChat and Line has had it for quite some time now) but it is still a significant development and as an app/business owner you should know the nitty-gritty involved.

The newest SDK from Facebook will contain the Messenger specific APIs, helper functions and image assets. You can also go the intent passing route but SDK is better.

 

android app with messenger

source: www.forbes.com

Follow these steps for a basic integration:
•    Start by creating an App ID for your application. Go to  developers.facebook.com and under My Apps (you need to be logged in for this), add a new android app, fill out the details like package name and development keys, and note down the App ID from the dashboard.
•    Download the SDK and import it in your android project. Configure your main activity java according to the SDK guidelines and paste the App ID in the manifest file.
<application android:label=”@string/app_name”>
<meta-data android:name=”com.facebook.sdk.ApplicationId” android:value=”@string/facebook_app_id”/>
</application>
•    In order to use Messenger integration in the Facebook SDK, make sure you have the following import statements in your Activity class that shares content into Messenger:
import com.facebook.messenger.MessengerUtils;
import com.facebook.messenger.MessengerThreadParams;
import com.facebook.messenger.ShareToMessengerParams;
•    To be able to send Send images, animated gifs, videos and audio clips to Messenger and have your app’s name and logo appear in the sent chat, you’ll use the MessengerUtils class from the SDK and set the desired mime type of the content. Supported types are: JPEG, GIF, PNG, WebP and MP4 (using H.264 encoder, baseline profile and AAC audio). This class also makes sure that if Messenger isn’t installed on the user’s phone, they’d be redirected to the Google Play Store.
String mimeType = “image/jpeg”;

// contentUri points to the content being shared to Messenger
ShareToMessengerParams shareToMessengerParams =
ShareToMessengerParams.newBuilder(contentUri, mimeType)
.build();

// Sharing from an Activity
MessengerUtils.shareToMessenger(
this,
REQUEST_CODE_SHARE_TO_MESSENGER,
shareToMessengerParams);
•    The Messenger SDK includes assets for Messenger-themed buttons. These buttons are available in blue and white, and in rectangular or circular shapes. The layouts for these buttons are available under /res/layout/ in various designs.
<LinearLayout>
<!–Include this in your layout–>
<includelayout=”@layout/messenger_button_send_blue_large” /></LinearLayout>

Main Messenger

With basic sharing, your app’s name and logo will be on everything sent from your app, but with optimized sharing, you’ll also be able to drive growth and engagement, right from a conversation using actions like Install (takes the user to the Play Store) and Reply (which brings people directly back to your app, to send more stuff).

You can start adding optimized sharing features after clearing the Facebook check for policy compliance under their App Review program.

Once your app is approved for optimized sharing, it may also be featured within Messenger. People can discover featured apps, listed below the apps that are already installed.
You can also integrate more advanced feature like analytics so you can obtain relevant metrics for your application.

Update: If you would like the Messenger to be integrated by Experts, you can check out these folks HERE

Previous ArticleNext Article