Onesignal-flutter-sdk: How to get the userid in flutter?

Created on 12 Apr 2019  路  2Comments  路  Source: OneSignal/OneSignal-Flutter-SDK

This is either a documentation omission, or a misunderstanding on my part.

In Flutter, how do you get the userid/playerid at any given time? I understand that you can use OneSignal.shared.setSubscriptionObserver() to get the userID initially, but is there really no way at all to get the userID again later?

In some parts of the documentation, I've seen references to getUserId and idsAvailable, but OneSignal.shared.getUserId and OneSignal.shared.idsAvailable are not valid functions.

Most helpful comment

Can you try String onesignalUserId = status.subscriptionStatus.userId;

https://documentation.onesignal.com/docs/flutter-sdk#section--getpermissionsubscriptionstate-

All 2 comments

Can you try String onesignalUserId = status.subscriptionStatus.userId;

https://documentation.onesignal.com/docs/flutter-sdk#section--getpermissionsubscriptionstate-

That works, thank you.

Was this page helpful?
0 / 5 - 0 ratings