OneSignal / OneSignal-DotNet-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your .NET app with OneSignal. https://onesignal.com
MIT License
16 stars 5 forks source link

[Bug]: App Crash when notifications permission is requested [iOS] #88

Open wilsonvargas opened 8 months ago

wilsonvargas commented 8 months ago

What happened?

We have installed OneSignal.DotNet version 5.0.2, and when attempting to request notification permissions using the following code:

OneSignal.Debug.LogLevel = LogLevel.VERBOSE;
OneSignal.Initialize(UniversalSettings.TokenNotification);
await OneSignal.Notifications.RequestPermissionAsync(true);

The application fails to function properly when requesting permissions, but only when it is published in the store.

Xamarin 4.8.0.1560

Steps to reproduce?

1. Install OneSignal.DotNet version 5.0.2.
2. Implement the permission request code mentioned in the application.
3. Publish the application to the store.
4. Observe that the application fails to request notification permissions in the published version.

What did you expect to happen?

The expected behavior is that the application successfully requests notification permissions without encountering any issues.

Relevant log output

["System.InvalidCastException: Unable to cast object of type 'Com.OneSignal.iOS.OSUser' to type 'Com.OneSignal.iOS.OSPushSubscription'.
  at ObjCRuntime.Runtime.GetNSObject[T] (System.IntPtr ptr) <0x106c5a3f0 + 0x00340> in <153620f857f54f9c9ab1e7a1e6853772#6b0a719b7c6e7d2ec24f13fb5be23ed5>:0 
  at Com.OneSignal.iOS.OSUser.get_PushSubscription () <0x1085b8b90 + 0x00053> in <d128b549342e4c12912477e6743b6ef0#6b0a719b7c6e7d2ec24f13fb5be23ed5>:0 
  at OneSignalSDK.DotNet.iOS.iOSPushSubscription.Initialize () <0x1085a0060 + 0x0007b> in <3846e65d363147fd849ba2d047a0f674#6b0a719b7c6e7d2ec24f13fb5be23ed5>:0 
  at OneSignalSDK.DotNet.iOS.iOSUserManager.Initialize () <0x10859f970 + 0x0004f> in <3846e65d363147fd849ba2d047a0f674#6b0a719b7c6e7d2ec24f13fb5be23ed5>:0 
  at OneSignalSDK.DotNet.iOS.iOSOneSignal.Initialize (System.String appId) <0x10859f3a0 + 0x000a3> in <3846e65d363147fd849ba2d047a0f674#6b0a719b7c6e7d2ec24f13fb5be23ed5>:0 
  at OneSignalSDK.DotNet.OneSignal.Initialize (System.String appId) <0x108596470 + 0x0003b> in <52693c75245f439194c30e607db2a9cb#6b0a719b7c6e7d2ec24f13fb5be23ed5>:0

Code of Conduct

emawby commented 8 months ago

@wilsonvargas Thank you for reporting we are investigating