Skip to content

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

@burhanaksendir

Description

@burhanaksendir

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions