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

[Bug]: OneSignal does

Open hdralexandru opened this issue 1 year ago • 6 comments

What happened?

On some phones, OneSignal does not generate a subscription id OR ask for notifications permissions. Strangely, it only happens on random phones (e.g. Samsung A50). On other phones, no matter how many times I reinstall the app, it works perfectly.

I've posted the logs below (the numbers before [DEBUG] is a row number, ignore it together with [DEBUG])

Even if I restart the app multiple times, the pushSubscriptionId still won't generate. It has internet connection and the permission for Notifications is granted from System Settings

Steps to reproduce?

1. Install the an app with OneSignal 5.1.0
2. Launch the app
3. The pop-up for notifications won't show and the token is never created

What did you expect to happen?

The pop-up for permission for notifications should show (I call optIn()) and a subscriptionId should be created

OneSignal Android SDK version

5.1.0

Android version

13

Specific Android models

Samsung A50

Relevant log output

0 [DEBUG] initWithContext(context: com.myapp.myapp.ImoApp@1ec90, appId: dba777d7-****-****-************)

588 [DEBUG] OperationRepo.enqueue(
operation: {
  "name": "create-subscription",
  "appId": "dba777d7-****-****-************",
  "onesignalId": "local-0a11fcae-****-****-****-************",
  "subscriptionId": "local-0d56aaa3-****-****-****-************",
  "type": "PUSH",
  "enabled": false,
  "address": "",
  "status": "NO_PERMISSION"
}, 
flush: false)
589 [DEBUG] OperationRepo.enqueue(
operation: {
  "name": "login-user",
  "appId": "dba777d7-****-****-************",
  "onesignalId": "local-0a11fcae-****-****-****-************"
}, flush: false)

590 [DEBUG] ConfigModelListener: fetching parameters for appId: dba777d7-****-****-************
591 [DEBUG] ParamsBackendService.fetchParams(appId: dba777d7-****-****-************, subscriptionId: null)
592 [DEBUG] LoginUserOperationExecutor(operation: [
[
  {
    "name": "login-user",
    "appId": "dba777d7-****-****-************",
    "onesignalId": "local-0a11fcae-****-****-****-************",
    "id": "fe******-****-****-****-************"
  },
  {
    "name": "create-subscription",
    "appId": "dba777d7-****-****-************",
    "onesignalId": "local-0a11fcae-****-****-****-************",
    "subscriptionId": "local-0d56aaa3-****-****-****-************",
    "type": "PUSH",
    "enabled": false,
    "address": "",
    "status": "NO_PERMISSION",
    "id": "4b231e4d-****-****-****-************"
  }
])
593 [DEBUG] HttpClient: GET apps/dba777d7-****-****-************/android_params.js
594 [DEBUG] NotificationsManager.addPermissionObserver(observer: com.onesignal.notifications.internal.listeners.DeviceRegistrationListener@829fda7)
595 [DEBUG] setTag(key: debug_app, value: true)
596 [DEBUG] OperationRepo.enqueue(operation: {"name":"set-tag","appId":"dba777d7-****-****-************","onesignalId":"local-0a11fcae-****-****-****-************","key":"debug_app","value":"true"}, flush: false)
597 [DEBUG] OperationRepo.enqueue(operation: {
  "name": "update-subscription",
  "appId": "dba777d7-****-****-************",
  "onesignalId": "local-0a11fcae-****-****-****-************",
  "subscriptionId": "local-0d56aaa3-****-****-****-************",
  "type": "PUSH",
  "enabled": false,
  "address": "",
  "status": "FIREBASE_FCM_INIT_ERROR"
}, flush: false)
598 [DEBUG] Attempted to clean 6 month old IAM data, but none exists!
605 [DEBUG] HttpClient: POST apps/dba777d7-****-****-************/users -{
  "subscriptions": [
    {
      "type": "AndroidPush",
      "token": "",
      "enabled": false,
      "notification_types": 0,
      "sdk": "050100",
      "device_model": "SM-A505FN",
      "device_os": "11",
      "rooted": false,
      "net_type": 0,
      "carrier": "orange",
      "app_version": "251"
    }
  ],
  "properties": {
    "timezone_id": "Europe/Bucharest",
    "language": "en"
  },
  "refresh_device_metadata": true
}
606 [DEBUG] ApplicationService.onActivityCreated(0,APP_CLOSE): com.myapp.myapp.MainActivity@eacf5b0

618 [DEBUG] InfluenceManager.attemptSessionUpgrade: Trackers after update attempt: [ChannelTracker{tag=notification_id, influenceType=UNATTRIBUTED, indirectIds=null, directId=null}, ChannelTracker{tag=iam_id, influenceType=UNATTRIBUTED, indirectIds=null, directId=null}]
620 [DEBUG] initWithContext(context: com.myapp.myapp.ImoApp@1ec90, appId: null)
621 [DEBUG] initWithContext: SDK already initialized

625 [DEBUG] OperationRepo.enqueue(operation:
{
  "name": "update-subscription",
  "appId": "dba777d7-****-****-************",
  "onesignalId": "local-0a11fcae-****-****-****-************",
  "subscriptionId": "local-0d56aaa3-****-****-****-************",
  "type": "PUSH",
  "enabled": false,
  "address": "",
  "status": "FIREBASE_FCM_INIT_ERROR"
}, flush: false)

631 [WARN] HttpClient: POST Error thrown from network stack.  | Throwable: connection closed
632 [WARN] HttpClient: null Error thrown from network stack.  | Throwable: connection closed
633 [INFO] Failed to get Android parameters, trying again in 30 seconds.
634 [DEBUG] OperationRepo: execute response = FAIL_RETRY
635 [DEBUG] LoginUserOperationExecutor(operation: [
  {
    "name": "login-user",
    "appId": "dba777d7-****-****-************",
    "onesignalId": "local-0a11fcae-****-****-****-************",
    "id": "fe90498f-****-****-****-************"
  },
  {
    "name": "create-subscription",
    "appId": "dba777d7-****-****-************",
    "onesignalId": "local-0a11fcae-****-****-****-************",
    "subscriptionId": "local-0d56aaa3-****-****-****-************",
    "type": "PUSH",
    "enabled": false,
    "address": "",
    "status": "NO_PERMISSION",
    "id": "4b231e4d-****-****-****-************"
  },
  {
    "name": "update-subscription",
    "appId": "dba777d7-****-****-************",
    "onesignalId": "local-0a11fcae-****-****-****-************",
    "subscriptionId": "local-0d56aaa3-****-****-****-************",
    "type": "PUSH",
    "enabled": false,
    "address": "",
    "status": "FIREBASE_FCM_INIT_ERROR",
    "id": "d60707d7-****-****-****-************"
  },
  {
    "name": "update-subscription",
    "appId": "dba777d7-****-****-************",
    "onesignalId": "local-0a11fcae-****-****-****-************",
    "subscriptionId": "local-0d56aaa3-****-****-****-************",
    "type": "PUSH",
    "enabled": false,
    "address": "",
    "status": "FIREBASE_FCM_INIT_ERROR",
    "id": "1a7289a6-****-****-****-************"
  }
])
636 [DEBUG] HttpClient: POST apps/dba777d7-****-****-************/users - {
  "subscriptions": [
    {
      "type": "AndroidPush",
      "token": "",
      "enabled": false,
      "notification_types": -8,
      "sdk": "050100",
      "device_model": "SM-A505FN",
      "device_os": "11",
      "rooted": false,
      "net_type": 0,
      "carrier": "orange",
      "app_version": "251"
    }
  ],
  "properties": {
    "timezone_id": "Europe/Bucharest",
    "language": "en"
  },
  "refresh_device_metadata": true
}
643 [DEBUG] ParamsBackendService.fetchParams(appId: dba777d7-****-****-************, subscriptionId: null)
644 [DEBUG] HttpClient: GET apps/dba777d7-****-****-************/android_params.js

675 [WARN] HttpClient: POST Error thrown from network stack.  | Throwable: connection closed
676 [DEBUG] OperationRepo: execute response = FAIL_RETRY
677 [DEBUG] LoginUserOperationExecutor(operation: [
  {
    "name": "login-user",
    "appId": "dba777d7-****-****-************",
    "onesignalId": "local-0a11fcae-****-****-****-************",
    "id": "fe90498f-****-****-****-************"
  },
  {
    "name": "create-subscription",
    "appId": "dba777d7-****-****-************",
    "onesignalId": "local-0a11fcae-****-****-****-************",
    "subscriptionId": "local-0d56aaa3-****-****-****-************",
    "type": "PUSH",
    "enabled": false,
    "address": "",
    "status": "NO_PERMISSION",
    "id": "4b231e4d-****-****-****-************"
  },
  {
    "name": "update-subscription",
    "appId": "dba777d7-****-****-************",
    "onesignalId": "local-0a11fcae-****-****-****-************",
    "subscriptionId": "local-0d56aaa3-****-****-****-************",
    "type": "PUSH",
    "enabled": false,
    "address": "",
    "status": "FIREBASE_FCM_INIT_ERROR",
    "id": "d60707d7-****-****-****-************"
  },
  {
    "name": "update-subscription",
    "appId": "dba777d7-****-****-************",
    "onesignalId": "local-0a11fcae-****-****-****-************",
    "subscriptionId": "local-0d56aaa3-****-****-****-************",
    "type": "PUSH",
    "enabled": false,
    "address": "",
    "status": "FIREBASE_FCM_INIT_ERROR",
    "id": "1a7289a6-****-****-****-************"
  }
])
678 [DEBUG] HttpClient: POST apps/dba777d7-****-****-************/users - {
  "subscriptions": [
    {
      "type": "AndroidPush",
      "token": "",
      "enabled": false,
      "notification_types": -8,
      "sdk": "050100",
      "device_model": "SM-A505FN",
      "device_os": "11",
      "rooted": false,
      "net_type": 0,
      "carrier": "orange",
      "app_version": "251"
    }
  ],
  "properties": {
    "timezone_id": "Europe/Bucharest",
    "language": "en"
  },
  "refresh_device_metadata": true
}
679 [WARN] HttpClient: null Error thrown from network stack.  | Throwable: connection closed
680 [INFO] Failed to get Android parameters, trying again in 40 seconds.

Code of Conduct

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

hdralexandru avatar Jan 12 '24 18:01 hdralexandru

Hi @hdralexandru thanks for reaching out! You mention that this only happens on random phones--does it consistently happen on those phones (e.g. Samsung A50), or does it only sometimes happen?

From your logs, I'm seeing FIREBASE_FCM_INIT_ERROR which suggests the subscription is not enabled due to an FCM issue. Are you using the com.google.firebase:firebase-messaging dependency in your app? If so, is it up-to-date?

Thanks for the additional information!

jennantilla avatar Jan 12 '24 23:01 jennantilla

@jennantilla thank you for answering so fast!

Yes, it always happens on those phones; I can't reproduce the bug on my phones (S23, Pixel 5 or emulators), but on my client's phone it always happens. I've tried the very same build; same result I don't have firebase-messaging in my app; the only thing from firebase i'm using is Analytics

hdralexandru avatar Jan 13 '24 00:01 hdralexandru

The bug description had me wondering a bit..... :)

kpturner avatar Jan 15 '24 16:01 kpturner

In the logs posted I see the status is FIREBASE_FCM_INIT_ERROR This seems relevant. I imagine that the device is not able to receive an FCM token so OneSignal cannot create the push subscription.

emawby avatar Jan 16 '24 19:01 emawby

I've created an app with OneSignal only, no other libraries (beside compose) however, the error is still the same, FIREBASE_FCM_INIT_ERROR

hdralexandru avatar Jan 19 '24 08:01 hdralexandru

@hdralexandru thanks for your patience. Unfortunately I haven't been able to reproduce this issue, though I suspect that it is indeed an issue with the specific Samsung A50 device. Does the phone have the Google Play Store (Services) installed and a strong wifi connection?

Thank you for the additional details!

jennantilla avatar Jan 31 '24 02:01 jennantilla

@hdralexandru we updated to firebase-messaging version 23.4.0 in our OneSignal-Android-SDK 5.1.4 release. Some others have said using this version of FCM has fixed this FIREBASE_FCM_INIT_ERROR for them.

However if you continue to see the issue can you search for any "firebase" or "FCM" entries in your logcat? This should point the a more specific cause of why FIREBASE_FCM_INIT_ERROR is happening.

jkasten2 avatar Mar 01 '24 23:03 jkasten2

Closing due to no response

jkasten2 avatar Apr 02 '24 20:04 jkasten2

Sorry for the late reply. Did not see yours, @jkasten2 .

I will update the sdk later this week and come back here to post my conclusion

hdralexandru avatar Apr 02 '24 21:04 hdralexandru

Hi, I have exact same issue with latest OneSignal React Native v5.1.0. any solution for this? Subscription ID is not generating for some android devices.

perminder-klair avatar Apr 10 '24 15:04 perminder-klair