小编Jef*_*all的帖子

Firebase 云消息传递未收到通知 (iOS)

我正在尝试使用 Firebase Notification Composer 向我的设备发送测试通知。我正在接收 FCM 令牌并将其打印到我的控制台,然后我尝试向该令牌发送通知。

这是我检查过的:

1) 我使用的是 iOS 12.4.1

2)我正在分配消息传递委托

3) 我从委托方法接收 FCM 令牌

4) 我已经确认通过打印到控制台启用了通知,当我被提示允许通知时,我点击了允许

5) 我已经验证在 Firebase 项目设置中有一个 APNs Auth Key 上传,具有正确的 TeamID 和 KeyID

6)当我发送测试消息时没有调用委托方法willPresentNotifications

7)我尝试过启用/禁用 Swizzling,但都不起作用

8)调试没有错误

这是代码:

import UIKit
import Firebase
import UserNotifications


@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate, MessagingDelegate {
var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

    UITabBar.appearance().barTintColor = UIColor(named: "Splish")!
    UINavigationBar.appearance().barTintColor = UIColor(named: "Splish")!
    UINavigationBar.appearance().titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]

    FirebaseApp.configure()

    Messaging.messaging().delegate = self

    UNUserNotificationCenter.current() …
Run Code Online (Sandbox Code Playgroud)

push-notification ios firebase swift firebase-cloud-messaging

5
推荐指数
1
解决办法
932
查看次数