" com.android.vending.INSTALL_REFERRER"在广播上获取引荐来源参数在某些设备上最多延迟15秒 [英] "com.android.vending.INSTALL_REFERRER" fetching referrer parameters on Broadcast has up to 15 seconds delays on some devices

查看:605
本文介绍了" com.android.vending.INSTALL_REFERRER"在广播上获取引荐来源参数在某些设备上最多延迟15秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的服务器创建一个重定向并将参数传递给Google Play商店的链接; 我的服务器收到的短信;
https://goo.gl/ {UNIQUE_ID}



当我点击时,其实我点击下面这个网址;
http://www.mycompany.com/env= dev& token = 123& id = 456

上面的链接指示我将Google Play商店添加到我的应用包含的参数中;
https:// play。 google.com/store/apps/details?id=com.mycompany.app&referrer=123,456



以下是问题;(首次安装)
当我安装上面的链接打开的应用程序时,我想在第一次将这些token,id参数传递给我的应用程序,然后我将跳过登录。这些参数由服务器创建,因为它们对用户来说也是唯一的。



我已经设置了com.android.vending.INSTALL_REFERRER,并且能够按照预期接收参数但在每台设备上都不一致,并可能面临严重延迟。

 < receiver 
android:name =。 GooglePlayReceiver
android:exported =true
android:permission =android.permission.INSTALL_PACKAGES>
< intent-filter>
< / intent-filter>
< / receiver>

我的GooglePlayReceiver Broadcastreceiver是;

  public class GooglePlayReceiver extends BroadcastReceiver {

Context mContext;
String purchaseId = null;

public GooglePlayReceiver(){
}

@Override
public void onReceive(Context context,Intent intent){
try {
mContext = context;
Bundle extras = intent.getExtras();
String verificationCode = null;
String phoneNumber = null;
if(extras!= null){
String code = extras.getString(referrer);
String [] strArr = code!= null? code.split(,):new String [0];
token = strArr [0];
id = strArr [1];
}
} catch(Exception ex){
}
}}

这个流程在某些设备上有很大的延迟。例如,Google Pixel 2会立即取得参数,三星Galaxy S7有5-10秒的延迟。

如何解决这个问题?

$ b $因为 INSTALL_REFERRER 是以广播的形式发送的( .android.com / guide / components / broadcasts.htmlrel =nofollow noreferrer> documentation )它使用发布订阅模型。没有时间保证。



正因为如此,您不应该设计您的应用程序启动流程来依赖于在一定时间内接收广播。 Android是开源的,并且更改使得我的不同手机制造商在广播传递方面会产生不同的提示。



我的应用程序有不同的设计: p>


  • 如果广播稍后到达,则用户必须始终使用正常设置流程

  • ,以便用户跳过登录


My server creates a link that redirects and passes parameters to google play store;

The sms I receive by my Server; https://goo.gl/{UNIQUE_ID}

when I click, I actually click on this this url below; http://www.mycompany.com/env=dev&token=123&id=456

The link above directs me to google play store to my app included parameters; https://play.google.com/store/apps/details?id=com.mycompany.app&referrer=123,456

Here is the question;(First time installation) When I install the app opened with the link above, I want to pass those "token", "id" parameters to my app in first time then I will skip login. These parameters creating by server because they are also unique to user.

I have setup the "com.android.vending.INSTALL_REFERRER" and I am able to receive parameters as expected but not consistent on every devices and could face with big delays.

 <receiver
        android:name=".GooglePlayReceiver"
        android:exported="true"
        android:permission="android.permission.INSTALL_PACKAGES">
        <intent-filter>
            <action android:name="com.android.vending.INSTALL_REFERRER" />
        </intent-filter>
    </receiver>

My GooglePlayReceiver Broadcastreceiver is;

public class GooglePlayReceiver extends BroadcastReceiver {

Context mContext;
String purchaseId = null;

public GooglePlayReceiver() {
}

@Override
public void onReceive(Context context, Intent intent) {
    try {
        mContext = context;
        Bundle extras = intent.getExtras();
        String verificationCode = null;
        String phoneNumber = null;
        if (extras != null) {
            String code = extras.getString("referrer");
            String[] strArr = code != null ? code.split(",") : new String[0];
            token = strArr[0];
            id = strArr[1];
        }
    } catch (Exception ex) {
    }
}}

This flow has big delays on some devices. For ex, Google Pixel 2 fetches the parameters immediately without delay, Samsung Galaxy S7 has 5-10 seconds delay.

How to solve this?

解决方案

Because the INSTALL_REFERRER is sent as a broadcast (documentation) it uses the publish subscribe model. There is no guarantee about timing.

Because of this you shouldn't design your app startup flow to rely on receiving the broadcast within a certain length of time. Android is open source, and changes made my different phone manufacturers will cause different promptness in the delivery of broadcasts.

I'd have a different design for your app:

  • take the user always to the normal setup flow
  • if the broadcast arrives later, allow the user to skip login

这篇关于&QUOT; com.android.vending.INSTALL_REFERRER&QUOT;在广播上获取引荐来源参数在某些设备上最多延迟15秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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