通过INSTALL_REFERRER Intent将价值从Google Play网址传递到应用的问题

时间:2014-12-23 11:59:03

标签: android android-intent google-play

安装应用后,我在使用Google Play网址传递transaction_id时出现问题。

URL看起来像这样: https://play.google.com/store/apps/details?id=com.bouncing.mate.bouncer&transaction_id=12345

使用此网址安装应用时,我尝试从transaction_id Intent中检索INSTALL_REFERRER值。为此,我在清单中宣布了一个接收器:

<!-- 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")));
        }
    }
}

问题是我不认为我的服务是开始的......我不确定是否&#34; transaction_id&#34;参数可以通过这种方式传递?在迄今为止我见过的所有例子中,&#34; refferer&#34;使用密钥。     例如:

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

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

1 个答案:

答案 0 :(得分:2)

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

您可以将一堆内容放入引荐来源,并且必须进行网址编码,例如,如果您通过:

https://play.google.com/store/apps/details?id=com.example&referrer=utm_source%3Dwebsite%26utm_medium%3Dmoweb%26utm_campaign%3Dsmartbanner然后谷歌将使用

呼叫您的广播接收器

receiver =“utm_source = website&amp; utm_medium = moweb&amp; utm_campaign = smartbanner”