gpt4 book ai didi

android - 解析推送不向某些设备发送通知

转载 作者:太空狗 更新时间:2023-10-29 14:55:06 25 4
gpt4 key购买 nike

当我从 Parse Push 发送通知时,它会向某些设备发送通知,而对于其余设备,它会显示 GCM- 不匹配的发件人 ID。我已经在我的应用程序中正确配置了 Parse 配置,但有时它会将我的应用程序生成的 GCM ID 存储在它的设备 token 字段中,然后给出此 GCM- Mismatch sender ID 错误。如何解决这个错误?

最佳答案

可能您的应用使用多个推送提供程序,包括 Parse。幸运的是 Parse 提供了一个很好的元数据。正如 Parse 在它的 docs 中所说的那样如果您使用除 Parse 之外的其他推送提供程序,则您应该提供您的应用用于推送消息的每个 Sender_ID。看看下面:

The Parse Android SDK chooses a reasonable default configuration so that you do not have to worry about GCM registration ids, sender ids, or API keys. In particular, the SDK will automatically register your app for push at startup time using Parse's sender ID (1076345567071) and will store the resulting registration ID in the deviceToken field of the app's current ParseInstallation.

However, as an advanced feature for developers that want to send pushes from multiple push providers, Parse allows you to optionally register your app for pushes with additional GCM sender IDs. To do this, specify the additional GCM sender ID with the following <meta-data> tag as a child of the <application> element in your app's AndroidManifest.xml:

<meta-data android:name="com.parse.push.gcm_sender_id"
android:value="id:YOUR_SENDER_ID" />;

In the sample snippet above, YOUR_SENDER_ID should be replaced by a numeric GCM sender ID. Note that the Parse SDK expects you to prefix your sender ID with an id: prefix, as shown in the sample snippet.

If you want to register your app with multiple additional sender IDs, then the android:value in the <meta-data> element above should hold a comma-delimited list of sender IDs, as in the following snippet:

<meta-data android:name="com.parse.push.gcm_sender_id"
android:value="id:YOUR_SENDER_ID_1,YOUR_SENDER_ID_2,YOUR_SENDER_ID_3"/>;

关于android - 解析推送不向某些设备发送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32241243/

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