-
Notifications
You must be signed in to change notification settings - Fork 52
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] FlutterBackground is not initialised after letting app run in background #56
Comments
Found Solution ? |
I can confirm it. On first run, |
This workaround works for me: // Workaround: initialize only works on second run of initialize
// The first initialize ensures, that the permission is set
// The second initialize ensures, that service is set up properly
return await FlutterBackground.initialize(androidConfig: androidConfig).then((value) async {
// value is false
if (!value && await FlutterBackground.hasPermissions) {
await FlutterBackground.initialize(androidConfig: androidConfig).then((value) async {
// value is true now
return value;
});
}
return value;
}); |
The same issue for me on Google Pixel 3A and Samsung Galaxy A13. |
@janoskranczler how did u resolve it finally? |
I couldn't resolve it. It still an issue for me either. |
@janoskranczler https://pub.dev/packages/background_fetch this lib solves perfectly! |
Thank you! I will take a look. |
This seemed to work for me, at least wrt to getting it to initialize without an error on first run. Can't speak to how well the background service itself works though. Tested on Android 13 (Pixel 4a) with release and debug builds.
|
Describe the bug
After run the FlutterBackground.initialize() command on the first app start, the application shows the "Let app always run in background?" dialog. If press "Allow", the FlutterBackground.initialize() returns false. FlutterBackground.enableBackgroundExecution() doesn't work after that. The bug is not reproduced on the second app run. In this case the dialog is not shown, and the FlutterBackground.initialize() returns true.
To Reproduce
Run the app at the first time and execute the FlutterBackground.initialize().
Expected behavior
FlutterBackground.initialize() returns "true" on press "Allow". FlutterBackground.enableBackgroundExecution() also works and returns "true".
Screenshots
Smartphone:
Code
flutter doctor -v
The text was updated successfully, but these errors were encountered: