fcm_eraser_plus 1.1.3
fcm_eraser_plus: ^1.1.3 copied to clipboard
The plugin has been upgraded and extended with additional features for working with FCM
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. #
🔧 Installation #
Add the library to pubspec.yaml:
dependencies:
fcm_eraser_plus: latest_version
Then, run:
flutter pub get
✨ Supported Features #
| 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. |
📌 Usage Guide #
1️⃣ Clear All Notifications #
import 'package:fcm_eraser_plus/fcm_eraser_plus.dart';
Future<void> clearAll() async {
await FcmEraserPlus.instance.clearAllNotifications();
}
2️⃣ Clear Notification by TAGS #
Future<void> clearByTags({required List<String> tags}) async {
await FcmEraserPlus.instance.clearByTags(tags: tags);
}
3️⃣ Set Badge Count on iOS #
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);
}
4️⃣ Get Active Tag Notifications #
Future<void> getActiveTags() async {
final activeTags = await FcmEraserPlus.instance.getActiveTags();
log('Active tags:\n$activeTags');
}
📡 Sending FCM Messages #
Easily send Firebase Cloud Messages (FCM) to your app using the steps below:
📥 Step 1: Setup Firebase Admin SDK #
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),
});
🔑 Step 2: Get Your Device Token #
Run your Flutter app (flutter run) and copy the device token printed in the console:
const token = 'YOUR_FCM_TOKEN';
📦 Step 3: Install Dependencies #
Navigate to the example/lib/fcm_admin directory and install the required Node.js dependencies:
npm install
🚀 Step 4: Send a Test Notification #
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.
📜 License #
This library is released under the MIT license. You can view the full license text here.