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


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. For those who’d want to manually combine
Firebase Messaging, add “FirebaseAppDelegateProxyEnabled” to your
Data.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 Data.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 #accessible(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(varieties: [.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: Knowledge) {
        
    }
    
    func software(_ software: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
        
    }
}

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

@accessible(iOS 10, *)
extension AppDelegate : UNUserNotificationCenterDelegate {
    
    // Obtain displayed notifications for iOS 10 units.
    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 well-liked 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 concern?

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles