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

[Bug]: OneSignal.User.pushSubscription.id is null!

Open aydemiromer opened this issue 2 years ago • 6 comments
trafficstars

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

aydemiromer avatar Oct 13 '23 12:10 aydemiromer

i have the same issued

jackie-maxx avatar Oct 20 '23 11:10 jackie-maxx

@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

emawby avatar Oct 23 '23 17:10 emawby

I encountered this problem as well.

pimtidaN455 avatar Dec 24 '23 05:12 pimtidaN455

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.

ashutosh9152 avatar Mar 20 '24 06:03 ashutosh9152

i have the same issued SDK 5.2.1

YurchukV avatar Jun 17 '24 06:06 YurchukV

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?

pkitatta avatar Jul 04 '24 12:07 pkitatta