Disable notifications
This is not an issue. I have been using this flutter plugin for 1 month. Everything is working well.
This is my initState code in my myhomepage.dart
@override
void initState() {
super.initState();
_fetchData(1);
_internetChecker();
OneSignal.shared.init("********************************************", iOSSettings: {
OSiOSSettings.autoPrompt: false,
OSiOSSettings.inAppLaunchUrl: true,
});
OneSignal.shared.setInFocusDisplayType(OSNotificationDisplayType.notification);
initDynamicLinks();
}
I want to add a feature to the app setting page where user can choose to enable or disable notifications within the app. I have a separate settings.dart page where I want to set the control to receive notifications. How can I do this?
Thanks
Check the setSubscription() method on OneSignal SDK documentations. You can simply disable notification using
await OneSignal.shared.setSubscription(false);
Thanks for answering @enricobenedos
@rgomezp is this the right behavior when setSubscription(false) and setSubscription(true) its will not receive the notification until you restart the app
Update:
Canceling or Resubscribing to Push Notifications has changed:
New methods:
await OneSignal.User.pushSubscription.optOut();
OR
await OneSignal.User.pushSubscription.optIn();
@reisvini thanks brother you saved my day :)
@reisvini
Thanks a lot.