Add Firebase messaging (Android-only, foreground-only)
This commit is contained in:
parent
203d375aa4
commit
f59d7118ed
9 changed files with 164 additions and 48 deletions
4
lib/env/dev.json
vendored
4
lib/env/dev.json
vendored
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"env": "DEV",
|
||||
"production": false,
|
||||
"apiUrl": "https://dev.localspend.co.uk/api"
|
||||
}
|
||||
"apiUrl": "https://localhost:/api"
|
||||
}
|
||||
|
|
|
@ -7,9 +7,12 @@ import 'package:local_spend/pages/spash_screen.dart';
|
|||
import 'package:local_spend/pages/more_page.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:local_spend/common/apifunctions/get_graph_data.dart';
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
|
||||
void main() {
|
||||
runApp(MyApp());
|
||||
runApp(
|
||||
MyApp()
|
||||
);
|
||||
}
|
||||
|
||||
void loadGraphs() {}
|
||||
|
@ -22,27 +25,43 @@ class GraphWithTitle {
|
|||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
final FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// TODO: load graphs on app login and send to graph widgets
|
||||
|
||||
return new MaterialApp(
|
||||
_firebaseMessaging.configure(
|
||||
onMessage: (Map<String, dynamic> message) async {
|
||||
print('onMessage: $message');
|
||||
},
|
||||
onLaunch: (Map<String, dynamic> message) async {
|
||||
print('onLaunch: $message');
|
||||
},
|
||||
onResume: (Map<String, dynamic> message) async {
|
||||
print('onResume: $message');
|
||||
},
|
||||
);
|
||||
|
||||
// Required on iOS; non-op on Android.
|
||||
_firebaseMessaging.requestNotificationPermissions();
|
||||
|
||||
return MaterialApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
localizationsDelegates: [
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: [Locale("en")],
|
||||
title: "Local Spend Tracker",
|
||||
theme: new ThemeData(
|
||||
supportedLocales: [Locale('en')],
|
||||
title: 'Local Spend Tracker',
|
||||
theme: ThemeData(
|
||||
primarySwatch: Colors.blueGrey,
|
||||
),
|
||||
routes: <String, WidgetBuilder>{
|
||||
"/HomePage": (BuildContext context) => HomePage(),
|
||||
"/LoginPage": (BuildContext context) => LoginPage(),
|
||||
'/HomePage': (BuildContext context) => HomePage(),
|
||||
'/LoginPage': (BuildContext context) => LoginPage(),
|
||||
'/MapPage': (BuildContext context) => MapPage(),
|
||||
"/ReceiptPage": (BuildContext context) => ReceiptPage2(),
|
||||
"/MorePage": (BuildContext context) => MorePage(),
|
||||
'/ReceiptPage': (BuildContext context) => ReceiptPage2(),
|
||||
'/MorePage': (BuildContext context) => MorePage(),
|
||||
},
|
||||
home: SplashScreen(),
|
||||
);
|
||||
|
|
Reference in a new issue