iOS: AppDelegate methods not getting call SwiftUI 2

Viewed 352

I'm trying to integrate FCM to my project which is using SwiftUI 2. The problem I have is that the AppDelegate methods are not getting called. In my main App struct, I have this:

@UIApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate

But the only method that gets called is func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool.

The rest doesn't work. I can get by all of the required methods with view modifiers but there is no replacement modifier for application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data). So I cannot set the APN token to FCM. I tried with both swizzling on and off (pretty much the same as didRegisterForRemoteNotificationsWithDeviceToken is not getting called, and I do set the token in the case of swizzling off).

The issue of AppDelegate methods not getting called seems to be a known issue as I see other dev have that as well.

Any suggestion is much appreciated. Thanks

UPDATE: After several hours of trying everything I could think of, I gave up and go back to pure AppDelegate lifecycle with a holder view controller that displays my SwiftUI view.

0 Answers
Related