Skip to content

Commit 3e4dcc5

Browse files
README.md updates
1 parent 2d0c1ce commit 3e4dcc5

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

flutter_local_notifications/README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ Note: the plugin requires Flutter SDK 3.22 at a minimum. The list of support pla
9999
* [Android] Retrieve the list of active notifications
100100
* [Android] Full-screen intent notifications
101101
* [Android] Start a foreground service
102+
* [Android] Android Auto notification support (requires CarAppService integration—see Android setup section)
102103
* [Android] Ability to check if notifications are enabled
103104
* [iOS (all supported versions) & macOS 10.14+] Request notification permissions and customise the permissions being requested around displaying notifications
104105
* [iOS 10 or newer and macOS 10.14 or newer] Display notifications with attachments
@@ -351,6 +352,52 @@ android {
351352

352353
</details>
353354

355+
#### 🚗 Supporting Android Auto Notifications
356+
357+
The plugin supports delivering notifications to Android Auto displays via the `showOnAndroidAuto` option. If you intend to use this feature, there is additional setup required within your Android application.
358+
359+
**CarAppService Implementation**
360+
If your app supports Android Auto, your app must already define a class inheriting from [`androidx.car.app.CarAppService`](https://developer.android.com/reference/androidx/car/app/CarAppService).
361+
362+
**What you need to do:**
363+
364+
- **Let the `flutter_local_notifications` know about your service:**
365+
`flutter_local_notifications` cannot provide this class itself, it must be supplied by you. To let the plugin access your `CarAppService`, make your `MainActivity` implement the `CarAppServiceClassConsumer` interface and return your service’s class from the required method.
366+
367+
**Example (in `MainActivity.java`):**
368+
```java
369+
public class MainActivity extends FlutterActivity implements CarAppServiceClassConsumer {
370+
@Override
371+
public Class<? extends CarAppService> getCarAppServiceClass() {
372+
return MyCarAppService.class; // Replace with your actual CarAppService class
373+
}
374+
}
375+
```
376+
377+
**Kotlin Example (in `MainActivity.kt`):**
378+
```kotlin
379+
class MainActivity : FlutterActivity(), CarAppServiceClassConsumer {
380+
override fun getCarAppServiceClass(): Class<out CarAppService>? {
381+
return MyCarAppService::class.java // Replace with your actual CarAppService class
382+
}
383+
}
384+
```
385+
386+
- **When is this required?**
387+
Only when enabling Android Auto support for notifications via the `showOnAndroidAuto` option. For standard notifications, no action is required.
388+
389+
- **How does this work?**
390+
When creating a notification for Android Auto, the `flutter_local_notifications` will:
391+
- Check if your activity implements `CarAppServiceClassConsumer`.
392+
- If so, call `getCarAppServiceClass()` to get your service class.
393+
- Build an intent that targets this class so notifications can be properly handled by Android Auto via `CarAppExtender` and `CarPendingIntent`.
394+
395+
For more details, see the [CarAppServiceClassConsumer interface](android/src/main/java/com/dexterous/flutterlocalnotifications/interfaces/CarAppServiceClassConsumer.java).
396+
397+
_Tip: If you do not require Android Auto support, you do not need to implement this interface._
398+
399+
_Tip: Before adding Android Auto notifications to your app you should review the [Car App Quality](https://developer.android.com/docs/quality-guidelines/car-app-quality) guidelines for your [App Category](https://developer.android.com/training/cars#supported-app-categories)._
400+
354401
### AndroidManifest.xml setup
355402

356403
Previously the plugin would specify all the permissions required all of the features that the plugin support in its own `AndroidManifest.xml` file so that developers wouldn't need to do this in their own app's `AndroidManifest.xml` file. Since version 16 onwards, the plugin will now only specify the bare minimum and these [`POST_NOTIFICATIONS`](https://developer.android.com/reference/android/Manifest.permission#POST_NOTIFICATIONS) and [`VIBRATE`](https://developer.android.com/reference/android/Manifest.permission#VIBRATE) permissions.

0 commit comments

Comments
 (0)