在Android应用程序中下载应用程序后,我们能否获得引荐来源链接

时间:2019-07-04 05:46:33

标签: android firebase firebase-dynamic-links

我创建了一个应用来获取用户的引荐来源,但该应用不是从Google Play商店下载,而是通过chrome或任何其他浏览器从aws(s3)服务器或任何其他服务器下载的。

整个过程:通过浏览器下载应用,然后手动安装。我可以获取引荐链接吗?

我尝试了3种方法:

  1. Firebase动态链接
  2. google Referrer lib
  3. 广播接收器

请回答我这样的托管和下载过程,它将成功吗?或需要发布会自动安装的地方

谢谢

class A < Array
  def word
    [*self[0..1],*self[-2..-1]].map(&:chr).join
  end
  def sort
    A.new(self.to_a.sort)
  end
end
FirebaseDynamicLinks.getInstance()
                .getDynamicLink(getIntent())
                .addOnSuccessListener(this, new OnSuccessListener<PendingDynamicLinkData>() {
                    @Override
                    public void onSuccess(PendingDynamicLinkData pendingDynamicLinkData) {
                        Uri deepLink = null;
                        if (pendingDynamicLinkData != null) {
                            deepLink = pendingDynamicLinkData.getLink();
                        }
                        Log.d("xxxxxx",""+deepLink);
                        if (deepLink != null
                                && deepLink.getBooleanQueryParameter("referrer", false)){
                            referrer = deepLink.getQueryParameter("referrer");
                            FirebaseInstanceId.getInstance().getInstanceId().addOnCompleteListener(new OnCompleteListener<InstanceIdResult>() {
                                @Override
                                public void onComplete(@NonNull Task<InstanceIdResult> task) {
                                    if(task.isSuccessful()){
                                        tokenid = task.getResult().getToken();
                                        postreq(tokenid,deviceid,referrer);
                                        Log.d("xxxx",""+tokenid);
                                        Log.d("xxxx",""+deviceid);
                                        Log.d("xxxx dynamic",""+referrer);
                                    }
                                }
                            });
                        }
                        else {
                            FirebaseInstanceId.getInstance().getInstanceId().addOnCompleteListener(new OnCompleteListener<InstanceIdResult>() {
                                @Override
                                public void onComplete(@NonNull Task<InstanceIdResult> task) {
                                    if(task.isSuccessful()){
                                        tokenid = task.getResult().getToken();
                                        postreq(tokenid,deviceid,referrer);
                                        Log.d("xxxx",""+tokenid);
                                        Log.d("xxxx",""+deviceid);
                                        Log.d("xxxx dynamic",""+referrer);
                                    }
                                }
                            });
                        }
                    }
                });
final InstallReferrerClient mReferrerClient;

        mReferrerClient = InstallReferrerClient.newBuilder(this).build();

        mReferrerClient.startConnection(new InstallReferrerStateListener() {
            @Override
            public void onInstallReferrerSetupFinished(int responseCode) {
                switch (responseCode) {
                    case InstallReferrerClient.InstallReferrerResponse.OK:
                        // Connection established
                        try {
                            ReferrerDetails response =
                                    mReferrerClient.getInstallReferrer();
                            Log.d("xxxx google",""+response.getInstallReferrer());

                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        mReferrerClient.endConnection();
                        break;
                    case
                            InstallReferrerClient.InstallReferrerResponse.FEATURE_NOT_SUPPORTED:
                        // API not available on the current Play Store app
                        break;
                    case
                            InstallReferrerClient.InstallReferrerResponse.SERVICE_UNAVAILABLE:
                        // Connection could not be established
                        break;
                }
            }

            @Override
            public void onInstallReferrerServiceDisconnected() {
                // Try to restart the connection on the next request to
                // Google Play by calling the startConnection() method.
            }
        });

0 个答案:

没有答案