我正在使用Facebook应用程序邀请邀请朋友,但我对此有一些问题。
-
不显示推送通知仅在 Facebook 通知中显示通知。
-
成功发送后,其成功功能不起作用。
请告诉我如何解决这个问题。
这是代码-:
FacebookSdk.sdkInitialize(AppInvite.this);
CallbackManager callbackManager = CallbackManager.Factory.create();
FacebookCallback<AppInviteDialog.Result> facebookCallback = new FacebookCallback<AppInviteDialog.Result>() {
@Override
public void onSuccess(AppInviteDialog.Result result) {
Intent InviteFB = new Intent(getApplicationContext(), HomeActivity.class);
// InviteFB.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(InviteFB);
finish();
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(AppInvite.this);
if (appInviteDialog.canShow()) {
AppInviteContent.Builder content = new AppInviteContent.Builder();
content.setApplinkUrl("https://fb.me/1705244.......");
content.setPreviewImageUrl("");
AppInviteContent appInviteContent = content.build();
appInviteDialog.registerCallback(callbackManager, facebookCallback);
appInviteDialog.show(AppInvite.this, appInviteContent);
}
}
-
邀请由Facebook处理。收件人的 Facebook 应用通知设置将决定他们将收到哪种类型的通知。
-
我发现要使
FacebookCallback
接收其回调,必须将CallbackManager
添加到onActivityResult
以处理结果:@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); callbackManager.onActivityResult(requestCode, resultCode, data); }