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

Permission of calling initialize() #32

Closed
tonny-tris opened this issue Jun 17, 2021 · 1 comment
Closed

Permission of calling initialize() #32

tonny-tris opened this issue Jun 17, 2021 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@tonny-tris
Copy link

could you tell me how to ignore permission of calling initialize? because after launch app at first time after installed it, it's normal to call initialize() and take permission, but when I launch app after many times, initialize() took any permission again, and it's very annoying. I tried to call .hasPermission and it take 'false' even before I have taken permission granted to yes.
Could you tell me how to skip permission 'again' after we launch app?

@tonny-tris tonny-tris added the bug Something isn't working label Jun 17, 2021
@JulianAssmann
Copy link
Owner

The example app uses the following code:

final config = FlutterBackgroundAndroidConfig(
    notificationTitle: 'flutter_background example app',
    notificationText: 'Background notification for keeping the example app running in the background',
    notificationIcon: AndroidResource(name: 'background_icon'),
    notificationImportance: AndroidNotificationImportance.Low,
);
bool hasPermissions = await FlutterBackground.initialize(androidConfig: config);

This will ask the user for permission the first time, but when the permission is already granted, the message will not be displayed a second time.

Optionally you can check whether or not the plugin already has the permission by calling

bool hasPermissions = await FlutterBackground.hasPermissions;

before calling initialize(...). That way you can inform the user of the upcoming permission granting dialog and maybe explain, why you need the permission etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant