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]: opted in state stops updating on Android after app restarted #1625

Closed
2 of 3 tasks
chriszs opened this issue Jan 9, 2024 · 8 comments
Closed
2 of 3 tasks

[Bug]: opted in state stops updating on Android after app restarted #1625

chriszs opened this issue Jan 9, 2024 · 8 comments

Comments

@chriszs
Copy link

chriszs commented Jan 9, 2024

What happened?

The opt-in and opt-out states stop updating on Android after the app is killed and restarted once or twice. The listener doesn't fire and getOptedIn returns the wrong value.

Steps to reproduce?

  1. https://reactnative.dev/docs/environment-setup?guide=native
  2. git clone -b onesignal-bug-demo https://github.com/chriszs/test-expo-app.git
  3. cd test-expo-app
  4. npm i
  5. echo "EXPO_PUBLIC_ONESIGNAL_APP_ID=<ONESIGNAL_ID_HERE>" > .env
  6. npx expo run:android
  7. Tap "OPT IN", tap "OPT OUT" (text should update accordingly)
  8. Tap the overview (square) hardware or soft button or swipe up on the bar at the bottom of the Android screen to view the app changer, then swipe up on the card representing this app to close it
  9. Reopen the app
  10. Tap "OPT IN", tap "OPT OUT" (text may not update)
  11. If text updates, repeat 8-10 until it stops

What did you expect to happen?

I expected the push subscription change event to trigger and the opted-in state to update when the user opts in or out even after the app is restarted.

React Native OneSignal SDK version

5.0.4

Which platform(s) are affected?

  • iOS
  • Android

Relevant log output

When I first run the app, it works as expected, and I see a log like:

2024-01-04 11:17:39.489  8180-8399  OneSignal               com.bf.appced43b                     D  [DefaultDispatcher-worker-2] HttpClient: GET apps/95209e17-8092-4894-a52f-276ea2c66226/users/by/onesignal_id/a7b09c5e-7ab1-40ed-8d88-e4b88e42be83
2024-01-04 11:17:39.492  8180-8401  OneSignal               com.bf.appced43b                     D  [DefaultDispatcher-worker-4] HttpClient: GET apps/95209e17-8092-4894-a52f-276ea2c66226/subscriptions/cdb1cb79-4d7d-4793-8026-c13ab5d8a870/iams
2024-01-04 11:17:39.506  8180-8180  OneSignal               com.bf.appced43b                     I  sending subscription change event

But after killing the app (swiping up on the card) and then reopening it, the event fires maybe once or not at all per opt in or out, and the opted-in state I can access is stuck either opted-in or opted-out, despite logs indicating a 200 success API PATCH operation. Here's what a restart and a couple toggles looks like:

---------------------------- PROCESS STARTED (12532) for package com.bf.appced43b ----------------------------
2024-01-04 11:53:03.920 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] initWithContext(context: com.bf.appced43b.MainActivity@d7ebb85, appId: 95209e17-8092-4894-a52f-276ea2c66226)
2024-01-04 11:53:03.920 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] initWithContext: SDK initializing
2024-01-04 11:53:03.921 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service interface com.onesignal.core.internal.application.IApplicationService
2024-01-04 11:53:03.921 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Found constructor: public com.onesignal.core.internal.application.impl.ApplicationService()
2024-01-04 11:53:03.922 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] ApplicationService: current activity=com.bf.appced43b.MainActivity@d7ebb85
2024-01-04 11:53:03.922 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] ApplicationService.init: entryState=APP_OPEN
2024-01-04 11:53:03.922 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service class com.onesignal.core.internal.config.ConfigModelStore
2024-01-04 11:53:03.922 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Found constructor: public com.onesignal.core.internal.config.ConfigModelStore(com.onesignal.core.internal.preferences.IPreferencesService)
2024-01-04 11:53:03.922 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service interface com.onesignal.core.internal.preferences.IPreferencesService
2024-01-04 11:53:03.922 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Found constructor: public com.onesignal.core.internal.preferences.impl.PreferencesService(com.onesignal.core.internal.application.IApplicationService,com.onesignal.core.internal.time.ITime)
2024-01-04 11:53:03.922 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service interface com.onesignal.core.internal.application.IApplicationService
2024-01-04 11:53:03.922 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Already instantiated: com.onesignal.core.internal.application.impl.ApplicationService@733554a
2024-01-04 11:53:03.922 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service interface com.onesignal.core.internal.time.ITime
2024-01-04 11:53:03.922 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Found constructor: public com.onesignal.core.internal.time.impl.Time()
2024-01-04 11:53:03.929 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service class com.onesignal.session.internal.session.SessionModelStore
2024-01-04 11:53:03.929 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Found constructor: public com.onesignal.session.internal.session.SessionModelStore(com.onesignal.core.internal.preferences.IPreferencesService)
2024-01-04 11:53:03.929 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service interface com.onesignal.core.internal.preferences.IPreferencesService
2024-01-04 11:53:03.929 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Already instantiated: com.onesignal.core.internal.preferences.impl.PreferencesService@ebc47f0
2024-01-04 11:53:03.932 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service interface com.onesignal.location.ILocationManager
2024-01-04 11:53:03.932 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Found constructor: public com.onesignal.location.internal.LocationManager(com.onesignal.core.internal.application.IApplicationService,com.onesignal.location.internal.capture.ILocationCapturer,com.onesignal.location.internal.controller.ILocationController,com.onesignal.location.internal.permissions.LocationPermissionController)
2024-01-04 11:53:03.932 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service interface com.onesignal.core.internal.application.IApplicationService
2024-01-04 11:53:03.932 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Already instantiated: com.onesignal.core.internal.application.impl.ApplicationService@733554a
2024-01-04 11:53:03.932 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service interface com.onesignal.location.internal.capture.ILocationCapturer
2024-01-04 11:53:03.932 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Found constructor: public com.onesignal.location.internal.capture.impl.LocationCapturer(com.onesignal.core.internal.application.IApplicationService,com.onesignal.core.internal.time.ITime,com.onesignal.location.internal.preferences.ILocationPreferencesService,com.onesignal.user.internal.properties.PropertiesModelStore,com.onesignal.location.internal.controller.ILocationController)
2024-01-04 11:53:03.932 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service interface com.onesignal.core.internal.application.IApplicationService
2024-01-04 11:53:03.932 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Already instantiated: com.onesignal.core.internal.application.impl.ApplicationService@733554a
2024-01-04 11:53:03.932 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service interface com.onesignal.core.internal.time.ITime
2024-01-04 11:53:03.932 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Already instantiated: com.onesignal.core.internal.time.impl.Time@7b5f169
2024-01-04 11:53:03.932 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service interface com.onesignal.location.internal.preferences.ILocationPreferencesService
2024-01-04 11:53:03.932 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Found constructor: public com.onesignal.location.internal.preferences.impl.LocationPreferencesService(com.onesignal.core.internal.preferences.IPreferencesService)
2024-01-04 11:53:03.932 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service interface com.onesignal.core.internal.preferences.IPreferencesService
2024-01-04 11:53:03.932 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Already instantiated: com.onesignal.core.internal.preferences.impl.PreferencesService@ebc47f0
2024-01-04 11:53:03.932 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service class com.onesignal.user.internal.properties.PropertiesModelStore
2024-01-04 11:53:03.932 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Found constructor: public com.onesignal.user.internal.properties.PropertiesModelStore(com.onesignal.core.internal.preferences.IPreferencesService)
2024-01-04 11:53:03.932 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service interface com.onesignal.core.internal.preferences.IPreferencesService
2024-01-04 11:53:03.932 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Already instantiated: com.onesignal.core.internal.preferences.impl.PreferencesService@ebc47f0
2024-01-04 11:53:03.934 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service interface com.onesignal.location.internal.controller.ILocationController
2024-01-04 11:53:03.934 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service interface com.onesignal.core.internal.device.IDeviceService
2024-01-04 11:53:03.934 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Found constructor: public com.onesignal.core.internal.device.impl.DeviceService(com.onesignal.core.internal.application.IApplicationService)
2024-01-04 11:53:03.934 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service interface com.onesignal.core.internal.application.IApplicationService
2024-01-04 11:53:03.934 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Already instantiated: com.onesignal.core.internal.application.impl.ApplicationService@733554a
2024-01-04 11:53:03.937 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service interface com.onesignal.location.internal.controller.ILocationController
2024-01-04 11:53:03.937 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service class com.onesignal.location.internal.permissions.LocationPermissionController
2024-01-04 11:53:03.937 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Found constructor: public com.onesignal.location.internal.permissions.LocationPermissionController(com.onesignal.core.internal.permissions.IRequestPermissionService,com.onesignal.core.internal.application.IApplicationService)
2024-01-04 11:53:03.937 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service interface com.onesignal.core.internal.permissions.IRequestPermissionService
2024-01-04 11:53:03.937 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Found constructor: public com.onesignal.core.internal.permissions.impl.RequestPermissionService(com.onesignal.core.internal.application.IApplicationService)
2024-01-04 11:53:03.937 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service interface com.onesignal.core.internal.application.IApplicationService
2024-01-04 11:53:03.937 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Already instantiated: com.onesignal.core.internal.application.impl.ApplicationService@733554a
2024-01-04 11:53:03.937 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service interface com.onesignal.core.internal.application.IApplicationService
2024-01-04 11:53:03.937 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Already instantiated: com.onesignal.core.internal.application.impl.ApplicationService@733554a
2024-01-04 11:53:03.938 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service interface com.onesignal.user.IUserManager
2024-01-04 11:53:03.938 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Found constructor: public com.onesignal.user.internal.UserManager(com.onesignal.user.internal.subscriptions.ISubscriptionManager,com.onesignal.user.internal.identity.IdentityModelStore,com.onesignal.user.internal.properties.PropertiesModelStore,com.onesignal.core.internal.language.ILanguageContext)
2024-01-04 11:53:03.938 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service interface com.onesignal.user.internal.subscriptions.ISubscriptionManager
2024-01-04 11:53:03.938 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Found constructor: public com.onesignal.user.internal.subscriptions.impl.SubscriptionManager(com.onesignal.core.internal.application.IApplicationService,com.onesignal.session.internal.session.ISessionService,com.onesignal.user.internal.subscriptions.SubscriptionModelStore)
2024-01-04 11:53:03.938 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service interface com.onesignal.core.internal.application.IApplicationService
2024-01-04 11:53:03.938 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Already instantiated: com.onesignal.core.internal.application.impl.ApplicationService@733554a
2024-01-04 11:53:03.938 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service interface com.onesignal.session.internal.session.ISessionService
2024-01-04 11:53:03.938 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Found constructor: public com.onesignal.session.internal.session.impl.SessionService(com.onesignal.core.internal.application.IApplicationService,com.onesignal.core.internal.config.ConfigModelStore,com.onesignal.session.internal.session.SessionModelStore,com.onesignal.core.internal.time.ITime)
2024-01-04 11:53:03.938 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service interface com.onesignal.core.internal.application.IApplicationService
2024-01-04 11:53:03.938 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Already instantiated: com.onesignal.core.internal.application.impl.ApplicationService@733554a
2024-01-04 11:53:03.938 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service class com.onesignal.core.internal.config.ConfigModelStore
2024-01-04 11:53:03.938 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Already instantiated: com.onesignal.core.internal.config.ConfigModelStore@e593687
2024-01-04 11:53:03.938 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service class com.onesignal.session.internal.session.SessionModelStore
2024-01-04 11:53:03.938 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Already instantiated: com.onesignal.session.internal.session.SessionModelStore@e0389b4
2024-01-04 11:53:03.938 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service interface com.onesignal.core.internal.time.ITime
2024-01-04 11:53:03.938 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Already instantiated: com.onesignal.core.internal.time.impl.Time@7b5f169
2024-01-04 11:53:03.938 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service class com.onesignal.user.internal.subscriptions.SubscriptionModelStore
2024-01-04 11:53:03.938 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Found constructor: public com.onesignal.user.internal.subscriptions.SubscriptionModelStore(com.onesignal.core.internal.preferences.IPreferencesService)
2024-01-04 11:53:03.938 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service interface com.onesignal.core.internal.preferences.IPreferencesService
2024-01-04 11:53:03.938 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Already instantiated: com.onesignal.core.internal.preferences.impl.PreferencesService@ebc47f0
2024-01-04 11:53:03.941 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service class com.onesignal.user.internal.identity.IdentityModelStore
2024-01-04 11:53:03.941 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Found constructor: public com.onesignal.user.internal.identity.IdentityModelStore(com.onesignal.core.internal.preferences.IPreferencesService)
2024-01-04 11:53:03.941 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service interface com.onesignal.core.internal.preferences.IPreferencesService
2024-01-04 11:53:03.941 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Already instantiated: com.onesignal.core.internal.preferences.impl.PreferencesService@ebc47f0
2024-01-04 11:53:03.942 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service class com.onesignal.user.internal.properties.PropertiesModelStore
2024-01-04 11:53:03.942 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Already instantiated: com.onesignal.user.internal.properties.PropertiesModelStore@8ff40aa
2024-01-04 11:53:03.942 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service interface com.onesignal.core.internal.language.ILanguageContext
2024-01-04 11:53:03.942 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Found constructor: public com.onesignal.core.internal.language.impl.LanguageContext(com.onesignal.user.internal.properties.PropertiesModelStore)
2024-01-04 11:53:03.942 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service class com.onesignal.user.internal.properties.PropertiesModelStore
2024-01-04 11:53:03.943 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Already instantiated: com.onesignal.user.internal.properties.PropertiesModelStore@8ff40aa
2024-01-04 11:53:03.943 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service interface com.onesignal.session.ISessionManager
2024-01-04 11:53:03.943 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Found constructor: public com.onesignal.session.internal.SessionManager(com.onesignal.session.internal.outcomes.IOutcomeEventsController)
2024-01-04 11:53:03.943 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service interface com.onesignal.session.internal.outcomes.IOutcomeEventsController
2024-01-04 11:53:03.943 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Found constructor: public com.onesignal.session.internal.outcomes.impl.OutcomeEventsController(com.onesignal.session.internal.session.ISessionService,com.onesignal.session.internal.influence.IInfluenceManager,com.onesignal.session.internal.outcomes.impl.IOutcomeEventsRepository,com.onesignal.session.internal.outcomes.impl.IOutcomeEventsPreferences,com.onesignal.session.internal.outcomes.impl.IOutcomeEventsBackendService,com.onesignal.core.internal.config.ConfigModelStore,com.onesignal.user.internal.identity.IdentityModelStore,com.onesignal.user.internal.subscriptions.ISubscriptionManager,com.onesignal.core.internal.device.IDeviceService,com.onesignal.core.internal.time.ITime)
2024-01-04 11:53:03.943 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service interface com.onesignal.session.internal.session.ISessionService
2024-01-04 11:53:03.943 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Already instantiated: com.onesignal.session.internal.session.impl.SessionService@9fbb811
2024-01-04 11:53:03.943 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service interface com.onesignal.session.internal.influence.IInfluenceManager
2024-01-04 11:53:03.943 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Found constructor: public com.onesignal.session.internal.influence.impl.InfluenceManager(com.onesignal.session.internal.session.ISessionService,com.onesignal.core.internal.application.IApplicationService,com.onesignal.core.internal.config.ConfigModelStore,com.onesignal.core.internal.preferences.IPreferencesService,com.onesignal.core.internal.time.ITime)
2024-01-04 11:53:03.943 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Retrieving service interface com.onesignal.session.internal.session.ISessionService
2024-01-04 11:53:03.943 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Already instantiated: com.onesignal.session.internal.session.impl.SessionService@9fbb811
[...snip...]
2024-01-04 11:53:03.996 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Already instantiated: com.onesignal.inAppMessages.internal.InAppMessagesManager@8c5049c
2024-01-04 11:53:03.996 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Already instantiated: com.onesignal.location.internal.permissions.LocationPermissionController@ff2aea5
2024-01-04 11:53:03.997 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] Already instantiated: com.onesignal.location.internal.LocationManager@57b984f
2024-01-04 11:53:03.997 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] initWithContext: using cached user a7b09c5e-7ab1-40ed-8d88-e4b88e42be83
2024-01-04 11:53:03.997 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] OperationRepo.enqueue(operation: {"name":"refresh-user","appId":"95209e17-8092-4894-a52f-276ea2c66226","onesignalId":"a7b09c5e-7ab1-40ed-8d88-e4b88e42be83"}, flush: false)
2024-01-04 11:53:03.999 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] NotificationsManager.addPermissionObserver(observer: com.onesignal.notifications.internal.listeners.DeviceRegistrationListener@428d27a)
2024-01-04 11:53:04.001 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] NotificationsManager.addPermissionObserver(observer: com.onesignal.rnonesignalandroid.RNOneSignal@9defa2b)
2024-01-04 11:53:04.001 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] LocationManager.setIsShared(value: false)
2024-01-04 11:53:04.007 12532-12639 OneSignal               com.bf.appced43b                     D  [Thread-12] ConfigModelListener: fetching parameters for appId: 95209e17-8092-4894-a52f-276ea2c66226
2024-01-04 11:53:04.007 12532-12639 OneSignal               com.bf.appced43b                     D  [Thread-12] ParamsBackendService.fetchParams(appId: 95209e17-8092-4894-a52f-276ea2c66226, subscriptionId: cdb1cb79-4d7d-4793-8026-c13ab5d8a870)
2024-01-04 11:53:04.010 12532-12615 OneSignal               com.bf.appced43b                     D  [DefaultDispatcher-worker-2] HttpClient: GET apps/95209e17-8092-4894-a52f-276ea2c66226/android_params.js?player_id=cdb1cb79-4d7d-4793-8026-c13ab5d8a870
2024-01-04 11:53:04.011 12532-12615 OneSignal               com.bf.appced43b                     D  [DefaultDispatcher-worker-2] HttpClient: Adding header if-none-match: W/"24ab72d6a5a6ec5d0b665af376675f9f"
2024-01-04 11:53:04.012 12532-12617 OneSignal               com.bf.appced43b                     D  [DefaultDispatcher-worker-4] Attempted to clean 6 month old IAM data, but none exists!
2024-01-04 11:53:04.021 12532-12614 OneSignal               com.bf.appced43b                     D  [DefaultDispatcher-worker-1] HttpClient: GET apps/95209e17-8092-4894-a52f-276ea2c66226/subscriptions/cdb1cb79-4d7d-4793-8026-c13ab5d8a870/iams
2024-01-04 11:53:04.023 12532-12640 OneSignal               com.bf.appced43b                     D  [OpRepo] RefreshUserOperationExecutor(operation: [{"name":"refresh-user","appId":"95209e17-8092-4894-a52f-276ea2c66226","onesignalId":"a7b09c5e-7ab1-40ed-8d88-e4b88e42be83","id":"8a72ffa1-abed-443e-9e02-b79328e9027b"}])
2024-01-04 11:53:04.024 12532-12617 OneSignal               com.bf.appced43b                     D  [DefaultDispatcher-worker-4] HttpClient: GET apps/95209e17-8092-4894-a52f-276ea2c66226/users/by/onesignal_id/a7b09c5e-7ab1-40ed-8d88-e4b88e42be83
2024-01-04 11:53:04.121 12532-12615 OneSignal               com.bf.appced43b                     D  [DefaultDispatcher-worker-2] HttpClient: GET apps/95209e17-8092-4894-a52f-276ea2c66226/android_params.js?player_id=cdb1cb79-4d7d-4793-8026-c13ab5d8a870 - Using Cached response due to 304: {"awl_list":{},"android_sender_id":"166098764301","chnl_lst":[],"enterp":true,"outcomes":{"direct":{"enabled":true},"indirect":{"notification_attribution":{"minutes_since_displayed":60,"limit":10},"enabled":true},"unattributed":{"enabled":true}},"receive_receipts_enable":true}
2024-01-04 11:53:04.489 12532-12614 OneSignal               com.bf.appced43b                     D  [DefaultDispatcher-worker-1] HttpClient: GET apps/95209e17-8092-4894-a52f-276ea2c66226/subscriptions/cdb1cb79-4d7d-4793-8026-c13ab5d8a870/iams - STATUS: 200 JSON: {"in_app_messages":[]}
2024-01-04 11:53:04.489 12532-12642 OneSignal               com.bf.appced43b                     D  [Thread-15] InAppMessagesManager.evaluateInAppMessages()
2024-01-04 11:53:04.490 12532-12617 OneSignal               com.bf.appced43b                     D  [DefaultDispatcher-worker-4] HttpClient: GET apps/95209e17-8092-4894-a52f-276ea2c66226/users/by/onesignal_id/a7b09c5e-7ab1-40ed-8d88-e4b88e42be83 - STATUS: 200 JSON: {"properties":{"language":"en","timezone_id":"[REDACTED]","country":"[REDACTED]","first_active":1704272326,"last_active":1704339144,"ip":"[REDACTED]"},"identity":{"onesignal_id":"a7b09c5e-7ab1-40ed-8d88-e4b88e42be83"},"subscriptions":[{"id":"cdb1cb79-4d7d-4793-8026-c13ab5d8a870","app_id":"95209e17-8092-4894-a52f-276ea2c66226","type":"AndroidPush","token":"dcZ4qAwYRxqx9Cz4OUi4le:APA91bHmuWIRMrsaXjgEiAdoFh-2Mas2w6vXwj0Fk5Yfg2BArWwqJ5XqHW3uirdknLCxp6SxvVczjLnYPyigWz5buO1rounfJLGiHE6O09HDDXOWyyWauxhGrSqMKXBUU_9EclkQQzw_","enabled":true,"notification_types":1,"session_time":0,"session_count":1,"sdk":"050005","device_model":"sdk_gphone64_arm64","device_os":"13","rooted":false,"test_type":0,"app_version":"1","net_type":0,"carrier":"T-Mobile","web_auth":"","web_p256":""}]}
2024-01-04 11:53:04.491 12532-12640 OneSignal               com.bf.appced43b                     D  [OpRepo] OperationRepo: execute response = SUCCESS
2024-01-04 11:53:11.225 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] OperationRepo.enqueue(operation: {"name":"update-subscription","appId":"95209e17-8092-4894-a52f-276ea2c66226","onesignalId":"a7b09c5e-7ab1-40ed-8d88-e4b88e42be83","subscriptionId":"cdb1cb79-4d7d-4793-8026-c13ab5d8a870","type":"PUSH","enabled":true,"address":"dcZ4qAwYRxqx9Cz4OUi4le:APA91bHmuWIRMrsaXjgEiAdoFh-2Mas2w6vXwj0Fk5Yfg2BArWwqJ5XqHW3uirdknLCxp6SxvVczjLnYPyigWz5buO1rounfJLGiHE6O09HDDXOWyyWauxhGrSqMKXBUU_9EclkQQzw_","status":"SUBSCRIBED"}, flush: false)
2024-01-04 11:53:11.427 12532-12640 OneSignal               com.bf.appced43b                     D  [OpRepo] SubscriptionOperationExecutor(operations: [{"name":"update-subscription","appId":"95209e17-8092-4894-a52f-276ea2c66226","onesignalId":"a7b09c5e-7ab1-40ed-8d88-e4b88e42be83","subscriptionId":"cdb1cb79-4d7d-4793-8026-c13ab5d8a870","type":"PUSH","enabled":true,"address":"dcZ4qAwYRxqx9Cz4OUi4le:APA91bHmuWIRMrsaXjgEiAdoFh-2Mas2w6vXwj0Fk5Yfg2BArWwqJ5XqHW3uirdknLCxp6SxvVczjLnYPyigWz5buO1rounfJLGiHE6O09HDDXOWyyWauxhGrSqMKXBUU_9EclkQQzw_","status":"SUBSCRIBED","id":"94e57625-7368-4387-92aa-2937593907ef"}])
2024-01-04 11:53:11.431 12532-12614 OneSignal               com.bf.appced43b                     D  [DefaultDispatcher-worker-1] HttpClient: PATCH apps/95209e17-8092-4894-a52f-276ea2c66226/subscriptions/cdb1cb79-4d7d-4793-8026-c13ab5d8a870 - {"subscription":{"type":"AndroidPush","token":"dcZ4qAwYRxqx9Cz4OUi4le:APA91bHmuWIRMrsaXjgEiAdoFh-2Mas2w6vXwj0Fk5Yfg2BArWwqJ5XqHW3uirdknLCxp6SxvVczjLnYPyigWz5buO1rounfJLGiHE6O09HDDXOWyyWauxhGrSqMKXBUU_9EclkQQzw_","enabled":true,"notification_types":1,"sdk":"050005","device_model":"sdk_gphone64_arm64","device_os":"13","rooted":false,"net_type":0,"carrier":"T-Mobile","app_version":"1"}}
2024-01-04 11:53:11.757 12532-12614 OneSignal               com.bf.appced43b                     D  [DefaultDispatcher-worker-1] HttpClient: PATCH apps/95209e17-8092-4894-a52f-276ea2c66226/subscriptions/cdb1cb79-4d7d-4793-8026-c13ab5d8a870 - STATUS: 200 JSON: {}
2024-01-04 11:53:11.757 12532-12640 OneSignal               com.bf.appced43b                     D  [OpRepo] OperationRepo: execute response = SUCCESS
2024-01-04 11:53:23.775 12532-12620 OneSignal               com.bf.appced43b                     D  [mqt_native_modules] OperationRepo.enqueue(operation: {"name":"update-subscription","appId":"95209e17-8092-4894-a52f-276ea2c66226","onesignalId":"a7b09c5e-7ab1-40ed-8d88-e4b88e42be83","subscriptionId":"cdb1cb79-4d7d-4793-8026-c13ab5d8a870","type":"PUSH","enabled":false,"address":"dcZ4qAwYRxqx9Cz4OUi4le:APA91bHmuWIRMrsaXjgEiAdoFh-2Mas2w6vXwj0Fk5Yfg2BArWwqJ5XqHW3uirdknLCxp6SxvVczjLnYPyigWz5buO1rounfJLGiHE6O09HDDXOWyyWauxhGrSqMKXBUU_9EclkQQzw_","status":"UNSUBSCRIBE"}, flush: false)
2024-01-04 11:53:23.977 12532-12640 OneSignal               com.bf.appced43b                     D  [OpRepo] SubscriptionOperationExecutor(operations: [{"name":"update-subscription","appId":"95209e17-8092-4894-a52f-276ea2c66226","onesignalId":"a7b09c5e-7ab1-40ed-8d88-e4b88e42be83","subscriptionId":"cdb1cb79-4d7d-4793-8026-c13ab5d8a870","type":"PUSH","enabled":false,"address":"dcZ4qAwYRxqx9Cz4OUi4le:APA91bHmuWIRMrsaXjgEiAdoFh-2Mas2w6vXwj0Fk5Yfg2BArWwqJ5XqHW3uirdknLCxp6SxvVczjLnYPyigWz5buO1rounfJLGiHE6O09HDDXOWyyWauxhGrSqMKXBUU_9EclkQQzw_","status":"UNSUBSCRIBE","id":"5debf42a-83bd-4893-b58d-84df66178d50"}])
2024-01-04 11:53:23.981 12532-12614 OneSignal               com.bf.appced43b                     D  [DefaultDispatcher-worker-1] HttpClient: PATCH apps/95209e17-8092-4894-a52f-276ea2c66226/subscriptions/cdb1cb79-4d7d-4793-8026-c13ab5d8a870 - {"subscription":{"type":"AndroidPush","token":"dcZ4qAwYRxqx9Cz4OUi4le:APA91bHmuWIRMrsaXjgEiAdoFh-2Mas2w6vXwj0Fk5Yfg2BArWwqJ5XqHW3uirdknLCxp6SxvVczjLnYPyigWz5buO1rounfJLGiHE6O09HDDXOWyyWauxhGrSqMKXBUU_9EclkQQzw_","enabled":false,"notification_types":-2,"sdk":"050005","device_model":"sdk_gphone64_arm64","device_os":"13","rooted":false,"net_type":0,"carrier":"T-Mobile","app_version":"1"}}
2024-01-04 11:53:24.361 12532-12614 OneSignal               com.bf.appced43b                     D  [DefaultDispatcher-worker-1] HttpClient: PATCH apps/95209e17-8092-4894-a52f-276ea2c66226/subscriptions/cdb1cb79-4d7d-4793-8026-c13ab5d8a870 - STATUS: 200 JSON: {}
2024-01-04 11:53:24.362 12532-12640 OneSignal               com.bf.appced43b                     D  [OpRepo] OperationRepo: execute response = SUCCESS

Code of Conduct

  • I agree to follow this project's Code of Conduct
@chriszs chriszs changed the title [Bug]: opted in state stops updating on Android [Bug]: opted in state stops updating on Android after app restarted Jan 9, 2024
@jennantilla
Copy link
Contributor

jennantilla commented Jan 17, 2024

Hi @chriszs thanks for reaching out! Originally I thought this was related to #1590 but see that it is a different issue. We'll look into this.

@chriszs
Copy link
Author

chriszs commented Feb 1, 2024

Thanks! I just verified that by upgrading to onesignal-react-native 5.0.5 and checking the latest Android SDK was loaded. My minimal reproduction still reflects the issue.

@chriszs
Copy link
Author

chriszs commented Feb 3, 2024

I just tried this on a fresh install of bare React Native 0.73.2 (well, the React Native reproducer template), following the steps in the SDK setup docs to verify it wasn't an Expo or setup issue and added some logging to make sure OneSignal was initializing and the listeners were registering (which is a step recommended in the troubleshooting docs). I also added a button to call getOptedIn, which in my testing also fails to get an updated opted in state. I also tried initializing outside the useEffect hook, as per the example in the setup docs, but that initialized it on every state change, and didn't seem to fix the issue. It still repros, as far as I can tell. Here's that version with the OneSignal key I used replaced with ONESIGNAL KEY GOES HERE.

@chriszs
Copy link
Author

chriszs commented Feb 15, 2024

I downgraded my upgrade PR back to v4, which is what I'm going to use until this is fixed.

@diegobonagurio
Copy link

@chriszs I have the same situation, when running initialize I can't get the user token.

@devinbrown7
Copy link

We're facing this issue as well with v5.0.6. We've rolled back to v4.5.2 until this is resolved.

@woodwa68
Copy link

woodwa68 commented Mar 7, 2024

We are also encountering this in v5.0.6. Exact same behavior where getOptedIn returns false despite logcat indicating that the optIn is sending the API request successfully and the eventListener never seems to acknowledge the change.

@jennantilla
Copy link
Contributor

Hello everyone! Thank you for your patience. We just released 5.1.0 which ensures that the push subscription opted in state, token, and id are accessed asynchronously so the correct values are given every time. We have deprecated getOptedIn, getPushSubscriptionTokenand now usegetOptedInAsyncandgetTokenAsync`. Please see our migration guide and code samples for using these new methods.

Please let us know if you have any additional questions or concerns!

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

5 participants