OneSignal-Flutter-SDK
OneSignal-Flutter-SDK copied to clipboard
[Bug]: OneSignal.User.pushSubscription.id is null!
What happened?
I can't access subscriptionId , I want to use rest api in my app but I need subscriptionId for specific notification. I tried with copy subs id one signal panel thats runned not have a problem in my code, but inside the code not access have a directly subs id.
Steps to reproduce?
This is my code =>
OneSignal.initialize(Env.oneSignal);
OneSignal.login(token ?? '');
var sendTags = {
'deviceLanguage': deviceLang,
'deviceCountry': deviceCountry,
'status': 'free'
};
OneSignal.User.addTags(sendTags);
print(OneSignal.User.pushSubscription.id);
What did you expect to happen?
Easily access subs id
OneSignal Flutter SDK version
5.0.3
Which platform(s) are affected?
- [X] iOS
- [X] Android
Relevant log output
No response
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
i have the same issued
@aydemiromer My guess is that the subscription id has not been received from the server at the time you are attempting to access it. My recommendation would be to use the push subscription observer to get notified when a property of the subscription has changed. This will notify your app when the id has been set
I encountered this problem as well.
I am on v5.1.2 and when I am calling OneSignal.User.pushSubscription.id. I am getting null but after some milliseconds I am getting the data. This same issue was on OneSignal-Cordova #918 you can check there. It is solved now but I am getting that issue in flutter.
Is there a possible solution for the future? I would be very grateful if anyone could help solve this problem.
i have the same issued SDK 5.2.1
Same issue here. In v3 the userId was instant, now in v5.2.1 most times the Onesignal_id is null, just a once in a while it's present. How to resolve this?