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

FlutterForegroundTask.launchApp(); Not working #301

Open
OsamaQureshi796 opened this issue Nov 27, 2024 · 3 comments
Open

FlutterForegroundTask.launchApp(); Not working #301

OsamaQureshi796 opened this issue Nov 27, 2024 · 3 comments

Comments

@OsamaQureshi796
Copy link

Hi,

I hope this finds you well.

I'm using FlutterForegroundTask to launch the app when it is background when some even is happen in my app.

But it is not working anymore to bring app from background to foreground.

FlutterForegroundTask.launchApp();

i checked logcat and also i searched for crashlytics but there is no crash around this problem.

Does anyone explain whats the problem.

Thanks

@jaypokar
Copy link

jaypokar commented Nov 28, 2024

I am getting same issue.
it works upto android OS version 12 or 13, but when running over android OS 14 after allowing Display Over the Apps permission it works perfectly ,
I am trying to understand do we need special permission for this or what ?

@Dev-hwang
Copy link
Owner

Dev-hwang commented Nov 28, 2024

Sorry for the late response. @OsamaQureshi796 @jaypokar

Due to restrictions on starting activities in the background on the Android platform, you must declare and grant the SYSTEM_ALERT_WINDOW permission to use the FlutterForegroundTask.launchApp function.

You can request the permission as follows:

<manifest>
    <!-- for utils -->
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<manifest>
if (Platform.isAndroid) {
   // The `launchApp` function requires the `android.permission.SYSTEM_ALERT_WINDOW` permission and 
   // requires using the `openSystemAlertWindowSettings()` function to grant the permission.
   if (!await FlutterForegroundTask.canDrawOverlays) {
     await FlutterForegroundTask.openSystemAlertWindowSettings();
   }
}

The example app contains an explanation for this, but it was missing in the documentation. I will add this explanation to the documentation.

@OsamaQureshi796
Copy link
Author

Hi @Dev-hwang ,

Thanks for the explanation but there is a problem, i was using this plugin for a specific case like if some android device don't have display over the other apps feature so in that case i was launching app when some event is triggered suppose i got trip request. In case of the devices that have display over the other apps there is my bubble chat head just like other apps.

Because it was working till now i don't know what happened and it stoped working.

Thanks

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

3 participants