notix 0.0.4
notix: ^0.0.4 copied to clipboard
Effortlessly manage notifications on Android and iOS with Notix with Firestore integration.
Notix #
Effortlessly manage and customize notifications on Android and iOS in your Flutter app with Notix.
Table of Contents #
Installation #
Add the following line to your pubspec.yaml file:
dependencies:
Notix: ^x.y.z
Replace x.y.z with the latest version of Notix from pub.dev.
Getting Started #
1. Initialize Notix #
Initialize Notix with your configuration, such as Firebase Cloud Messaging (FCM) settings and notification channels. This step is essential before using Notix in your app.
import 'package:Notix/Notix.dart';
void main() async {
await Notix.init(
configs: NotixConfig(
firebaseMessagingKey: 'YOUR_FCM_API_KEY',
icon: 'notification_icon',
// Add more configuration options here
),
);
}
2. Send Notifications #
Send notifications to your app users with ease. You can customize the content, channel, and behavior of each notification.
import 'package:Notix/Notix.dart';
void sendNotification() {
NotixMessage notification = NotixMessage(
title: 'New Message',
body: 'You have a new message.',
clientNotificationId: 'unique_id',
// Add more notification details here
);
Notix.push(notification);
}
3. Receive and Handle Notifications #
Handle incoming notifications and customize the behavior when a user interacts with them. You can listen to various notification events and take actions accordingly.
import 'package:Notix/Notix.dart';
void main() {
Notix.eventsStream.listen((event) {
if (event.type == EventType.notificationTap) {
// Handle notification tap event
} else if (event.type == EventType.receiveNotification) {
// Handle received notification
}
});
}
Advanced Usage #
Notification Channels #
Notix supports the creation and management of notification channels on Android. You can define channels with different behaviors, such as sound, vibration, or LED colors.
NotixChannel channel = NotixChannel(
id: 'channel_id',
name: 'Channel Name',
description: 'Channel Description',
playSound: true,
showBadge: true,
enableVibration: true,
enableLights: true,
ledColor: Colors.blue,
sound: 'custom_sound.mp3',
importance: Importance.high,
);
// Add the channel to the configuration
NotixConfig configs = NotixConfig(
channels: [channel],
// ...
);
Firebase Integration #
Notix seamlessly integrates with Firebase for cloud messaging. You can utilize Firebase services for better notification delivery and management.
// Initialize Firebase in your app
await Firebase.initializeApp();
// Initialize Notix with Firebase Cloud Messaging settings
await Notix.init(
configs: NotixConfig(
firebaseMessagingKey: 'YOUR_FCM_API_KEY',
// ...
),
);