What is the new version of the application request dialog box in Android Facebook SDK 4.0.1

I used the old implementation of the Facebook apprequests dialog box in my project, for example:

Bundle parameters = new Bundle(); parameters.putString("message","invite friends message..."); parameters.putString("data","invite friends data..."); parameters.putString("title","invite friends dialog title..."); if (facebook != null){ facebook.dialog(getActivity(), "apprequests", parameters, new Facebook.DialogListener() { @Override public void onComplete(Bundle values) { // todo: } }); } 

I found a new implementation in a facebook document. The application invites

 appLinkUrl = "my app link..."; previewImageUrl = "my image url..."; if (AppInviteDialog.canShow()) { AppInviteContent content = new AppInviteContent.Builder() .setApplinkUrl(appLinkUrl) .setPreviewImageUrl(previewImageUrl) .build(); AppInviteDialog.show(activity, content); } 

Is this the correct implementation for an app for friends or in any other way? if so, where will my message and data content be posted.

Or if I use api chart request, for example:

  String graphPath="/me/apprequests/"; GraphRequest request = GraphRequest.newGraphPathRequest( accessToken, graphPath, graphCallback); Bundle parameters = new Bundle(); parameters.putString("message","invite friends message..."); parameters.putString("data","invite friends data..."); parameters.putString("title","invite friends dialog title..."); request.setParameters(parameters); request.executeAsync(); 

then receiving {"data":[]} in response, and the dialog box does not appear. What would be the correct implementation for this?

+6
source share
2 answers

I got a solution, find below, this is a new implementation of the application request dialog in facebook sdk4.

  String appLinkUrl = "https://fb.me/..."; String previewImageUrl = ...; final String TAG = "fbv4"; if (AccessToken.getCurrentAccessToken() == null) { // start login... } else { FacebookSdk.sdkInitialize(activity.getApplicationContext()); CallbackManager callbackManager = CallbackManager.Factory.create(); FacebookCallback<AppInviteDialog.Result> facebookCallback= new FacebookCallback<AppInviteDialog.Result>() { @Override public void onSuccess(AppInviteDialog.Result result) { Log.i(TAG, "MainACtivity, InviteCallback - SUCCESS!" + result.getData()); } @Override public void onCancel() { Log.i(TAG, "MainACtivity, InviteCallback - CANCEL!"); } @Override public void onError(FacebookException e) { Log.e(TAG, "MainACtivity, InviteCallback - ERROR! " + e.getMessage()); } }; AppInviteDialog appInviteDialog = new AppInviteDialog(activity); if (appInviteDialog.canShow()) { AppInviteContent.Builder content = new AppInviteContent.Builder(); content.setApplinkUrl(appLinkUrl); content.setPreviewImageUrl(previewImageUrl); AppInviteContent appInviteContent = content.build(); appInviteDialog.registerCallback(callbackManager, facebookCallback); appInviteDialog.show(activity, appInviteContent); } } } 
+2
source

Old application requests have been renamed to "Requests for the game" and are limited only to games.

The App Invites dialog box has recently been launched and is intended for all mobile applications (with native applications for iOS or Android). In the application invitation dialog box, you can set the URL (links to applications are included), you can also add an image to the invitation. However, you cannot pre-fill the message, the user must enter it.

+3
source

Source: https://habr.com/ru/post/984953/


All Articles