More powerful when working with FCM.
The plugin has been upgraded and extended with additional features for working with FCM (Firebase Cloud Messaging). It supports deleting all notifications or specific ones using TAGs and setting the badge count on iOS.
Add the library to pubspec.yaml
:
dependencies:
fcm_eraser_plus: latest_version
Then, run:
flutter pub get
Feature | Android | iOS | Description |
---|---|---|---|
Clear all notifications | ✅ | ✅ | Removes all active notifications from the system tray. |
Clear notification by TAGS | ✅ | ✅ | Delete multiple notifications using a list of their tag identifiers. |
Set badge count | ❌ | ✅ | Sets the badge number on the app icon for iOS. |
Get active tag notifications | ✅ | ✅ | Get the list of tags for active notifications. |
import 'package:fcm_eraser_plus/fcm_eraser_plus.dart';
Future<void> clearAll() async {
await FcmEraserPlus.instance.clearAllNotifications();
}
Future<void> clearByTags({required List<String> tags}) async {
await FcmEraserPlus.instance.clearByTags(tags: tags);
}
Set isClear = true to delete all active notifications simultaneously. Set it to false to skip.
Future<void> setBadge({required int count, bool isClear = true}) async {
await FcmEraserPlus.instance.setBadge(count: count, isClear: isClear);
}
Future<void> getActiveTags() async {
final activeTags = await FcmEraserPlus.instance.getActiveTags();
log('Active tags:\n$activeTags');
}
Easily send Firebase Cloud Messages (FCM) to your app using the steps below:
Download a service account key (JSON file) from your Firebase console and place it inside the example/lib/fcm_admin
directory.
var serviceAccount = require('./service-acc.json');
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
});
Run your Flutter app (flutter run
) and copy the device token printed in the console:
const token = 'YOUR_FCM_TOKEN';
Navigate to the example/lib/fcm_admin
directory and install the required Node.js dependencies:
npm install
Run the following command from the example/scripts
directory to send a message to your app:
npm run send-message
Your app will receive messages in all states: background, or terminated.
Note: If messages stop arriving, the platform may be throttling them. iOS, in particular, has strict throttling policies.
This library is released under the MIT license. You can view the full license text here.