OneSignal-Flutter-SDK
OneSignal-Flutter-SDK copied to clipboard
getDeviceState is missing
Can't use getDeviceState method with new version. I looked documentation but didn't see any information about this. What could I use instead?
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
@berkaymazlumlar Hello what data from the device state are you looking for? You are able to use the permission and subscription observers to be updated when data on either of those objects change.
OneSignal.shared.getDeviceState().then((deviceState) async {
debugPrint("initOnesignalNormalPush DeviceState: ${deviceState?.jsonRepresentation()}");
String? playerId = deviceState?.userId;
}
This is from older sdk version. I also look for function similar this to get playerid. Is that for new sdk:
OneSignal.User.pushSubscription.id
if so, I got null value of id
@harrynguyen2510 Thank you for reaching out OneSignal.User.pushSubscription.id should not always return nil so it sounds like either something is going wrong with registering your device or something is going wrong retrieving the value in the SDK. Is the device able to receive push (does it show up in the dashboard)? If not then it is likely an issue registering and if so then it is an issue retrieving the value
Any update?
I also receiving null when i am calling.
OneSignal.User.pushSubscription.id
I am getting the value after some time. I also tried adding await but still it is not working .
This same issue was on OneSignal Cordova but there it is solved by deprecating OneSignal.User.pushSubscription.id and adding await OneSignal.User.pushSubscription.getIdAsync()
There issue number is #918.