Add messaging
This commit is contained in:
parent
345b54bec3
commit
4fecc291a4
9 changed files with 81 additions and 5 deletions
19
lib/firebaseMessagingConf.dart
Normal file
19
lib/firebaseMessagingConf.dart
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
|
||||
final FirebaseMessaging _firebaseMessaging = new FirebaseMessaging();
|
||||
|
||||
// https://pub.dartlang.org/packages/firebase_messaging#-example-tab-
|
||||
void firebaseConfig() {
|
||||
_firebaseMessaging.configure(
|
||||
onLaunch: (Map<String, dynamic> message) {
|
||||
print('On firebase launch');
|
||||
},
|
||||
onMessage: (Map<String, dynamic> message) {
|
||||
print('On firebase message');
|
||||
},
|
||||
onResume: (Map<String, dynamic> message) {
|
||||
print('On firebase resume');
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
|
@ -16,7 +16,8 @@ import 'dummyMapPlugin.dart';
|
|||
import 'fireMarkType.dart';
|
||||
import 'slider.dart';
|
||||
import 'package:just_debounce_it/just_debounce_it.dart';
|
||||
import 'package:padder/padding.dart';
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
|
||||
|
||||
enum MapOperation { view, subscriptionConfirm, unsubscribe }
|
||||
|
||||
|
|
@ -37,6 +38,8 @@ class GenericMap extends StatefulWidget {
|
|||
|
||||
class _GenericMapState extends State<GenericMap> {
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
||||
final FirebaseMessaging _firebaseMessaging = new FirebaseMessaging();
|
||||
|
||||
|
||||
final BasicLocation location;
|
||||
final String title;
|
||||
|
|
@ -145,6 +148,8 @@ class _GenericMapState extends State<GenericMap> {
|
|||
operation = MapOperation.subscriptionConfirm;
|
||||
break;
|
||||
case MapOperation.subscriptionConfirm:
|
||||
// IOS specific
|
||||
_firebaseMessaging.requestNotificationPermissions();
|
||||
operation = MapOperation.unsubscribe;
|
||||
break;
|
||||
case MapOperation.unsubscribe:
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import 'package:comunes_flutter/comunes_flutter.dart';
|
|||
import 'dart:async';
|
||||
import 'globals.dart' as globals;
|
||||
import 'basicLocationPersist.dart';
|
||||
import 'firebaseMessagingConf.dart';
|
||||
|
||||
Future<Map<String, dynamic>> loadSecrets() async {
|
||||
return await SecretLoader(secretPath: 'assets/private-settings.json').load();
|
||||
|
|
@ -17,6 +18,7 @@ void main() {
|
|||
globals.firesApiUrl = secrets['firesApiUrl'];
|
||||
globals.prefs.then((prefs) {
|
||||
loadYourLocationsWithPrefs(prefs);
|
||||
firebaseConfig();
|
||||
|
||||
// Run baby run!
|
||||
runApp(new FiresApp());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue