FCM verify device token before sending push notification using PHP(FCM 在使用 PHP 发送推送通知之前验证设备令牌)
问题描述
我的数据库中有 fcm 令牌,并且某些令牌用于发送推送通知.
I have fcm tokens in my database and for some tokens are used to send push notifications.
一切都按要求正常工作.但是由于我得到了一些设备令牌,因此需要进行优化
Everything is working fine as required. But there is optimization required since some device token I am getting
string(116)
"{
"multicast_id": 1234,
"success": 0,
"failure": 1,
"canonical_ids": 0,
"results": [{
"error": "NotRegistered"
}]
}
"
如果在发送推送通知之前已经注册,可以帮助我验证设备令牌吗?
Could any help me verify device token if registered already before sending push notification?
推荐答案
您可以使用 实例 ID 服务器参考 GET API.如果您收到类似下面的响应,则表示该令牌仍然有效.
You can verify if a token in your database is still valid or not using the Instance ID Server Reference GET API. If you got a response similar to below, it means that the token is still valid.
GET 请求示例:
https://iid.googleapis.com/iid/info/nKctODamlM4:CKrh_PC8kIb7O...clJONHoA?details=true
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA
示例结果
HTTP 200 OK
{
"application":"com.iid.example",
"authorizedEntity":"123456782354",
"platform":"Android",
"attestStatus":"ROOTED",
"appSigner":"1a2bc3d4e5",
"connectionType":"WIFI",
"connectDate":"2015-05-12
"rel":{
"topics":{
"topicname1":{"addDate":"2015-07-30"},
"topicname2":{"addDate":"2015-07-30"},
"topicname3":{"addDate":"2015-07-30"},
"topicname4":{"addDate":"2015-07-30"}
}
}
}
这篇关于FCM 在使用 PHP 发送推送通知之前验证设备令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:FCM 在使用 PHP 发送推送通知之前验证设备令牌
基础教程推荐
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 如何替换eregi() 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
