Skip to content

Commit

Permalink
Registered app for notifications
Browse files Browse the repository at this point in the history
Data messages when terminated will be supported soon.
Check flutter/plugins#1900
  • Loading branch information
Levi-Lesches committed Aug 13, 2019
1 parent a6598c4 commit 143d186
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions lib/services/fcm.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import 'package:firebase_messaging/firebase_messaging.dart';

// So basically, here's the gist with these things
// When the app is in the foreground, it's onMessage
// If not, then:
// if it's in the background:
// if it's a notification, it's onResume
// otherwise it's a data message and it'll be onMessage
// if it's terminated:
// if it's a notification: it's onLaunch
// otherwise it's a data message and it's onMessage

final FirebaseMessaging firebase = FirebaseMessaging();

Future<String> getToken() async => firebase.getToken();
Expand All @@ -10,7 +20,7 @@ Future<void> callback(Map<String, dynamic> message) async {
}

void registerNotifications() => firebase.configure(
onMessage: callback,
onResume: callback,
onMessage: callback,
onResume: callback,
onLaunch: callback
);
);

0 comments on commit 143d186

Please sign in to comment.