[Bug]: Application crashes without possibility to cach it on iOS
Immons opened this issue · 4 comments
What happened?
The latest version (4.3.2) and previous also crashes application on iOS when initializing and waiting for token.
System.NullReferenceException: Object reference not set to an instance of an object
at OneSignalSDK.Xamarin.OneSignalImplementation+OSPermissionObserver.OnOSPermissionChanged (Com.OneSignal.iOS.OSPermissionStateChanges permissionStateChanges) [0x00018] in /Users/briansmith/Development/OneSignal/onesignal-xamarin-sdk/OneSignalSDK.Xamarin.iOS/OneSignalCallbacks.cs:79
at (wrapper managed-to-native) UIKit.UIApplication.xamarin_UIApplicationMain(int,string[],intptr,intptr,intptr&)
at UIKit.UIApplication.UIApplicationMain (System.Int32 argc, System.String[] argv, System.IntPtr principalClassName, System.IntPtr delegateClassName) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.1.1.27/src/Xamarin.iOS/UIKit/UIApplication.cs:57
at UIKit.UIApplication.Main (System.String[] args, System.Type principalClass, System.Type delegateClass) [0x0003b] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.1.1.27/src/Xamarin.iOS/UIKit/UIApplication.cs:92
at KidsTime.iOS.Application.Main (System.String[] args) [0x00002] in /Users/immons/Projects/KidsTime/KidsTime.Mobiles/KidsTime.iOS/Main.cs:15
Steps to reproduce?
Initialize OneSignal with following code:
OneSignal.Default.LogLevel = LogLevel.VERBOSE;
OneSignal.Default.Initialize(AppConstants.OneSignalId);
await OneSignal.Default.PromptForPushNotificationsWithUserResponse();
OneSignal.Default.NotificationOpened += DefaultOnNotificationWasOpened;
OneSignal.Default.NotificationWillShow += DefaultOnNotificationWillShow;
OneSignal.Default.PushSubscriptionStateChanged += DefaultOnPushSubscriptionStateChanged;
What did you expect to happen?
It should register and not crash.
OneSignal Xamarin SDK version
4.3.2
Which platform(s) are affected?
- iOS
- Android
Relevant log output
No response
Code of Conduct
- I agree to follow this project's Code of Conduct
Thanks for the report!
Though I haven't been able to reproduce this, I suspect the issue is related to the callbacks being added before we set _instance = this
. I think we can change the ordering, but I'm curious if you are able to help me understand the device state when this crashes?
- Has the app ever successfully been brought up where the OneSignal SDK has been initialized?
- What is the current notification permission state on startup?
The issue is not reproducible always. For sure it should be initialized, because on app start I am displaying pinpad screen, and after successful pin authorization I am registering also with OneSignal. The problem on my devices occurs every 3-4 launches.
Thanks @Immons . I've marked this as a bug and we will try to address what I believe to be a timing window during initialization.
@Immons I've made the change and released v4.3.3. Please let me know if this addresses your issue