handle_firebase_notification 1.0.0 copy "handle_firebase_notification: ^1.0.0" to clipboard
handle_firebase_notification: ^1.0.0 copied to clipboard

outdated

A flutter plugin to handle firebase notification when app is in Background or Foreground.

example/lib/main.dart

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:handle_firebase_notification/handle_firebase_notification.dart';
import 'package:handle_firebase_notification/mixin_firebase_notification_state.dart';
import 'package:handle_firebase_notification_example/second_screen.dart';

import 'first_screen.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> with FirebaseNotificationStateMixin {
  Future<void> initialState() async {
    try {
      await HandleFirebaseNotification.instance.setAction('ACTION');
    } catch (error) {
      print(error.toString());
    }
  }

  @override
  void initState() {
    super.initState();
    initialState();
  }

  @override
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      navigatorObservers: [HandleFirebaseNotification.routeObserver],
      initialRoute: '/',
      routes: <String, WidgetBuilder>{
        "/": (BuildContext context) => FirstScreen(),
        "/second": (BuildContext context) => SecondScreen()
      },
      //navigatorObservers: [routeObserver],
    );
  }

  @override
  void onOpenFromNotification(data) {
    print('Main Screen ' + data.toString());
  }
}
3
likes
0
pub points
0%
popularity

Publisher

unverified uploader

A flutter plugin to handle firebase notification when app is in Background or Foreground.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on handle_firebase_notification