Facebook App邀请,邀请朋友 [英] Facebook App Invite, Invite Friends

查看:211
本文介绍了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)



fb邀请不能工作的代码



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





创建新的测试用户后,使用设备应用程序目前未安装,并且该应用程序从未被用户授权。



所以这里的关键是如果应用程序安装在目标设备,即使用户以前没有授权应用程序。此外,似乎如果用户以前已经授权了应用程序,即使它在某些时候被删除,它也不会生成通知。



所以如果你想测试这个,创建一个全新的测试用户,并在您正在测试的平台上的Facebook应用上登录,并确保该应用没有安装在设备上。



我认为尽管安装了应用程序,它仍然会生成通知,因为多个用户可能使用相同的设备,但这似乎是现在的。



我会在这里离开这里,以防将来有任何人遇到类似的问题。



长久而繁荣!



来源



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


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邀请,邀请朋友的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆