gpt4 book ai didi

Android 23+ - 从备份中排除 GCM 注册 ID

转载 作者:可可西里 更新时间:2023-11-01 18:46:03 30 4
gpt4 key购买 nike

我有一个使用 Azure 发送推送通知的应用程序。 Azure 反过来使用 GCM 发送到 Android 设备。

我注意到我的 AndroidManifest.xml 中有警告

On SDK version 23 and up, your app data will be automatically backed up, and restored on app install. Your GCM regid will not work across restores, so you must ensure that it is excluded from the back-up set. Use the attribute android:fullBackupContent to specify an @xml resource which configures which files to backup.

我已按照此处的说明进行操作 https://developer.android.com/training/backup/autosyncapi.html?hl=in#configuring

但是我对如何从备份中排除 GCM regID 感到困惑?这是我当前的设置。

list

<application
android:allowBackup="true"
android:fullBackupContent="@xml/backup_scheme"
........

res/xml/backup_scheme.xml

<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
<exclude domain="sharedpref" path=""/>
</full-backup-content>

我应该把什么作为路径?我应该在我排除的地方有一个物理文件吗?

更新

所以我想我明白了。在我的 RegistrationIntentService.java 文件中,我将用户注册 ID 存储在字符串“registrationID”下的共享首选项中。所以我假设我使用以下...

<exclude domain="sharedpref" path="registrationID"/>

对吗?

最佳答案

根据@Simon 的回答进一步研究后,我认为当备份描述符 xml 文件是从 Android Studio 中的快速修复自动生成时,我们仍然需要替换 Path 中指定的文件名。我检查了我的一个应用程序中的 shared_prefs 目录,该目录已实现 Firebase 云消息传递,并找到以下 GCM 设置首选项文件:

enter image description here

因此 backup_descriptor.xml 将是:

<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
<!-- Exclude the shared preferences file that contains the GCM registrationId -->
<exclude
domain="sharedpref"
path="com.google.android.gms.appid.xml"/>
<exclude
domain="sharedpref"
path="com.google.android.gms.measurement.prefs.xml"/>
</full-backup-content>

关于Android 23+ - 从备份中排除 GCM 注册 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39088106/

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