gpt4 book ai didi

android - Onesignal GDPR 更改未注册设备

转载 作者:行者123 更新时间:2023-11-29 16:41:34 29 4
gpt4 key购买 nike

当我针对 Onesignal 新 GDPR 更改尝试以下步骤时,Onesignal 未注册设备,我不知道是否正确。

第 1 步:在应用程序 onCreate 中

if(!OneSignal.userProvidedPrivacyConsent()) {
OneSignal.setRequiresUserPrivacyConsent(true);
}

第 2 步: 当用户接受条款时,我将设置 provideUserConsent(true)

第 3 步:在用户接受条款后,我将启动 OneSignal 方法 startInit()

 OneSignal.startInit(this)
.setNotificationReceivedHandler(new OneSignalNotificationReceivedHandler())
.setNotificationOpenedHandler(new OneSignalNotificationOpenedHandler())
.init();

按照上面的步骤我会得到这样的日志信息

05-23 11:19:21.790 22460-22460/com.example.app V/OneSignal: OneSignal SDK initialization delayed, user privacy consent is set to required for this application.

05-23 11:19:21.795 22460-22460/com.example.app W/OneSignal: Method idsAvailable() was called before the user provided privacy consent. Your application is set to require the user's privacy consent before the OneSignal SDK can be initialized. Please ensure the user has provided consent before calling this method. You can check the latest OneSignal consent status by calling OneSignal.userProvidedPrivacyConsent()

在 OneSignal Dashboard 中收到这样的消息

Google Play services library initialization error. Check for conflicting plugins and make sure "com.google.android.gms.version" is in your AndroidManifest.xml. Check the logcat for more details.

但我在 AndroidManifest.xml 中包含了所有必要的细节

<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />

最佳答案

一定是有误。

setRequiresUserPrivacyConsent(true) 必须在 OneSignal 初始化之前调用。

例子:

public void onCreate() {
super.onCreate();
// Prevents OneSignal from sending any data until provideUserConsent` is called.
OneSignal.setRequiresUserPrivacyConsent(true);

// OneSignal Initialization
OneSignal.startInit(this)
.inFocusDisplaying(OneSignal.OSInFocusDisplayOption.Notification)
.unsubscribeWhenNotificationsAreDisabled(true)
.init();
}

public void onUserTappedProvidePrivacyConsent(View v) {
// will initialize the OneSignal SDK and enable push notifications
OneSignal.provideUserConsent(true);
}

https://documentation.onesignal.com/docs/android-native-sdk#section--setrequiresuserprivacyconsent-

关于android - Onesignal GDPR 更改未注册设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50481038/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com