Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: OneSignal Flutter: Permission Issue After App Restart #848

Closed
3 tasks done
burhanaksendir opened this issue Feb 26, 2024 · 1 comment
Closed
3 tasks done

Comments

@burhanaksendir
Copy link

burhanaksendir commented Feb 26, 2024

What happened?

After obtaining push notification permissions using OneSignal.Notifications.permission in my Flutter project, the initial value is true. However, upon completely closing and reopening the app, the OneSignal.Notifications.permission value returns false.

Steps to reproduce?

1- Initialize OneSignal in the initState method:

void initState() {
 OneSignal.initialize("your-app-id");
  super.initState();
}

2- Request push notification permissions using a method like the following:

Future<void> requestNotificationPermission() async {
  await OneSignal.Notifications.requestPermission(true);
  
  bool permissionGranted = getNotificationPermission();
}

3- Expect the initial permission value to be true after obtaining permissions.
4- Completely close the app and reopen it.
5- Check the OneSignal.Notifications.permission value, and observe that it is now false:

bool getNotificationPermission() {
  bool permissionGranted = OneSignal.Notifications.permission;
  debugPrint("Notification Permission: $permissionGranted");
  return permissionGranted;
}

What did you expect to happen?

I expected that after obtaining push notification permissions, the OneSignal.Notifications.permission value would remain true even after completely closing and reopening the app.

OneSignal Flutter SDK version

5.1.0

Which platform(s) are affected?

  • iOS
  • Android

Relevant log output

[OneSignalPlugin] Notification permission status: true

The initial log output indicates that the notification permission status is true after successfully obtaining push notification permissions. However, upon reopening the app, the log output shows:

[OneSignalPlugin] Notification permission status: false

This is unexpected as I anticipated the permission status to persist as true even after restarting the application.

Code of Conduct

  • I agree to follow this project's Code of Conduct
@jennantilla
Copy link
Contributor

Hello there--apologies that this issue was missed. If this is still a problem, can you please update to the latest SDK version and open a new issue with updated information? Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants