通过 FCM 消息控制台在后台向我的 iOS 应用程序发送静默通知
Send silent notification to my iOS app in background, through FCM message console
我想向我的 iOS 应用程序发送静默通知,为此我已在其中实施了 FCM。当应用程序在后台时,我需要在应用程序收到来自 FCM 的通知时执行一些操作。
为此,执行过程将进入名为
的方法
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
但问题是,在用户点击通知之前,它不会进入此方法。
根据 (FCM documents) , if we want to wake up our app in background then we have to pass content_available parameter with key value true . but when i am sending this information through your FCM Compose message console in custom data,我们的应用程序不会唤醒,也不会在后台激活,直到用户点击通知。我想我收到的所有通知都是正常通知,而不是无声通知。所以 FCM 的实现和发送通知看起来工作得很好。
我遵循了所有给出的 FCM 文档并参考了几乎所有可能的连接 Whosebug 解决方案。甚至我已经关注了发送远程通知的苹果文档。最后我发送 "content_available" : true 通过 FCM 消息控制台。但它并没有变成无声通知,我收到的通知是用户必须点击的正常通知,才能进入方法 didReceiveRemoteNotification
。
是否可以通过 FCM 在后台接收通知(如静默通知)?
或任何其他实施方式?
我已经找到了解决方案。
只需遵循此 及其答案即可。
然后在 postman
中像这样输入 json body
{
"to":"eEBrg.... .... .... .... (FCM Token)",
"priority": "normal",
"content_available": true,
"notification":{
(do not send body here if you want to send the silent notification)
"requesttype":"ring" // optional
}
}
...您的应用程序将在后台唤醒并进入 didReceiveRemoteNotification 方法。
我想向我的 iOS 应用程序发送静默通知,为此我已在其中实施了 FCM。当应用程序在后台时,我需要在应用程序收到来自 FCM 的通知时执行一些操作。
为此,执行过程将进入名为
的方法-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
但问题是,在用户点击通知之前,它不会进入此方法。
根据 (FCM documents) , if we want to wake up our app in background then we have to pass content_available parameter with key value true . but when i am sending this information through your FCM Compose message console in custom data,我们的应用程序不会唤醒,也不会在后台激活,直到用户点击通知。我想我收到的所有通知都是正常通知,而不是无声通知。所以 FCM 的实现和发送通知看起来工作得很好。
我遵循了所有给出的 FCM 文档并参考了几乎所有可能的连接 Whosebug 解决方案。甚至我已经关注了发送远程通知的苹果文档。最后我发送 "content_available" : true 通过 FCM 消息控制台。但它并没有变成无声通知,我收到的通知是用户必须点击的正常通知,才能进入方法 didReceiveRemoteNotification
。
是否可以通过 FCM 在后台接收通知(如静默通知)? 或任何其他实施方式?
我已经找到了解决方案。
只需遵循此
然后在 postman
中像这样输入 json body{
"to":"eEBrg.... .... .... .... (FCM Token)",
"priority": "normal",
"content_available": true,
"notification":{
(do not send body here if you want to send the silent notification)
"requesttype":"ring" // optional
}
}
...您的应用程序将在后台唤醒并进入 didReceiveRemoteNotification 方法。