OneSignal / OneSignal-Flutter-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your flutter app with OneSignal
https://www.onesignal.com
Other
625 stars 215 forks source link

Undefined class 'OSDeviceState'.[question]: #778

Closed narayanan-ka closed 10 months ago

narayanan-ka commented 1 year ago

How can we help?

I migrated to onesignal_flutter: ^5.0.3 and I'm getting an error Undefined class 'OSDeviceState'.

Here is my code for the same :

Future<bool> isSubscribedToPushNotifications() async {
    OSDeviceState? osDeviceState = await OneSignal.shared.getDeviceState();

    return osDeviceState?.subscribed ?? false;
  }

Could you let me know how do I fix the above since I cant find the OSDeviceState anywhere in the new package of onesignal. Here is my question on stack overflow for the same issue for reference. https://stackoverflow.com/questions/77379712/onesignal-flutter-sdk-setup-undefined-class-osdevicestate

Code of Conduct

emawby commented 1 year ago

@narayanan-ka Here is our migration guide for the new major version. You can find additional information here.

getDeviceState is no longer a function in the SDK. If you would like to know if the subscription is subscribed you can use OneSignal.User.pushSubscription.optedIn or use an observer to be notified when it changes.

nan-li commented 10 months ago

Closing due to no response, please reach out if you have any additional questions or help needed!