OneSignal/OneSignal-DotNet-SDK

[Bug]: .Net Maui -> Notification Permission Prompt is not appearing.

Opened this issue · 6 comments

What happened?

Notification Permission Prompt not appearing if one signal is not initialized in constructor of App.xaml.cs or MainPage.xaml.cs
We want to subscribe one signal only after the user is logged in. So we moved the below line to login button click
OneSignal.Initialize("xxxxxxxxxxx");
after that Notification Permission Prompt is not appearing. We tried both
OneSignal.User.PushSubscription.OptIn();
and
OneSignal.InAppMessages.AddTrigger("showPrompt", "true");

Steps to reproduce?

Remove the below line in App start [public App(){ OneSignal.Initialize("xxxxxxxxxxx"); }]
OneSignal.Initialize("xxxxxxxxxxx");

What did you expect to happen?

Notification Permission Prompt is not appearing.

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
emawby commented

@palanikumar32 Could you try OneSignal.Notifications.RequestPermissionAsync()

@palanikumar32 Could you try OneSignal.Notifications.RequestPermissionAsync()

Thanks for the reply, already tried no luck.

emawby commented

@palanikumar32 Could you try enabling verbose logging and reporting what you see in the logs? Do any other OneSignal methods work? Also is the behavior the same for both iOS and Android?

@palanikumar32 Could you try enabling verbose logging and reporting what you see in the logs? Do any other OneSignal methods work? Also is the behavior the same for both iOS and Android?

Here i attached the logs, unfortunately right now I couldn't test the same behavior in IOS.
Problem is our App will get onesignal id only after login, so we want to trigger OneSignal.Initialize and permission dialog only on login success.
log-initialize-button-click.txt
log-subscribe-button-click.txt
OneSignalMaui-testapp.zip

Screenshot

@palanikumar32 I apologize for the late response. I am not able to reproduce this issue on Android or iOS. We are doing a release soon that updates the native iOS and Android SDK dependencies, uses .net7 tools instead of legacy Xamarin build tools, and fixes other various bugs. When that release is available I will ping here again and we can try to reproduce. I believe that this issue may be resolved by that release.

For me, this was happening when I was calling OneSignal.Initialize(...) in OnStart rather than in App Constructor.