ios – SwiftUI firebase push notification errors. App Delegate Proxy is disabled

0
57


I am getting some errors when I attempt to add Firebase push notification with SwiftUI.

FIRMessaging Distant Notifications proxy enabled, will swizzle distant
notification receiver handlers. In the event you’d favor to manually combine
Firebase Messaging, add “FirebaseAppDelegateProxyEnabled” to your
Information.plist, and set it to NO. Comply with the directions at:
https://firebase.google.com/docs/cloud-messaging/ios/shopper#method_swizzling_in_firebase_messaging
to make sure correct integration.

After I add FirebaseAppDelegateProxyEnabled is NO at Information.plist. I am getting this error:

**

[GoogleUtilities/AppDelegateSwizzler] App Delegate Proxy is disabled.

**

Right here is the AppDelegate:

class AppDelegate: NSObject, UIApplicationDelegate {
    let gcmMessageIDKey = "gcm.message_id"
    
    func software(_ software: UIApplication,
                     didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
        
        FirebaseApp.configure()
        
        Messaging.messaging().delegate = self
        
        if #out there(iOS 10.0, *) {
            UNUserNotificationCenter.present().delegate = self
            
            let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
            UNUserNotificationCenter.present().requestAuthorization(
                choices: authOptions,
                completionHandler: {_, _ in }
            )
        } else {
            let settings : UIUserNotificationSettings = UIUserNotificationSettings(sorts: [.alert, .badge, .sound], classes: nil)
            software.registerUserNotificationSettings(settings)
        }
        
        software.registerForRemoteNotifications()
        return true
    }
    
    func software(_ software: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any],
                     fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
        
        if let messageID = userInfo[gcmMessageIDKey] {
            print("Message ID: (messageID)")
        }
        
        print(userInfo)
        
        completionHandler(UIBackgroundFetchResult.newData)
    }
    
    func software(_ software: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Information) {
        
    }
    
    func software(_ software: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
        
    }
}

extension AppDelegate: MessagingDelegate {
    func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {
        
        let deviceToken:[String: String] = ["token": fcmToken ?? ""]
        print("Gadget token: ", deviceToken) // This token can be utilized for testing notifications on FCM
    }
}

@out there(iOS 10, *)
extension AppDelegate : UNUserNotificationCenterDelegate {
    
    // Obtain displayed notifications for iOS 10 gadgets.
    func userNotificationCenter(_ heart: UNUserNotificationCenter,
                                willPresent notification: UNNotification,
                                withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
        let userInfo = notification.request.content material.userInfo
        
        if let messageID = userInfo[gcmMessageIDKey] {
            print("Message ID: (messageID)")
        }
        
        print(userInfo)
        
        // Change this to your most popular presentation possibility
        completionHandler([[.banner, .badge, .sound]])
    }
    
    func userNotificationCenter(_ heart: UNUserNotificationCenter,
                                didReceive response: UNNotificationResponse,
                                withCompletionHandler completionHandler: @escaping () -> Void) {
        let userInfo = response.notification.request.content material.userInfo
        
        if let messageID = userInfo[gcmMessageIDKey] {
            print("Message ID from userNotificationCenter didReceive: (messageID)")
        }
        
        print(userInfo)
        
        completionHandler()
    }
}

How can I repair this problem?