OneSignal-Android-SDK icon indicating copy to clipboard operation
OneSignal-Android-SDK copied to clipboard

[Bug]: OneSignal subscription list shows "Permission is not granted" even the permission is already granted

Open softsan opened this issue 1 year ago • 5 comments

What happened?

For few of my users in production, can't get subscribed to Onesignal. It shows the record in subscription list but it shows as "Permission is not granted" I double / triple checked with the users and they all have given permission for Notification. They also did cache and data clear, logout, uninstall and fresh install several times but it doesn't make any difference. I am using the very latest version of OneSignal SDK. Here are some screenshots:

subscription_list

When i open that subscription, there is no "Externalid" and i am pretty sure I use that in my code: details

Steps to reproduce?

In my MainApplication.kt I init OneSignal like this:
OneSignal.initWithContext(applicationContext, oneSignalAppId)

this is how i asked permission:
CoroutineScope(Dispatchers.IO).launch {
                OneSignal.Notifications.requestPermission(true)
            }

And after login, i use this:
 OneSignal.login(userIdx)

and register the tags like this:
 OneSignal.User.addTag(key, value)

and on logout from my app i clear all the tags and also sign out from OneSignal
fun unregisterTag(key: String) {
        OneSignal.User.removeTag(key)
    }

fun removeExternalUserId() {
        OneSignal.logout()
    }

Also i created in-app Push prompt for those users and they received that and they always click on "Allow" button but it never get subscribed or if subscribed it shows as "Permission is not granted"

What did you expect to happen?

It should subscribed to Onesignal and should receive push notifications.

OneSignal Android SDK version

5.1.13

Android version

13, 12, 11

Specific Android models

Android 14 Samsung/ pixel device

Relevant log output

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

softsan avatar May 31 '24 13:05 softsan

Hello @softsan thanks for reaching out! Are you able to reproduce this on any devices you have? If so, capturing a debug log would be most helpful to see what's going on.

Thank you!

jennantilla avatar Jun 04 '24 19:06 jennantilla

@jennantilla No, it doesn't reproduce on our dev environment. It mostly on Production user. I also observed that for some of the production user, it shows as "Permission denied" and "Not subscribed" error on OneSignal dashboard. Unfortunately we don't have any access of their device and it's hard for them as well to get the device logs. Btw, do you have any SDK method to capture OneSignal logs (release logs) / device logs into a flle? if so i can use that method to dump logs into file and upload it to my server.

softsan avatar Jun 11 '24 18:06 softsan

@jennantilla Further on this, we have several other users who are seeing either "Permission not granted" or "Not subscribed" on OneSignal dashboard. We double checked that they logout from app, cleared their cache and data, uninstall and fresh install the app. But it still shows the the same on OneSignal dashboard.

os_ss

softsan avatar Jun 11 '24 20:06 softsan

@jennantilla Hello we have the same issue and we can reproduce it 100%.

Version: 5.1.14

How to reproduce?

  1. clean install the app
  2. use Onesignal.login to login user which already exists in onesignal console (that userId was previously logged in the app)
  3. right after that request permission using OneSignal.getNotifications().requestPermission and accept permission

Based on logs when you accept permission OperationRepo.enqueue(operation: {"name":"update-subscription is enqueued and after that should be executed by SubscriptionOperationExecutor and sent to console.

But problem is that if you manage to make step 3 (accepting permission) before login is executed via LoginUserOperationExecutor than SubscriptionOperationExecutor is not created and executed and subscription is in console shown as Permission Not Granted and stuck in that state. (It seems that restarting the app or changing onesignal tags doesn't help. Only fix is to disable permission and enable it manually again).

When it works correctly?

  • if you call Onesignal.login and wait few seconds until LoginUserOperationExecutor is executed and then accept permission, then it works correctly and SubscriptionOperationExecutor is created and user is shown as subscribed in console
  • if you request and accept permission and then after SubscriptionOperationExecutor is executed call Onesignal.login , then it works correctly and user is shown as subscribed in console

So there seems to be small window if you accept permission after login before login is actually executed that causes this issue that subscription is shown as Permission not granted. We upgraded onesignal from 4.x to 5x and this causes huge issue for us so please take a look at it

Here is the full log you can examine based on steps to reproduce: https://www.dropbox.com/scl/fi/0zd5j9oszm0s67be6tivh/onesignal_issue.tft.rtf?rlkey=hxs6eeahdek9ykqzqddonqksv&dl=0

socialError avatar Jun 14 '24 12:06 socialError

@socialError thanks for breaking down the issue and documenting exactly when the issue does and doesn't happen.

The root of the issue is when a LoginUserOperation is being combined with a UpdateSubscriptionOperation. LoginUserOperationExecutor processes these together and makes a single REST API call as follows:

HttpClient: Request
Sent = POST
https://api.onesignal.com/apps/{{APP_ID}}/users - Body: {"identity":{"external_id":"SOME_EXISTING_ID"},"subscriptions":
[{"id":"11111111-2222-3333-444444444444","token":"FCM_PUSH_TOKEN","enabled":true,"notification_types":1}],"properties":
{"timezone_id":"Europe\/Bratislava","language":"en"},"refresh_device_metadata":true
}

The OneSignal REST API should be able to accept the subscription update, however as you noted there is a bug where if the externalId already exists the update on the subscription doesn't happen.

This is something the OneSignal backend is looking into, and we will update you here once it is fixed.

jkasten2 avatar Jun 21 '24 17:06 jkasten2

@socialError @softsan this backend issue is now fixed!

To any avoid possibilities of a client side event being skipped (mostly prompting for notification permission outside of the OneSignal SDK) I also recommend you use the OneSignal-Android-SDK 5.1.15 or newer.

jkasten2 avatar Jul 09 '24 22:07 jkasten2

my android users are still having this issue....

yarodevuci avatar Oct 09 '25 05:10 yarodevuci

Any fixes for this? Still experiencing this issue...

TimMouskhelichvili avatar Nov 01 '25 23:11 TimMouskhelichvili

I’m also facing the same issue, but I’m unable to reproduce it. I’ve lost nearly half a million users because of this.

TamilCodeRays avatar Nov 04 '25 11:11 TamilCodeRays

The same problem appeared. When give consent for the first time the status is Permission Not Granted. If revoke consent and give it a second time, the issue is fixed

Buinich avatar Nov 18 '25 09:11 Buinich

In my scenario, the user initially receives notifications, but after some time their status suddenly changes to ‘Never Subscribed’. Since this happens randomly and after a delay, I’m not able to reproduce the issue consistently.

TamilCodeRays avatar Nov 18 '25 09:11 TamilCodeRays

In my scenario, the user initially receives notifications, but after some time their status suddenly changes to ‘Never Subscribed’. Since this happens randomly and after a delay, I’m not able to reproduce the issue consistently.

onesignal sdk version - 5.1.30 Firebase Fcm Sdk version - 25.0.0

TamilCodeRays avatar Nov 18 '25 09:11 TamilCodeRays

I'm also experiencing this issue in production using onesignal_flutter: ^5.3.4. It works perfectly fine on most devices, but we’re seeing this problem mainly on certain Android devices. What’s strange is that on the same device with the same build, it sometimes works and then suddenly stops working without any changes. When it stops working:

  • No new records appear in the OneSignal dashboard.
  • Subscriptions become orphaned (missing external ID).
  • iOS devices work perfectly fine; this issue seems isolated to Android.

It’s difficult to reproduce consistently, but it’s definitely happening in real user scenarios. Hoping for a stable fix soon.

JneelaWhisker avatar Nov 21 '25 14:11 JneelaWhisker

To fix the issue I have to clear all devices for the user...

yarodevuci avatar Nov 21 '25 22:11 yarodevuci