Comments (3)
If your code is more or less exactly the same as you posted, there is a limitation in the doc saying:
Any User namespace calls must be invoked after initialization. Example: OneSignal.User.addTag("tag", "2")
Maybe you should initialize the SDK, then inside a provider subscribe into permissionChange event and wait for confirmation and ONLY THEN ask for the ID. This justified delay may help in your case, but if you don't want to "justify", you can try if a setTimeout
works.
from react-native-onesignal.
Hello there! In 5.1.0 we updated the Push Subscription property getters to be async so that the value is always correct. Please upgrade to this version and let us know if you are still having any issues.
Thanks!
from react-native-onesignal.
We also have a similar issue while using version 5.0.5. I can not reproduce this by myself, but I get corresponding Sentry-Exceptions.
- Initialize OneSignal during app start
OneSignal.Debug.setLogLevel(LogLevel.Verbose);
OneSignal.initialize(appId);
OneSignalHelper.requestPermission();
OneSignalHelper.addEventListener(...)
- Get the subscription ID. To make sure that OneSignal is correctly initialized, we do a 5-times retry with 2 seconds timeout each. Additionally, the user needs to fill in a login form before this function is executed. That means our last attempt to retrieve the subscription ID is typically 12-20 seconds after app start.
OneSignal.User.pushSubscription.getPushSubscriptionId()
Nevertheless, for some users we don't get a subscription ID. This happens on Android (13, 14) as well as on iOS (15.8 up to 17.4)
from react-native-onesignal.
Related Issues (20)
- airplane mode ON: notifications lost? HOT 3
- [Bug]: The requestPermission method for notifications returns a Promise<array> on iOS. HOT 2
- [Bug]: iOS `pod install --repo-update` not working
- TypeError: _$$_REQUIRE(_dependencyMap[22], (...)ationWillShowInForegroundHandler is not a function (it is undefined), js engine: hermes HOT 1
- [Bug]: promptForPushNotificationsWithUserResponse puts app in background for half a second for no reason HOT 1
- devices iOS and android are not received any push notif HOT 1
- [Bug]: ApplicationService.getAppContext java.lang.NullPointerException HOT 3
- Crash: PermissionsActivity.reregisterCallbackHandlers HOT 2
- [Bug]: OneSignal: This method has been deprecated. Use getIdAsync instead for getting push subscription id. HOT 5
- [Bug]: fallback alert is always shown on iOS HOT 3
- How to solve this Error in XCode Multiple commands produce React-Core-60309c9c-RCTI18nStrings | React-Core-RCTI18nStrings? HOT 5
- [Bug]: stale/wrong data in getPermissionAsync and requestPermission methods HOT 4
- [Bug]: Duplicate notifications occur when using an additional SDK, and foregroundWillDisplay does not fire with notifications from sources outside of OneSignal. HOT 2
- [Bug]: Linking fails on macbook pro m2 when trying to run app on iphone simulator HOT 1
- [Bug]: Onesignal does not show notification when app in foreground android HOT 3
- Incorrect Notification Badge Count on Android Devices with Expo React Native
- [Bug]: Possibly threading issue with willDisplay on Android + documentation clarification
- [Feedback]: Bump to OneSignal-iOS-SDK 3.12.8 / privacy manifest requirement HOT 2
- [question]: Starting a new project in React Native with the new architecture enabled HOT 4
- [question]: How to prevent web notifications from showing when tab is being viewed? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-onesignal.