小编Ale*_*sha的帖子

后台推送通知不起作用 iOS12 Swift4.2

我已经通过 firebase 实现了推送通知。无法从后台获取通知。在我的 App 委托中有以下代码,

class AppDelegate: UIResponder, UIApplicationDelegate, MessagingDelegate, UNUserNotificationCenterDelegate {

    var window: UIWindow?
     let gcmMessageIDKey = "gcm.message_id"

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
         sleep(3)
        IQKeyboardManager.shared.enable = true

        if #available(iOS 10.0, *) {
            // For iOS 10 display notification (sent via APNS)
            UNUserNotificationCenter.current().delegate = self

            let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
            UNUserNotificationCenter.current().requestAuthorization(
                options: authOptions,
                completionHandler: {_, _ in })
        } else {
            let settings: UIUserNotificationSettings =
                UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
            application.registerUserNotificationSettings(settings) …
Run Code Online (Sandbox Code Playgroud)

xcode apple-push-notifications ios firebase swift

4
推荐指数
1
解决办法
3827
查看次数

标签 统计

apple-push-notifications ×1

firebase ×1

ios ×1

swift ×1

xcode ×1