Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: MAUI - OneSignal not working at all on iOS #53

Closed
1 task done
whoteit opened this issue Mar 25, 2023 · 12 comments
Closed
1 task done

[Bug]: MAUI - OneSignal not working at all on iOS #53

whoteit opened this issue Mar 25, 2023 · 12 comments
Assignees

Comments

@whoteit
Copy link

whoteit commented Mar 25, 2023

What happened?

First time OneSignal user. We create a .NET MAUI app targeting .NET 7.0 and followed the .NET guide to the letter.
https://documentation.onesignal.com/docs/net-sdk-setup

Everything works perfectly on Android, but nothing works on iOS. We call OneSignal.Default.Initialize(...) followed by PromptForPushNotificationsWithUserResponse, and nothing happens. No exceptions, no errors, and the device does not appear in the users list in the dashboard.

I set logs to verbose as follows :
OneSignal.Default.LogLevel = LogLevel.VERBOSE;
OneSignal.Default.AlertLevel = LogLevel.NONE;

... and yet nothing related to OneSignal is output to the debug window in Visual Studio when running on my iPhone. The logs work fine when debugging on Android (both emulator and physical device).

Steps to reproduce?

1. Create .NET MAUI app targeting .NET 7.0
2. Reference OneSignal nuget (<PackageReference Include="OneSignalSDK.DotNet" Version="4.3.3" />)
3. Add following code to App.xaml.cs
``OneSignal.Default.Initialize("...");
OneSignal.Default.PromptForPushNotificationsWithUserResponse();
OneSignal.Default.PushEnabled = true;``
4. Go to OneSignal dashboard. iPhone devices does not appear. All Android devices appear just fine.

What did you expect to happen?

Push notifications should work
iPhone user should appear in the users list in the dashboard

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@brismithers
Copy link
Contributor

@whoteit sorry you are having issues getting going! I created a new empty MAUI project and was able to reproduce what you are seeing. However after doing a rebuild of the solution, I started seeing things working including log statements! Can you try a full rebuild and see if that gets things going?

Thanks!

@brismithers brismithers self-assigned this Mar 27, 2023
@whoteit
Copy link
Author

whoteit commented Mar 27, 2023

No change unfortunately. Deleted obj / bin and rebuilt solution, still see nothing in the debug output related to OneSignal and notifications don't work / user doesn't appear in the Users list.

I am doing nothing special. This is the code of my App() constructor (App.xaml.cs)

        OneSignal.Default.LogLevel = LogLevel.VERBOSE;
        OneSignal.Default.AlertLevel = LogLevel.NONE;

        var promotionsAllowed = Preferences.Default.Get("promotions_allowed", true);

        if (promotionsAllowed)
        {
            OneSignal.Default.Initialize("...");
                
            OneSignal.Default.PushEnabled = true;
        }

@whoteit
Copy link
Author

whoteit commented Mar 27, 2023

@brismithers do you think this is due to me deploying a debug version to my iPhone (using VS hot-restart, without a paired mac or xcode) ?

@Driloncpp
Copy link

Hello everyone. Looks like you have the same problem as I have. Did you find any solution or fix for this problem?

@whoteit
Copy link
Author

whoteit commented Jul 18, 2023

Hello, yes. It turns out it doesn't work when deploying the app to iOS directly from Visual Studio (hot restart). It works fine without any changes when Visual Studio is paired with a Mac + XCode.

@Driloncpp
Copy link

What do you exactly mean with paired with a Mac + XCode? do I have to deploy it from a Mac to my device? Is there a documentation about it?

@whoteit
Copy link
Author

whoteit commented Jul 18, 2023

Yes, https://learn.microsoft.com/en-us/dotnet/maui/ios/pair-to-mac

Then when debugging in VS, chose iOS remote devices, and your iPhone (physically connected to your Mac) should appear there.

@douglassimaodev
Copy link

OneSignal.Default... where is "Default" it is not longer in there

@grabnerM
Copy link

grabnerM commented Jan 2, 2024

@douglassimaodev Same here.. Did you find a solution for this problem?

@emawby
Copy link
Contributor

emawby commented Jan 17, 2024

@grabnerM Hello Default has been removed since the beta versions of the SDK so you should be able to access the other namespaces directly. If you are not able to please let me know.

@grabnerM
Copy link

@emawby Hi, yeah i got it working. Just waiting for some PRs to get completed to finish this on our project. Otherwise everything works as expected

@nan-li
Copy link

nan-li commented Oct 24, 2024

Hi, we have had no further reports of this. If this is still an issue, please open a new report with updated information.

@nan-li nan-li closed this as completed Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants