diff --git a/.gitignore b/.gitignore index dca3b69..1e7ac68 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ doc/api/ assets/private-settings.json android/app/src/main/AndroidManifest.xml +android/app/google-services.json diff --git a/android/app/build.gradle b/android/app/build.gradle index e5c5cb9..dd502fb 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -48,4 +48,8 @@ dependencies { testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.1' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' + compile 'com.google.firebase:firebase-core:15.0.2' + // google recommends 16 but fails because location flutter package deps in 15 } + +apply plugin: 'com.google.gms.google-services' \ No newline at end of file diff --git a/android/app/google-services.json-sample b/android/app/google-services.json-sample new file mode 100644 index 0000000..97375ca --- /dev/null +++ b/android/app/google-services.json-sample @@ -0,0 +1,45 @@ +{ + "project_info": { + "project_number": "", + "firebase_url": "", + "project_id": "", + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "", + "android_client_info": { + "package_name": "", + } + }, + "oauth_client": [ + { + "client_id": "", + "client_type": 3 + }, + { + "client_id": "", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "", + } + ], + "services": { + "analytics_service": { + "status": 1 + }, + "appinvite_service": { + "status": 1, + "other_platform_oauth_client": [] + }, + "ads_service": { + "status": 2 + } + } + } + ], + "configuration_version": "1" +} diff --git a/android/app/src/main/AndroidManifest-Sample.xml b/android/app/src/main/AndroidManifest-Sample.xml index 202578e..9db35fe 100644 --- a/android/app/src/main/AndroidManifest-Sample.xml +++ b/android/app/src/main/AndroidManifest-Sample.xml @@ -18,8 +18,6 @@ android:name="io.flutter.app.FlutterApplication" android:label="All Against The Fire!" android:icon="@mipmap/launch_image"> - - + + - diff --git a/android/build.gradle b/android/build.gradle index 4476887..2a0d93d 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -6,6 +6,7 @@ buildscript { dependencies { classpath 'com.android.tools.build:gradle:3.0.1' + classpath 'com.google.gms:google-services:4.0.0' } } diff --git a/lib/firebaseMessagingConf.dart b/lib/firebaseMessagingConf.dart new file mode 100644 index 0000000..2bfa60b --- /dev/null +++ b/lib/firebaseMessagingConf.dart @@ -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 message) { + print('On firebase launch'); + }, + onMessage: (Map message) { + print('On firebase message'); + }, + onResume: (Map message) { + print('On firebase resume'); + } + ); + +} \ No newline at end of file diff --git a/lib/genericMap.dart b/lib/genericMap.dart index e8da53f..51ac0a4 100644 --- a/lib/genericMap.dart +++ b/lib/genericMap.dart @@ -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 { final GlobalKey _scaffoldKey = new GlobalKey(); + final FirebaseMessaging _firebaseMessaging = new FirebaseMessaging(); + final BasicLocation location; final String title; @@ -145,6 +148,8 @@ class _GenericMapState extends State { operation = MapOperation.subscriptionConfirm; break; case MapOperation.subscriptionConfirm: + // IOS specific + _firebaseMessaging.requestNotificationPermissions(); operation = MapOperation.unsubscribe; break; case MapOperation.unsubscribe: diff --git a/lib/main.dart b/lib/main.dart index edab90a..8d72660 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -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> 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()); diff --git a/pubspec.yaml b/pubspec.yaml index ff89a1d..4d8e27a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -25,6 +25,7 @@ dependencies: geocoder: "^0.0.1" just_debounce_it: "^1.0.4" flutter_fab_dialer: "^0.0.5" + firebase_messaging: "^1.0.2" dev_dependencies: flutter_test: