You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Subscription stuck at NO_PERMISSION after reinstall when notification permission already granted #2621
Reopen — do NOT toggle the notification permission
Expected Behavior
Notifications work normally after reinstall. Subscription status becomes SUBSCRIBED.
Actual Behavior
OneSignal dashboard shows "Permission Not Granted". getOptedInAsync() returns false.
The state may eventually recover (hours later), or never recover at all.
Root Cause
After reading the SDK source, the chain is:
1. NotificationsManager.permission is initialized correctly:
After reinstall, permission is already granted → permission = true from the start.
2. Fresh subscription has status = NO_PERMISSION:
// UserSwitcher.kt — createAndSwitchToNewUser()
status = currentPushSubscription?.status ?:SubscriptionStatus.NO_PERMISSION
After data clear, no previous subscription exists → status = NO_PERMISSION.
3. retrievePushTokenAndUpdateSubscription() — the function that fixes status — has only two triggers:
// DeviceRegistrationListener.ktoverridefunonNotificationPermissionChange(permission:Boolean) {
retrievePushTokenAndUpdateSubscription() // trigger A
}
overridefunonModelReplaced(model:ConfigModel, tag:String) {
if (tag !=ModelChangeTags.HYDRATE) return
retrievePushTokenAndUpdateSubscription() // trigger B
}
4. Neither trigger fires:
Trigger A (onNotificationPermissionChange): never fires because setPermissionStatusAndFire() only fires when oldPermission != newPermission. Since permission starts as true (correctly read at init), and the system permission never changes, no event is emitted.
Trigger B (onModelReplaced(HYDRATE)): only fires when the ConfigModel is re-fetched from the backend. If the config cache is still valid, no re-fetch occurs → never fires.
Result:status stays NO_PERMISSION indefinitely. The subscription is optedIn = model.optedIn && status != NO_PERMISSION = false.
Suggested Fix
In DeviceRegistrationListener.start(), add a startup check:
overridefunstart() {
_configModelStore.subscribe(this)
_notificationsManager.addPermissionObserver(this)
_subscriptionManager.subscribe(this)
// Fix: if permission is already granted but subscription status is NO_PERMISSION,// trigger token retrieval immediately on startup.if (_notificationsManager.permission) {
retrievePushTokenAndUpdateSubscription()
}
}
This is safe — retrievePushTokenAndUpdateSubscription() is idempotent and already handles the case where a token exists.
import{OneSignal}from'react-native-onesignal';import{useEffect}from'react';exportdefaultfunctionApp(){useEffect(()=>{OneSignal.initialize('YOUR_APP_ID');OneSignal.login('test-user-123');// Grant permission on first install, then reinstall the app without// revoking the permission. The subscription will be stuck at NO_PERMISSION.OneSignal.Notifications.requestPermission(false);// After reinstall: canRequestPermission() returns false (already asked),// so requestPermission() is skipped. But the fresh subscription has// status = NO_PERMISSION, and no trigger ever calls// retrievePushTokenAndUpdateSubscription() to fix it.setTimeout(async()=>{constoptedIn=awaitOneSignal.User.pushSubscription.getOptedInAsync();consthasPermission=awaitOneSignal.Notifications.getPermissionAsync();consttoken=awaitOneSignal.User.pushSubscription.getTokenAsync();console.log({ optedIn, hasPermission, token });// After reinstall:// hasPermission: true ← system permission is granted// optedIn: false ← stuck// token: null ← never retrieved},5000);},[]);returnnull;}
Repro steps:
Run on Android 13+ device
Launch app → grant notification permission → confirm optedIn: true
Reinstall (adb install -r or clear app data via Settings)
Reopen — do not touch the notification permission toggle
Activity
tp26610 commentedon Apr 23, 2026
Minimal Reproduction (React Native)
Repro steps:
optedIn: trueadb install -ror clear app data via Settings)optedIn: falsedespitehasPermission: truetp26610 commentedon Apr 23, 2026
A fix has been submitted in #2622.