android - install_referrer Intent 弃用和更新库

标签 android firebase android-studio deprecated install-referrer

我收到了来自谷歌的电子邮件:

We recently announced that we’ll be deprecating the install_referrer intent broadcast mechanism. Because one or more of your apps uses this intent to track referrals, we wanted to ensure you make the switch before March 1, 2020. After this date, new versions of the Play Store app will no longer broadcast the install_referrer intent after app installs.



我在 Stack 上检查了这个答案:install_referrer intent deprecation并遵循等待 Firebase 库更新的建议,现在我将我的项目更新到最新版本,但仍然在 package="com.google.firebase.measurement_impl"下的 list 合并中进入 INSTALL_REFERRER
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.firebase.measurement_impl" >

<uses-sdk android:minSdkVersion="14" />

<!-- Required permission for App measurement to run. -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE" />

<application>
    <receiver
        android:name="com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver"
        android:enabled="true"
        android:exported="true"
        android:permission="android.permission.INSTALL_PACKAGES" >
        <intent-filter>
            <action android:name="com.android.vending.INSTALL_REFERRER" />
        </intent-filter>
    </receiver>
</application>

这里是我在项目中使用的 firebase 版本
    implementation 'com.google.firebase:firebase-messaging:20.1.0'
    implementation 'com.google.firebase:firebase-analytics:17.2.2'
    implementation 'com.google.firebase:firebase-crash:16.2.1'
    implementation 'com.google.android.gms:play-services-location:17.0.0'
    implementation 'com.google.firebase:firebase-crashlytics:17.0.0-beta01'
    implementation 'com.google.firebase:firebase-config:19.1.1'
    implementation 'com.google.firebase:firebase-auth:19.2.0'

现在 5 天后,3 月 1 日将到来,我没有找到解决这个问题的方法

最佳答案

Google 的 installreferrer 库解决了这个问题。

implementation 'com.android.installreferrer:installreferrer:1.1'

关注此 link了解实现。
在您的应用程序的启动 Activity 中初始化客户端。
InstallReferrerClient referrerClient;
referrerClient = InstallReferrerClient.newBuilder(this).build();
referrerClient.startConnection(
    .... 
);

成功初始化客户端后,您可以存储从以下代码获得的引荐来源数据。
ReferrerDetails response = referrerClient.getInstallReferrer();
String referrerUrl = response.getInstallReferrer();

根据谷歌:

The install referrer information will be available for 90 days and won't change unless the application is reinstalled. To avoid unnecessary API calls in your app, you should invoke the API only once during the first execution after install.

关于android - install_referrer Intent 弃用和更新库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60414445/

相关文章:

android - 从右到左语言的滑动标签布局

android - DatabaseException : Expected a Map while deserializing, 但得到了一个类 java.lang.Long

firebase - 为新用户创建 Firebase 受众

android - 不能在约束中表示 214748364 的大小

javascript - 加载页面时隐藏 jQuery 移动页脚

ios - 通过 Firebase 从 MapKit 注释转至 UITableViewCell

android - JSONObject.put(string,string) 不工作

android - 如何在Android Studio中集成Vitamio?

android-studio - 从 Android Studio 运行所有 flutter 单元测试

android - QOpenGLWidget 不绘制数组