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]: iOS object variable not set as soon it hits OneSignal when using Hot Restart #67

Open gabsamples6 opened 1 year ago

gabsamples6 commented 1 year ago

What happened?

  1. Launch the app
  2. when OneSignal.Debug.LogLevel = LogLevel.VERBOSE; is hit
  3. Get System.NullReferenceException: Object reference not set to an instance of an object. at OneSignalSDK.DotNet.iOS.iOSDebugManager.set_LogLevel(LogLevel value)

on any OneSignal call I get the above

Steps to reproduce?

1. Launch the app 
2. when     OneSignal.Debug.LogLevel = LogLevel.VERBOSE; is hit
3. Get  System.NullReferenceException: Object reference not set to an instance of an object.
   at OneSignalSDK.DotNet.iOS.iOSDebugManager.set_LogLevel(LogLevel value)

on any OneSignal call I get the above

What did you expect to happen?

Run the app so that I can initialize onesignal and send notification

Any suggestions

Relevant log output

System.NullReferenceException: Object reference not set to an instance of an object.
   at OneSignalSDK.DotNet.iOS.iOSDebugManager.set_LogLevel(LogLevel value)

Code of Conduct

shepherd-l commented 1 year ago

What .Net version are you using and what version is your Visual Studio?

gabsamples6 commented 1 year ago

@shepherd-l using

shepherd-l commented 1 year ago

Could you share a sample project with us that reproduces the issue?

gabsamples6 commented 1 year ago

@shepherd-l see attached project

See simple attached example - the main point of this sample is that it crashes in iOS when hitting the first line of code where Onesignal is used.

  1. Launch app in android

  2. Breakpoint on SharedPush.Initialize

  3. OneSignal.Debug all good

  4. Launch app in iOS

  5. Breakpoint on SharedPush.Initialize - OneSignal.Debug

  6. Crash -Object variable not set when breakpoint hit

Google-services json and entitlement.plist are empty as not important to demonstrate this bug

Attachment here OneSignalPoC.zip

thanks again for looking into this.

gabsamples6 commented 1 year ago

Any news? have you been able to replicate it?

Zack-G-I-T commented 12 months ago

@shepherd-l we have the same problem. Works fine on Android MAUI, but on ios we cant do anything with onesignal. We tried copying the sample app but cannot get it working. Is there some missing setup or something?

shepherd-l commented 11 months ago

I was unable to reproduce the error with the 5.0.2 release

Could you try upgrading to 5.0.2 and let us know if you are still seeing the issue?

@Zack-G-I-T could you also try upgrading to 5.0.2 as well?

gabsamples6 commented 11 months ago

@shepherd-l hi there thanks for the update but we are still having the same problem in iOS using 5.0.2 .. Can you tell me or share a project that worked for you?

shepherd-l commented 11 months ago

Let us know if this project works for you: https://drive.google.com/file/d/1OpZjo1G0BZBmeBOp1g_GeyxKfoNAYcIO/view?usp=share_link

I’m using

gabsamples6 commented 11 months ago

@shepherd-l hi thanks for the link but still not working for me -

  1. Launch the dotnet8 app in Visual studio 17.8.0 Preview 3.0 .net 8 (same with .net 7) or any version of visual studio
  2. Local iOS device
  3. As soon as it hits Onesignal.Debug you get image
emawby commented 11 months ago

@gabsamples6 Something about your dev environment must be different and is causing the issue so we should try to track it down. Is this working on Android for you? If you remove that debug line does it run for you?

gabsamples6 commented 11 months ago

@emawby hi -

Are you using a Mac? - we dont use mac for development as visual studio for mac is too buggy

gabsamples6 commented 11 months ago

Any news? did you manage to replicate the issue?

gabsamples6 commented 11 months ago

@shepherd-l @emawby hi there , is there any news on this one , have you been able to replicate the issue ?

many thanks

emawby commented 11 months ago

Hello we have not been able to replicate the issue yet. I imagine that this is because you are using Windows and we are using Mac. Are you using a physical device or a simulator? Do you know which build tools your visual studio uses for iOS builds?

gabsamples6 commented 11 months ago

Hi I am using a physical device as described in the instructions using windows pc and latest visual studio .i tried against 3 iPhone and same issue

emawby commented 11 months ago

@gabsamples6 Do you have a mac build host for your iOS builds? If so what xcode version/xcode build tools are you using on the host?

gabsamples6 commented 11 months ago

We build the app using azure devops pipelines using Microsoft hosted agents . Are u familiar with hot restart? That allows us to debug the app using a physical device without the usage of a Mac. Visual studio for Mac has been made obsolete and we had problem building our app that has more than 100 pages .so we use a pc . I do thing you should have a pc has this is an extremely common scenario

shepherd-l commented 11 months ago

We were able to reproduce your issue. Development builds with hot restart don’t seem to work with our SDK.

Production builds work for us when we connect the iOS device to the Mac directly instead of the Windows machine.

We recommend doing production builds with the device connected to the Mac as a workaround for now.

gabsamples6 commented 10 months ago

Hi We debugging we use a windows pc and connect an iPhone to it , bcse vs for mac has so many issues..

When we deploy we use Azure pipeline. that being said - are you in a position to tell us when the issue will be fixed?

many thanks

emawby commented 10 months ago

We are working on bumping our minimum version to .net7 which may help with this issue, but we have not been able to identify a fix yet for windows builds where the device is connected to the windows machine. We are still investigating.

gabsamples6 commented 9 months ago

@emawby anynews? many thanks

emawby commented 8 months ago

@gabsamples6 The update to .net7 will be available in the next release of this SDK. Thank you for your patience this has been a tricky one to resolve.

gabsamples6 commented 8 months ago

@emawby wonder why you are sticking to .net 7 when in no longer supported and not move to .net 8 , so are you saying that this also solves the issue of the object variable not set in debug time using a windows pc connected to a physical ios device?

And when is next release scheduled for?

A prompt reply would be very very welcome.