最近我从 GCM 迁移到 FCM 以通过我的应用程序发送通知,我想知道是否可以从我的应用程序服务器订阅特定主题的成员.如果可能,那么如何查明特定成员令牌是否有效或过期.
Recently I migrated from GCM to FCM for sending the notification via my app, i want to know whether can able to subscribe the members in particular topic from my app server. If possible, then how will find out if a particular member token valid or expired.
因为在我的数据库中,我有近 22L 人 GCM 注册 TOKEN id,所以我将创建一个主题并通过我的应用服务器订阅这些成员.
Because in my database, i have near to 22L people GCM Registration TOKEN id, so that i will create one topic and subscribe those members via my app server.
解决此类问题的任何想法.
Any ideas to resolve this kind of issues.
您可以使用 Instance ID API,特别是使用 batchAdd
.它还可以通过返回 NOT_FOUND
错误来识别您订阅的注册令牌是否无效.来自文档:
You can subscribe multiple tokens to Topic via your App Server using the Instance ID API, specifically, using batchAdd
. It can also identify if the Registration Token that you were subscribing is invalid by returning a NOT_FOUND
error. From the docs:
管理多个应用实例的关系图
使用 Instance ID 服务的批处理方法,您可以对应用实例进行批处理管理.例如,您可以将应用程序实例批量添加或删除到 FCM 或 GCM 主题.要管理应用实例,请在此端点调用实例 ID 服务,并在 JSON 正文中提供应用实例令牌:
Using the Instance ID service's batch methods, you can perform batch management of app instances. For example, you can perform bulk addition or removal of app instances to an FCM or GCM topic. To manage app instances, call the Instance ID service at this endpoint, providing the app instance tokens in the JSON body:
https://iid.googleapis.com/iid/v1:batchAdd
https://iid.googleapis.com/iid/v1:batchRemove
参数
结果
调用成功时返回 HTTP 状态 200.空结果表示成功订阅令牌.对于失败的订阅,结果包含以下错误代码之一:
On success the call returns HTTP status 200. Empty results indicate successful subscription for the token. For failed subscriptions, the result contains one of these error codes:
POST 请求示例
https://iid.googleapis.com/iid/v1:batchAdd
Content-Type:application/json
Authorization:key=API_KEY
{
"to": "/topics/movies",
"registration_tokens": ["nKctODamlM4:CKrh_PC8kIb7O...", "1uoasi24:9jsjwuw...", "798aywu:cba420..."],
}
示例结果
HTTP 200 OK
{
"results":[
{},
{"error":"NOT_FOUND"},
{},
]
}
这篇关于APP Server中的FCM TOPIC创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!