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

[question]: Permission not granted after optIn #1824

Closed
1 task done
MarianoManzi opened this issue Aug 30, 2023 · 23 comments
Closed
1 task done

[question]: Permission not granted after optIn #1824

MarianoManzi opened this issue Aug 30, 2023 · 23 comments

Comments

@MarianoManzi
Copy link

MarianoManzi commented Aug 30, 2023

How can we help?

In my app i have a switch to enable and disable notifications the following is the listner on the switch:

switch.setOnCheckedChangeListener { _, isChecked ->
  if (OneSignal.Notifications.permission) {
    if (isChecked) OneSignal.User.pushSubscription.optIn() else OneSignal.User.pushSubscription.optOut()
  } else CoroutineScope(Dispatchers.IO).launch { OneSignal.Notifications.requestPermission(true) }
}

The problem is that when i call OneSignal.User.pushSubscription.optIn(), even if OneSignal.Notifications.permission is true the OneSignal console tells me thet the user hasn't granted the permission.

The OneSignal.User.pushSubscription.optOut() work as expected.

Code of Conduct

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

Hi @MarianoManzi thanks for reaching out! I have not been able to reproduce this issue. Would you be able to provide the logs from the device so we can take a closer look?

Thanks!

@MarianoManzi
Copy link
Author

Hi @jennantilla, thanks for the answer.

I try to give you more information. So when I call the optIn function I get the error: Subscription can't change notification_types to positive integer while disabled, but as I said befor the OneSignal.Notifications.permission is correctly true (checking from the devices settings the notification permission are granted) and when, from the system dialog, I accept the notification permission the onNotificationPermissionChange is triggered with the right value.

[DefaultDispatcher-worker-5] HttpClient: PATCH RECEIVED JSON: {"errors":[{"code":"subscription-10","title":"Subscription can't change notification_types to positive integer while disabled"}]}

Operation execution failed without retry: [{"name":"update-subscription","appId":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx","onesignalId":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx","subscriptionId":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx","type":"PUSH","enabled":false,"address":"","status":"SUBSCRIBED","id":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}]

@RickRedSix
Copy link

Hi @MarianoManzi, did you ever resolve this?

It might be related, but I seem to be having a similar issue but with the react-native-onesignal package and it's only on Android.

OneSignal/react-native-onesignal#1590

@juandl
Copy link

juandl commented Oct 18, 2023

I can confirm the same issue.

@MarianoManzi
Copy link
Author

Hi @RickRedSix unfortunally not

@excasualdev
Copy link

Have similar problem on Amazon Fire HD 10 device.
Push notifications just not received. After first application start user seems like "subscribed" in onesignal dashboard, but after try to send notification he turns to "Not subscribed" and after second application start I got the same error:
{"errors":[{"code":"subscription-10","title":"Subscription can't change notification_types to positive integer while disabled"}]}

But there is no problem on simple android devices.

@MarianoManzi did you resolve this problem?

@MarianoManzi
Copy link
Author

Hi @excasualdev nothing yet, I suggest you follow also the issue opened by @RickRedSix a few week ago

@gvalenza
Copy link

Hi, i've the same issue {"errors":[{"code":"subscription-10","title":"Subscription can't change notification_types to positive integer while disabled"}]}

@MarianoManzi did you resolve this problem?

@MarianoManzi
Copy link
Author

Hi @gvalenza, unfortunally nothing, for now i'm sticking with the old release

@gvalenza
Copy link

@MarianoManzi what version are you using?
I'm using 5.0.3 of one signal

@MarianoManzi
Copy link
Author

@gvalenza I'm having this issue since upgrading to the major release 5.0, now I've rolled back to the 4.
I've noticed that now is also aviable the 5.0.4 but I haven't got the chance to test it yet.

@parkdcom
Copy link

Still experiencing the same issue with v5.0.4

@nan-li
Copy link
Contributor

nan-li commented Jan 9, 2024

Hi @MarianoManzi,

Thanks for sharing your logs. I am interested in this line:

Operation execution failed without retry: [{
  "name":"update-subscription",
  "appId":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "onesignalId":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "subscriptionId":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "type":"PUSH",
  "enabled":false,
  "address":"",
  "status":"SUBSCRIBED",
  "id":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}]

The SDK sent an update to the server. Is this logged right after you call optIn()?

It shows that the "address" is empty, which means there is no push token, or no push token YET. That is why this error response is received upon trying to optIn.

Does this happen often in your testing? You can check for the push token with OneSignal.User.pushSubscription.token

@jennantilla
Copy link
Contributor

Hello everyone! Just an update that this was fixed in 5.1.1 of our SDK. Please update to this version and let us know if you are having any additional issues. Thanks!

@jgalindosl
Copy link

I have updated to 5.1.1, but the issue remains.

PATCH RECEIVED JSON: {"errors":[{"code":"subscription-10","title":"Subscription can't change notification_types to positive integer while disabled"}]}
Operation execution failed without retry: [{"name":"update-subscription","appId":"xx","onesignalId":"xx","subscriptionId":"xx","type":"PUSH","enabled":false,"address":"","status":"SUBSCRIBED","id":"xx"}]

@VitalyTimofeev
Copy link

try to add firebase messaging to your dependencies, helped us to fix this error:

implementation "com.google.firebase:firebase-messaging:$ext.firebaseMessaging"

@jgalindosl
Copy link

try to add firebase messaging to your dependencies, helped us to fix this error:

implementation "com.google.firebase:firebase-messaging:$ext.firebaseMessaging"

This did the trick for me. Thanks

@ramirezi29
Copy link

Similar to the other posts, adding the following line to my build.gradle's dependencies section solved the issue:
implementation 'com.google.firebase:firebase-messaging:23.4.0'

@nan-li
Copy link
Contributor

nan-li commented Jan 29, 2024

Hi @jgalindosl, what version of com.google.firebase:firebase-messaging did you use to resolve this error?

PATCH RECEIVED JSON: {"errors":[{"code":"subscription-10","title":"Subscription can't change notification_types to positive integer while disabled"}]}

Hi @ramirezi29, were you seeing the exact same error about "Subscription can't change notification_types to positive integer while disabled" or a different issue?

Noting that the OneSignal Android SDK already includes a dependency to firebase-messaging here albeit an older version.

@jgalindosl
Copy link

For me

implementation 'com.onesignal:OneSignal:5.1.1'
implementation "com.google.firebase:firebase-messaging:23.4.0"

did the trick @nan-li

@nan-li
Copy link
Contributor

nan-li commented Jan 30, 2024

Thank you for following up @jgalindosl I appreciate the details.
This is interesting, we will investigate why our included firebase-messaging dependency was not sufficient.

@harini18
Copy link

harini18 commented Feb 10, 2024

We have been having this same issue with OneSignalFlutter 5.1.0 version.

@arda-copur
Copy link

They say they send permissions automatically, but unfortunately it needs to be turned on from the device settings. They think I need to access each user's device.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests