notifee icon indicating copy to clipboard operation
notifee copied to clipboard

Document Android 14 behavior changes for foreground services

Open davidliu opened this issue 1 year ago • 7 comments

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.

davidliu avatar Feb 23 '24 09:02 davidliu

Indeed - related is the new full screen intent item

mikehardy avatar Feb 23 '24 13:02 mikehardy

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" />

danisOktaxi avatar Feb 26 '24 21:02 danisOktaxi

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

liamjones avatar Feb 29 '24 08:02 liamjones

this is possibliiy solution

AftabUfaq avatar Mar 06 '24 08:03 AftabUfaq

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

MrShakes avatar Mar 19 '24 07:03 MrShakes

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.

santhoshvai avatar Apr 04 '24 10:04 santhoshvai

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[bot] avatar May 02 '24 10:05 github-actions[bot]

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)

pke avatar Jun 20 '24 21:06 pke

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>

Sathvik-Rao avatar Sep 10 '24 00:09 Sathvik-Rao