gpt4 book ai didi

ios - Firebase 通知不工作 ios

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:25:31 27 4
gpt4 key购买 nike

我在我的应用程序中集成了 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];

最佳答案

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

“Firebase/Core”和“Firebase/消息”

关于ios - Firebase 通知不工作 ios,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41958353/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com