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

问题描述:

当在Android上启动应用时使用Firebase邀请并访问动态链接时,是否有办法知道用户是否刚刚安装了该应用,感谢邀请或者是否已经安装?检查Firebase邀请是否已导致Play商店

非常感谢,

博尔哈

编辑:感谢克特林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

这不起作用。 AppInviteReferral.hasReferral()在两种情况下均返回true。我发现AppInviteReferral.isOpenedFromPlayStore()应该像我们想要的那样工作。 –

+0

@CatalinMorosan你是对的我到现在还没有机会测试它,因为我的应用不在Play商店。现在它和你的答案是有效的,而不是hasReferral() – Borja

基于this Google product form post,在火力地堡动态链接库将只检查每个应用程序一生只有一次进入深层链接,这意味着你需要卸载并重新安装应用程序吧再次检查。这提供了getInvitation()方法的行为,看起来您可以根据此方法的结果暗示应用是否先前已安装。

对我来说,这似乎非常混乱。在Branch.io我们做的完全不同:您的链接数据对象将始终包含一个is_first_session布尔值,您可以通过编程方式以您选择的任何方式进行处理。