Ios Firebase推送静默推送通知HTTP v1
通过其或通过其向FCM发送以下请求不会产生预期的无声通知Ios Firebase推送静默推送通知HTTP v1,ios,firebase,firebase-cloud-messaging,Ios,Firebase,Firebase Cloud Messaging,通过其或通过其向FCM发送以下请求不会产生预期的无声通知 POST https://fcm.googleapis.com/v1/projects/project-name/messages:send { "message": { "apns": { "payload": { "aps": { "content-available": 1 }, "some": "test", "and":
POST https://fcm.googleapis.com/v1/projects/project-name/messages:send
{
"message": {
"apns": {
"payload": {
"aps": {
"content-available": 1
},
"some": "test",
"and": "more",
"nested": {
"content": "with_value"
}
},
"headers": {
"priority": "5"
}
},
"data": {
"some": "content"
},
"token": "..."
}
}
它也不能通过遗留API工作
POST https://fcm.googleapis.com/fcm/send
{
"to": "...",
"content_available": true,
"priority": "normal",
"data": {
"some-key": "value"
}
}
但是,如果我不使用FCM层直接将请求发送到APN,以下代码将正确执行:
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
print(userInfo)
let content = UNMutableNotificationContent()
content.title = "Some title"
content.body = "Some content"
let uuidString = UUID().uuidString
let request = UNNotificationRequest(identifier: uuidString,
content: content, trigger: nil)
let notificationCenter = UNUserNotificationCenter.current()
notificationCenter.add(request) { (error) in
if error != nil {
// Handle any errors.
}
}
completionHandler(.newData)
}
其他信息:
- 将
添加到badge
会更新应用程序上的徽章,以便收到通知apns
- 设置
键可在通知中心创建通知通知
- 我所有的例子都得到了FCM的成功回复
- 两个电话我都试过很多组合