简体   繁体   English

当应用程序在后台运行时,推送通知不起作用

[英]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.

相关问题 当应用程序在后台运行时,iOS推送通知不起作用 - iOS push notifications do not work when app is in background 推送通知不起作用 Xcode 11.3.1 - Push notifications don't work Xcode 11.3.1 如果通过iTunes安装了应用程序,则推送通知不起作用,但如果通过XCode安装,则推送通知就不会起作用 - Push notifications don't work if app is installed via iTunes but they do if installed by XCode 推送通知在iOS7中不起作用,但它们适用于iOS6 - Push notifications don't work in iOS7 but they work in iOS6 当我切换到生产证书时,Trigger.io和解析推送通知不起作用 - Trigger.io & Parse push notifications don't work when I switch to production certificate 推送通知在Apple Beta测试(TestFlight)中不起作用 - Push notifications don't work in Apple Beta Testing (TestFlight) 不显示推送通知 - Don't show push notifications 我未注册时,推送通知仍会播放声音 - Push Notifications still play sounds when I don't register it 应用程序在后台模式下未收到推送通知 - App doesn't receive push notifications in background mode iOS应用未收到来自Firebase的后台推送通知 - iOS app doesn't receive background push notifications from Firebase
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM