繁体   English   中英

通过INSTALL_REFERRER Intent从Google Play URL向应用程序传递值时出现问题

[英]Problems passing value from Google Play URL to app via INSTALL_REFERRER Intent

安装应用后,我在从Google Play URL传递transaction_id遇到问题。

该URL看起来像这样: 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”参数吗? 到目前为止,在我看到的所有示例中,都使用了“ refferer”键。 例如:

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

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

唯一允许的查询参数是“引荐来源网址”

您可以在引荐来源网址中放入很多内容,并且这些内容必须经过url编码,例如,如果通过:

https://play.google.com/store/apps/details?id=com.example&referrer=utm_source%3Dwebsite%26utm_medium%3Dmoweb%26utm_campaign%3Dsmartbanner,然后Google将通过以下方式致电您的广播接收器

接收者=“ utm_source = website&utm_medium = moweb&utm_campaign = smartbanner”

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM