本文介绍了Facebook App邀请,邀请朋友的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我切换到了Facebook 4.0,以实现Android的AppInviteDialog。我遵循。



对话框出现,我可以选择朋友,邀请他们,我得到 onSuccess()调用,但我的朋友没有收到邀请。



我使用了以下应用程序网址:https://fb.me/****412097*****



没有previewImageURL,虽然我在对话框中看到我的应用程序的图像。



代码:

  // Inside onCreate  -  

callbackManager = CallbackManager.Factory.create();

mInvititeDialog = new AppInviteDialog(this);
mInvititeDialog.registerCallback(callbackManager,
new FacebookCallback< AppInviteDialog.Result>(){

@Override
public void onSuccess(Result result){
NetworkController.showCustomToast(
InviteFriendsActivity.this,
邀请成功发送!);
finish();
}

@Override
public void onCancel(){
Log.d(Result,Cancelled);
NetworkController.showCustomToast(
InviteFriendsActivity.this,Cancelled);
finish ();
}

@Override
public void onError(FacebookException exception){
Log.d(Result,Error+ exception.getMessage());
NetworkController.showCustomToast(
InviteFriendsActivity.this,
邀请朋友时出错);
finish();
}
});


if(AppInviteDialog.canShow()){
AppInviteContent content = new AppInviteContent.Builder()
.setApplinkUrl(appLinkUrl).build();

AppInviteDialog.show(InviteFriendsActivity.this,content);

}

@Override
protected void onActivityResult(int requestCode,int resultCode,Intent data){
// TODO自动生成的方法存根
super.onActivityResult(requestCode,resultCode,data);
callbackManager.onActivityResult(requestCode,resultCode,data);

}

从下面的类似链接没有帮助(即使他们来自ios)









它确实适用于我,但是我不太清楚,如果它涵盖了所有的场景,是完美的解决方案。在这里发送给其他用户和建议(如果有的话)。


I switched to Facebook 4.0 in order to implement AppInviteDialog for Android. I followed this reference.

The dialog appears, I can select friends, invite them, I get the onSuccess() call, but my friends don't get the invite.

I have used the below applink URL: https://fb.me/****412097*****

No previewImageURL although I saw my app's image on the dialog.

Code:

//Inside onCreate -

        callbackManager = CallbackManager.Factory.create();

        mInvititeDialog = new AppInviteDialog(this);
        mInvititeDialog.registerCallback(callbackManager,
                new FacebookCallback<AppInviteDialog.Result>() {

                    @Override
                    public void onSuccess(Result result) {
                        NetworkController.showCustomToast(
                                InviteFriendsActivity.this,
                                "Invitation Sent Successfully!");
                        finish();
                    }

                    @Override
                    public void onCancel() {
                        Log.d("Result", "Cancelled");
                        NetworkController.showCustomToast(
                                InviteFriendsActivity.this, "Cancelled");
                        finish();
                    }

                    @Override
                    public void onError(FacebookException exception) {
                        Log.d("Result", "Error " + exception.getMessage());
                        NetworkController.showCustomToast(
                                InviteFriendsActivity.this,
                                "Error while inviting friends");
                        finish();
                    }
                });


    if (AppInviteDialog.canShow()) {
            AppInviteContent content = new AppInviteContent.Builder()
                            .setApplinkUrl(appLinkUrl).build();

            AppInviteDialog.show(InviteFriendsActivity.this, content);

    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        // TODO Auto-generated method stub
        super.onActivityResult(requestCode, resultCode, data);
        callbackManager.onActivityResult(requestCode, resultCode, data);

    }

No help from below similar links (even though they are from ios)

Code for fb invitation not working

https://stackoverflow.com/questions/27547826/facebook-app-invites-issue

Facebook App Invite not received

解决方案

Ok, turns out everything was working fine after all. My mistake was in assuming not having the app installed, and not having the app authorized should generate a push notification.

After creating a new test user, using a device where the app was not currently installed and the app NEVER having been authorized with the user.

So the key here is that no push notification will be generated if the app is installed on the target device, even if the user has not authorized the app previously. Also, seemingly, if the user has authorized the app previously, even if it was removed it at some point, it also will not generate a notification.

So if you want to test this, create an entirely new test user and log in on the Facebook app on the platform you are testing on, and make sure the app is not installed on the device.

I think it should still generate a notification despite app being installed, because multiple users might be using the same device, but that's how it seems to be right now.

I'll leave this here in case anyone has a similar problem in the future.

Live long and prosper!

Source

It did actually work for me, however I am not very sure if it covers all the scenarios and is the perfect solution. Posting here for other users and suggestions if any.

这篇关于Facebook App邀请,邀请朋友的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 00:24