simple_push_notification 0.4.3 copy "simple_push_notification: ^0.4.3" to clipboard
simple_push_notification: ^0.4.3 copied to clipboard

An extended package for handling firebase push notification service and notification navigation in a simple way.

A simple notification package for handling firebase notifications which supports notification navigations.

Features #

  • Display push notification
  • activate and deactivate the push notification service
  • navigate to desired screen, view or page after tapping to push notification popup

Getting started #

This package uses firebase push notifications and to use this package, firebase app should be configured properly in your flutter app. Recommended way to setup firebase app is using Flutterfire. Follow this doc

In the pubspec.yaml of your flutter project, add the following dependency:

    dependencies:
        simple_push_notification: latest_version_number

import it:

    import 'package:simple_push_notification/simple_push_notification.dart';

Android #

After configuring firebase, you will see firebase_options.dart created in your lib folder. All you need to do is start a firebase app and use SimplePushNotification class.

void main(){
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(
    name: NAME_OF_YOUR_FIREBASE_APP,
    options: DefaultFirebaseOptions.currentPlatform,
  );
  runApp(App());
}

After the initialization, use SimplePushNotification class anyway you desire.

Usage #

    final pushNotification = SimplePushNotification.initialize(
    navigatorKey: () => navigatorKey,
    getNotificationPayload: (map) => SimplePayload(),
    config: NotificationConfig(
        appIcon: 'ic_launcher',
        notificationChannelDescription: 'this is a test description',
        notificationChannelId: 'testId',
        notificationChannelName: 'Test name'),
  );

  await pushNotification.activate(
    onActivated: (token) {
      log('Notification activated!!!! token: $token');
    },
    onRead: (payload) {
      log(payload.toString());
    },
  );

here, navigatorKey must be provided same as in MaterialApp's navigatorKey or a class that implements NotificationNavigation.

Information #

Please feel free to create PR if you want to contributte.

3
likes
130
pub points
61%
popularity

Publisher

unverified uploader

An extended package for handling firebase push notification service and notification navigation in a simple way.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

firebase_core, firebase_messaging, flutter, flutter_local_notifications

More

Packages that depend on simple_push_notification