-
Notifications
You must be signed in to change notification settings - Fork 368
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
[Feedback]: notification permission API confusion #2184
Comments
@KChernenko thanks for the feedback, I'll expand a bit more on optIn & optOutUsage CasesUse these if you want to have an option were end-users can turn off OneSignal push notifications inside your app. DescriptionCall
Additional ConsiderationsNote OneSignal SDK keeps track of which was called last requestPermission
onNotificationPermissionChange
It should fire in both cases, as long as you foreground the app after you change the setting. If you are using an older SDK than OneSignal-Android-SDK 5.1.15 please update, s there was a bug in older versions. If you can still reproduce on the latest version can you share details on how you reproduce the issue?
Also I won't recommend calling While your questions here are the right place to ask them at your scale you may want to reach out to OneSignal support for faster support. |
@jkasten2 When can we call as example Is the nofitication permission required for that or can we call the login at any time? Also what happens if we call |
You can call
Repeated calls to |
Thanks for the answer. How can I call Example: In my app, I can switch between a test system and a live system. Both systems have a different OneSignal App ID. Do I need to perform a logout first when switching systems, or what is the best approach to handle this? |
@michael-winkler changing the appId isn't support in the SDK. If you need to change the value for you testing you must clear all data for your app in the Android settings, or uninstall and reinstall the app. |
Is there a possibility that you could integrate something like this into the SDK? It would be great if you could add this as a feature. This was also asked by another user: This leads to another question. Example: I have a successful subscription. Now, I completely clear the app's cache. I log in again with my old external User ID. Will everything work as before and be restored? |
@jkasten2 Can you please give here again an answer? 😄 |
The SDK wasn't designed for the appId to change, just about every part of the SDK depends on it. Could you explain your use case?
Clearing the app's cache won't affect this, only clearing the app's data will. It behaves just like uninstalling and reinstall the app. If you login to the same external User ID the SDK will recover the User, however since the data was cleared it will created a new push subscription. |
What's on your mind?
SDK's API is highly confusing when dealing with the system notifications permission flow.
We're a significant client with tens of millions of installs and several millions of MAU. We want to show our custom screen that explains why we need notification permission and request this permission ourselves. Later, after the user onboarding process, we engage them using your service. With your SDK, after years of being your customer, we're still trying to figure out how to achieve this. In the documentation, you're saying that in order to turn off internal system notifications permission request, we need after the
OneSignal.initWithContext(this, ONESIGNAL_APP_ID)
Call (by the way, why is it a suspended function?)
However, in the migration guide, you're mentioning:
pushSubscription.optIn()
And its conterpart:
pushSubscription.optOut()
Do we need to call
optIn()
right after the SDK initialization? If yes, shouldOneSignal.Notifications.requestPermission(false)
be called after or before theoptIn()
? We tried both ways, and in either case, an internal system notifications permission request is executed, and a permission dialog shows up in the places we do not want. We tried to calloptIn()
in theOneSignal.Notifications.addPermissionObserver
:The callback is triggered only when permission is enabled. When we disable the permission in the system setting (Android 14), we do not receive the
onNotificationPermissionChange
, so theoptOut()
call is not executed.It is extremely important for us to provide a smooth and legal complaint flow for our users, but currently, we can not do this due to an unknown reason (it's a bug, multiple bugs, not clear documentation, or both?).
Code of Conduct
The text was updated successfully, but these errors were encountered: