Closed tonny-tris closed 3 years ago
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.
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?