【问题标题】:Problems passing value from Google Play URL to app via INSTALL_REFERRER Intent通过 INSTALL_REFERRER Intent 将值从 Google Play URL 传递到应用程序的问题
【发布时间】:2014-12-23 11:59:03
【问题描述】:

安装应用后,我在从 google play URL 传递 transaction_id 时遇到问题。

网址如下所示: https://play.google.com/store/apps/details?id=com.bouncing.mate.bouncer&transaction_id=12345

当使用此 url 安装应用程序时,我尝试从 INSTALL_REFERRER Intent 检索 transaction_id 值。为此,我在清单中声明了一个接收器:

<!-- The Google Play com.android.vending.INSTALL_REFERRER Intent is broadcast when an app is installed from the Google Play Store.
This broadcast receiver listens for that Intent, passing the data required for app install tracking. -->

<receiver
    android:name=".data.tracking.AppInstallReceiver"
    android:exported="true">
    <intent-filter>
        <action android:name="com.android.vending.INSTALL_REFERRER"/>
    </intent-filter>
</receiver>

我的接收器类如下所示:

public class AppInstallReceiver extends BroadcastReceiver {

    @Override 
    public void onReceive(Context context, Intent intent) {

        if (intent.hasExtra("transaction_id")) {
            // Intent has transaction id extra, start Service that will handle tracking
            context.startService(AppInstallService.getIntent(context, intent.getStringExtra("transaction_id")));
        }
    }
}

问题是我认为我的服务从未启动过......我不确定“transaction_id”参数是否可以通过这种方式传递?到目前为止,在我看到的所有示例中,都使用了“引用者”键。 例如:

Bundle extras = intent.getExtras();
String referrerString = extras.getString("referrer");

服务已使用: adb shell am broadcast -a com.android.vending.INSTALL_REFERRER --es "transaction_id" "1234567" 它应该可以正常工作,但是在安装时收到意图是我无法测试的。

【问题讨论】:

    标签: android android-intent google-play


    【解决方案1】:

    唯一允许的查询参数是“referrer”

    你可以在referrer中放一堆东西,而且它们必须是url编码的,例如如果你通过:

    https://play.google.com/store/apps/details?id=com.example&referrer=utm_source%3Dwebsite%26utm_medium%3Dmoweb%26utm_campaign%3Dsmartbanner 然后谷歌会调用你的广播接收器

    receiver = "utm_source=website&utm_medium=moweb&utm_campaign=smartbanner"

    【讨论】:

      猜你喜欢
      • 2020-05-19
      • 1970-01-01
      • 1970-01-01
      • 2015-11-03
      • 2015-11-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多