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]: Shows permission prompt without calling RequestPermissionAsync #637

Closed
1 task done
AFB-MORA opened this issue Sep 12, 2023 · 3 comments
Closed
1 task done

Comments

@AFB-MORA
Copy link

AFB-MORA commented Sep 12, 2023

What happened?

SDK automatically shows iOS permission prompt without calling OneSignal.Notifications.RequestPermissionAsync(true)

Steps to reproduce?

1. Install OneSignal 5.0.2
2. Initialize OneSignal with app id
3. Build project for iOS
4. Run the app

What did you expect to happen?

The prompt should NOT be shown.

Unity version

2022.3.2f1

OneSignal Unity SDK version

5.0.2

Platform

iOS

Relevant log output

No response

Code of Conduct

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

Could you share the following details, I was unable to reproduce the issue

Do you have any other SDKs installed?
What devices are you seeing this issue on and what version of iOS are they using?
Could you reproduce this issue in a new project and share it with us?

@AFB-MORA
Copy link
Author

I found the problem. I was calling OneSignal.User.PushSubscription.OptIn(); before calling OneSignal.Notifications.RequestPermissionAsync(true). I think "OptIn" shows permission prompt, if called first. I don't know this is a bug or by design.

@shepherd-l
Copy link
Contributor

shepherd-l commented Sep 26, 2023

Yes this is by design

OptIn() will display the permission prompt if the user hasn’t been prompted. If the user has already been prompted and the app’s settings has notifications permission disabled, the user will see a prompt to direct them to the settings app.

We created OptIn() as a shorthand method for developers to use. OneSignal.Notifications.requestPermissionAsync() can be used for more control.

Let me know if you have any questions

And thanks for the feedback, I plan on updating our documentation to make this more clear.

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

2 participants