检查Firebase邀请是否导致Play商店

时间:2016-10-01 16:08:28

标签: android firebase firebase-dynamic-links firebase-invites

在Android上启动应用时使用Firebase邀请并访问动态链接时,有没有办法知道用户是否刚刚安装了应用程序,这要归功于邀请或者是否已安装?

非常感谢,

博尔哈

2 个答案:

答案 0 :(得分:1)

编辑:感谢Catalin Morosan的回答

事实证明,您可以使用方法AppInviteReferral.isOpenedFromPlayStore(result.getInvitationIntent())找到它。在单击邀请时运行的活动中:

// Create an auto-managed GoogleApiClient with access to App Invites.
mGoogleApiClientInvite = new GoogleApiClient.Builder(this)
        .addApi(AppInvite.API)
        .enableAutoManage(this, this)
        .build();

// Check for App Invite invitations and launch deep-link activity if possible.
// Requires that an Activity is registered in AndroidManifest.xml to handle
// deep-link URLs.
boolean autoLaunchDeepLink = false;
AppInvite.AppInviteApi.getInvitation(mGoogleApiClientInvite, this, autoLaunchDeepLink)
        .setResultCallback(
                new ResultCallback<AppInviteInvitationResult>() {
                    @Override
                    public void onResult(AppInviteInvitationResult result) {
                        if (result.getStatus().isSuccess()) {
                            // Extract information from the intent
                            Intent intent = result.getInvitationIntent();
                            String invitationId = AppInviteReferral.getInvitationId(intent);
                            boolean alreadyUser = AppInviteReferral.isOpenedFromPlayStore(result.getInvitationIntent());
                            if (alreadyUser) {
                                // Do stuff...
                            } else {
                                // Do other stuff...
                            }
                        }
                    }
                });

答案 1 :(得分:0)

基于this Google product form post,Firebase动态链接库仅会在每个应用生命周期内检查一次传入深层链接,这意味着您需要卸载并重新安装应用才能再次检查。这会影响getInvitation()方法的行为,看起来您可以根据此方法的结果暗示该应用是否先前已安装。

对我而言,这似乎令人困惑。在Branch.io,我们完全不同:您的链接数据对象将始终包含is_first_session布尔值,您可以以您选择的任何方式以编程方式处理它。