从客户端发送通知 - Firebase 云消息传递 - swift 以编程方式
send notification from the client - Firebase Cloud Messaging - swift programmatically
是否可以使用 swift 从客户端找到推送通知?
我在网上搜索,发现的唯一示例和文档与 Firebase Cloud Functions
的使用和/或使用 Firebase Console
.
严格相关
我想知道是否可以使用 Firebase Cloud Messaging
从客户端创建和发送通知。
实际上可以使用 firebase rest api,以下端点可用于发送通知:
HTTP 请求必须是具有这些 headers:
的 POST 请求
Authorization: key=<server_key>
Content-Type: application/json
和以下 body:
{
"to" : "<FCM TOKEN>",
"collapse_key" : "type_a",
"priority": 10,
"data" : {
"body" : "Notification",
"title": "Notification title"
}
}
当然,您需要知道应该接收通知的目标设备的 FCM 令牌,或者至少知道 device/user 订阅的主题。如果您想向特定主题发送通知,请使用以下 body:
{
"to" : "/topics/<YOUR_TOPIC>",
"collapse_key" : "type_a",
"priority": 10,
"data" : {
"body" : "Notification",
"title": "Notification title"
}
}
是否可以使用 swift 从客户端找到推送通知?
我在网上搜索,发现的唯一示例和文档与 Firebase Cloud Functions
的使用和/或使用 Firebase Console
.
我想知道是否可以使用 Firebase Cloud Messaging
从客户端创建和发送通知。
实际上可以使用 firebase rest api,以下端点可用于发送通知:
HTTP 请求必须是具有这些 headers:
的 POST 请求Authorization: key=<server_key>
Content-Type: application/json
和以下 body:
{
"to" : "<FCM TOKEN>",
"collapse_key" : "type_a",
"priority": 10,
"data" : {
"body" : "Notification",
"title": "Notification title"
}
}
当然,您需要知道应该接收通知的目标设备的 FCM 令牌,或者至少知道 device/user 订阅的主题。如果您想向特定主题发送通知,请使用以下 body:
{
"to" : "/topics/<YOUR_TOPIC>",
"collapse_key" : "type_a",
"priority": 10,
"data" : {
"body" : "Notification",
"title": "Notification title"
}
}