[英]Push notifications don't work when app is in background
There's a problem with my app and I don't know why: notification with Firebase doesn't work when the app is in the background, but they are fired once the app goes in the foreground. 我的应用程序有问题,我不知道为什么:当应用程序在后台时,Firebase通知不起作用,但是一旦应用程序进入前台,它们就会被触发。 The problem is not how to handle them, but why when the app is in foreground notification popup are fired, but when are in the background not.
问题不在于如何处理它们,而是为什么当应用程序处于前台通知弹出窗口时会被触发,而何时在后台通知则不会触发。
{
"notification" : {
"title" : "...",
"body" : "...",
"icon" : "...",
"sound" : "default"
},
"to": "...",
"priority" : "high",
"data" : {
...
}
}
This is a sample of the notification I tried to fire with the postman. 这是我尝试向邮递员开具的通知的示例。 Any ideas?
有任何想法吗? Thanks
谢谢
1) Check your certificate and bundle identifier in Firebase. 1)在Firebase中检查您的证书和捆绑包标识符。
2) Make sure you send Device Token to Firebase. 2)确保将设备令牌发送到Firebase。
- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
// For Development
[FIRInstanceID instanceID] setAPNSToken:deviceToken type:FIRInstanceIDAPNSTokenTypeSandbox];
// For Production
[FIRInstanceID instanceID] setAPNSToken:deviceToken type: FIRInstanceIDAPNSTokenTypeProd];
}
You can checkout this Link for more information. 您可以检出此链接以获取更多信息。
签入功能您已在后台模式下打开了远程通知。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.