Firebase Cloud Messaging Doesn't Create Push Notifications but Gets Information

旧城冷巷雨未停 提交于 2019-11-30 11:02:09
fredytowelie

Add FirebaseAppDelegateProxyEnabled type "Boolean" value "NO" in your info.plist:

You're missing the UNUserNotificationDelegate methods that allow you to get notifications.

extension NotificationManager: UNUserNotificationCenterDelegate {

    func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: () -> Void) {

        switch response.actionIdentifier {

        // NotificationActions is a custom String enum I've defined
        case NotificationActions.HighFive.rawValue:
            print("High Five Delivered!")
        default: break
        }
    }

    func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: (UNNotificationPresentationOptions) -> Void) {

        // Delivers a notification to an app running in the foreground.
    }
}

These two delegate methods replace the old ones you're currently using to receive (i.e. didReceiveRemoteNotification). See this tutorial for more information: http://cleanswifter.com/ios-10-local-notifications/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!