Problem with OneSignal and Xamarin iOS

I use the OneSignal service in my Xamarin iOS application, agree the documentation: https://documentation.onesignal.com/docs/xamarin-sdk-setup

I took all the steps, BUT if I override the AppDelegate methods

OnResignActivation
DidEnterBackground
WillEnterForeground
WillTerminate
OnActivated

I get the following error:

ObjCRuntime.RuntimeException: Cannot get the method descriptor for the selector 'oneSignalApplicationDidBecomeActive:' on the type 'AppDelegate', because the selector does not correspond to a method

I need to override these methods, what is my mistake?

Thank!

+4
source share
2 answers

try this in the appdelegate app

[Export ("oneSignalApplicationDidBecomeActive:")]
public void OneSignalApplicationDidBecomeActive(UIApplication application) {
    Console.WriteLine ("oneSignalApplicationDidBecomeActive:");
}
+5
source

I had a similar problem with oneSignalDidFailRegisterForRemoteNotification: error:

Fixed with this code inside AppDelegate. Hope this helps.

[Export("oneSignalDidFailRegisterForRemoteNotification:error:")]
public void OneSignalDidFailRegisterForRemoteNotification(UIApplication app, NSError error)
    {
        Console.WriteLine("oneSignalDidFailRegisterForRemoteNotification:error:");
    }
+3
source

All Articles