【问题标题】:Firebase notifications not working iosFirebase通知不起作用ios
【发布时间】:2017-06-16 22:26:48
【问题描述】:

我在我的应用中集成了 Firebase 推送通知。在 xcode 中启用了通知。证书也可以。但通知没有显示在我的应用程序中。有人对此有任何想法吗?

这是我的代码:

[FIRApp configure];

if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max) {
    UIUserNotificationType allNotificationTypes =
    (UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge);
    UIUserNotificationSettings *settings =
    [UIUserNotificationSettings settingsForTypes:allNotificationTypes categories:nil];
    [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
} else {
    // iOS 10 or later
#if defined(__IPHONE_10_0) && IPHONE_OS_VERSION_MAX_ALLOWED >= IPHONE_10_0
    UNAuthorizationOptions authOptions =
    UNAuthorizationOptionAlert
    | UNAuthorizationOptionSound
    | UNAuthorizationOptionBadge;
    [[UNUserNotificationCenter currentNotificationCenter]
     requestAuthorizationWithOptions:authOptions
     completionHandler:^(BOOL granted, NSError * _Nullable error) {
     }
     ];

    // For iOS 10 display notification (sent via APNS)
    [[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];
    // For iOS 10 data message (sent via FCM)
    //        [[FIRMessaging messaging] setRemoteMessageDelegate:self];
#endif
    }

[[UIApplication sharedApplication] registerForRemoteNotifications];

【问题讨论】:

    标签: ios objective-c firebase firebase-cloud-messaging


    【解决方案1】:

    如果您没有放置正确的 SDK,可能会导致问题。确保你有这两个:

    “Firebase/Core”和“Firebase/Messaging”

    【讨论】:

    • 哦,我的项目中缺少 firebase/messaging。它应该显示一些错误消息。非常感谢。
    猜你喜欢
    • 2018-03-02
    • 2018-05-20
    • 1970-01-01
    • 1970-01-01
    • 2020-11-03
    • 2020-01-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多