Android 从play store安装后无法检索推荐代码
我需要在我的应用程序中为我创建的url集成转介代码实现: 并为此创建了广播接收器 installReferreReceiver.java 在manifest.xml中注册接收方Android 从play store安装后无法检索推荐代码,android,android-broadcastreceiver,referrals,Android,Android Broadcastreceiver,Referrals,我需要在我的应用程序中为我创建的url集成转介代码实现: 并为此创建了广播接收器 installReferreReceiver.java 在manifest.xml中注册接收方 从play store安装应用程序后有我的接收器呼叫,但我在转介代码中得到空值 我需要获得将应用程序提交给其他用户的用户代码。但这样做我会失败的。此外,我还使用shell脚本在终端中测试了我的接收器,它对我来说运行良好 因此,如果这段代码有任何问题,请向我说明,或者向我建议另一种方法。谢谢 验证您正在测试的play
从play store安装应用程序后有我的接收器呼叫,但我在转介代码中得到空值
我需要获得将应用程序提交给其他用户的用户代码。但这样做我会失败的。此外,我还使用shell脚本在终端中测试了我的接收器,它对我来说运行良好
因此,如果这段代码有任何问题,请向我说明,或者向我建议另一种方法。谢谢 验证您正在测试的play store url是否正确,是否具有测试所需的值。遵循以下定义的方案:
https://play.google.com/store/apps/details?id=com.example.application
&referrer=utm_source%3Dgoogle
%26utm_medium%3Dcpc
%26utm_term%3Drunning%252Bshoes
%26utm_content%3Dlogolink
%26utm_campaign%3Dspring_sale
有关更多信息,请查看位于的文档
例如,进行转介:
public void sendReferral(Context context) {
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, getInvitationMessage()), PreferencesManager.getInstance().getKeyReferrerUrl()));
sendIntent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.invitation_subject));
sendIntent.setType("text/plain");
context.startActivity(Intent.createChooser(sendIntent, context.getResources().getText(R.string.invitation_extended_title)));
}
private String getInvitationMessage(){
String playStoreLink = "https://play.google.com/store/apps/details?id=app.package.com&referrer=utm_source=";
return invitationId = playStoreLink + getReferralId();
}
然后在您的接收器中:
public class InstallReferrerReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent == null) {
return;
}
String referrerId = intent.getStringExtra("referrer");
if (referrerId == null){
return;
}
}
如果我将此用于共享游戏商店url,那么我应该将我的推荐代码放在哪里以及如何检索它。我也检查了谷歌开发者控制台,但没有得到正确的。如果您有任何样本,请提供给我。@Brian我们如何在不发送playstore构建的情况下测试它?您可以使用adb:adb shell am broadcast-a com.android.vending.INSTALL\u referer-n--es referer在本地测试它。请注意,到您的BroadcastReceiver的路径应该包括您的包名。
public void sendReferral(Context context) {
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, getInvitationMessage()), PreferencesManager.getInstance().getKeyReferrerUrl()));
sendIntent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.invitation_subject));
sendIntent.setType("text/plain");
context.startActivity(Intent.createChooser(sendIntent, context.getResources().getText(R.string.invitation_extended_title)));
}
private String getInvitationMessage(){
String playStoreLink = "https://play.google.com/store/apps/details?id=app.package.com&referrer=utm_source=";
return invitationId = playStoreLink + getReferralId();
}
public class InstallReferrerReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent == null) {
return;
}
String referrerId = intent.getStringExtra("referrer");
if (referrerId == null){
return;
}
}