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

Document Android 14 behavior changes for foreground services #997

Closed
davidliu opened this issue Feb 23, 2024 · 9 comments · Fixed by #1050
Closed

Document Android 14 behavior changes for foreground services #997

davidliu opened this issue Feb 23, 2024 · 9 comments · Fixed by #1050

Comments

@davidliu
Copy link

https://developer.android.com/about/versions/14/changes/fgs-types-required#permission-for-fgs-type

Types are now required for Android 14, and their associated permissions need to be declared.

@mikehardy
Copy link
Collaborator

Indeed - related is the new full screen intent item

@danisOktaxi
Copy link

danisOktaxi commented Feb 26, 2024

notifee.displayNotification cause crash on Android 14 when passing prop android: {asForegroundService : true}

Update: Miss configuration in AndroidManifest cause this crash.

Declare service type on manifest to prevent the crash
<service android:name="app.notifee.core.ForegroundService" android:foregroundServiceType="location|camera|microphone" />

@liamjones
Copy link
Contributor

liamjones commented Feb 29, 2024

As well as the foreground service permission, from May 2024 apps targeting API level 34+ apparently need to handle the fullscreen intent permission differently?

For apps targeting Android U (API Level 34) and above, USE_FULL_SCREEN_INTENT is now a special app permission granted automatically only to apps whose core functionality requires a full screen notification.

From: https://developer.android.com/distribute/play-policies

@AftabUfaq
Copy link

this is possibliiy solution

@MrShakes
Copy link

For anyone with this issue while we wait for the docs to be updated, you need to first add this to your manifest as pointed out above
<service android:name="app.notifee.core.ForegroundService" android:foregroundServiceType="location|camera|microphone" />

Then add a further permission based on the foregroundServiceType chosen, for dataSync I had to add <uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
More info here:
https://developer.android.com/about/versions/14/changes/fgs-types-required

@santhoshvai
Copy link
Contributor

santhoshvai commented Apr 4, 2024

From the android docs

If the foreground service needs new permissions after you launch it, you should call startForeground() again and add the new service types. For example, suppose a fitness app runs a running-tracker service that always needs location information, but might or might not need media permissions. You would need to declare both location and mediaPlayback in the manifest. If a user starts a run and just wants their location tracked, your app should call startForeground() and pass just the location service type. Then, if the user wants to start playing audio, call startForeground() again and pass location|mediaPlayback.

We would actually need support to set foreground service types dynamically,

for example, sometimes location permission may have not been granted and we would still need to start the service

In my view, notifee.displayNotification should support specifying the type "location|camera|microphone" for example.

Copy link

github-actions bot commented May 2, 2024

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 17, 2024
@pke
Copy link

pke commented Jun 20, 2024

Indeed - related is the new full screen intent item

do we need this permission for notifee even? Play console only allows it for alarm apps (which ours clearly isn't but it schedules local notifications that need to be delivered with high timely accuracy)

@Sathvik-Rao
Copy link

AndroidManifest.xml

<manifest ...>
	<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC"/>

	<application 
	...
		<service 
        	android:name="app.notifee.core.ForegroundService" 
        	android:foregroundServiceType="dataSync"
         	/>
	</application>
</manifest>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants