notification_reactor 0.0.3+1 copy "notification_reactor: ^0.0.3+1" to clipboard
notification_reactor: ^0.0.3+1 copied to clipboard

For DIY engineers! Define your own reaction by Push Notification (via APNs (iOS) / FirebaseCloudMessaging (Android)).

example/lib/main.dart

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:notification_reactor/notification_reactor.dart';

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

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

class _MyAppState extends State<MyApp> {
  String _route;
  Map<String, dynamic> _data;

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    NotificationReactor().setHandlers(
      onLaunch: (message) {
        _route = "onLaunch";
        _data = message;
      },
      onResume: (message) {
        _route = "onResume";
        _data = message;
      },
      onMessage: (message) {
        _route = "onMessage";
        _data = message;
      },
    );
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Text(
              '${(_route != null) ? _route : "no push"}\n${(_data != null) ? _data : "no data"}'),
        ),
      ),
    );
  }
}
3
likes
40
pub points
15%
popularity

Publisher

unverified uploader

For DIY engineers! Define your own reaction by Push Notification (via APNs (iOS) / FirebaseCloudMessaging (Android)).

Repository (GitHub)
View/report issues

License

BSD-3-Clause (LICENSE)

Dependencies

flutter, meta

More

Packages that depend on notification_reactor