Add messaging
This commit is contained in:
parent
345b54bec3
commit
4fecc291a4
9 changed files with 81 additions and 5 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -22,3 +22,4 @@ doc/api/
|
|||
|
||||
assets/private-settings.json
|
||||
android/app/src/main/AndroidManifest.xml
|
||||
android/app/google-services.json
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
45
android/app/google-services.json-sample
Normal file
45
android/app/google-services.json-sample
Normal file
|
|
@ -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"
|
||||
}
|
||||
|
|
@ -18,8 +18,6 @@
|
|||
android:name="io.flutter.app.FlutterApplication"
|
||||
android:label="All Against The Fire!"
|
||||
android:icon="@mipmap/launch_image">
|
||||
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="PUT_YOUR_API_HERE"/>
|
||||
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/>
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:launchMode="singleTop"
|
||||
|
|
@ -37,9 +35,9 @@
|
|||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
<action android:name="FLUTTER_NOTIFICATION_CLICK" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name="com.apptreesoftware.mapview.MapActivity"
|
||||
android:theme="@style/Theme.AppCompat.Light.DarkActionBar"/>
|
||||
</application>
|
||||
</manifest>
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ buildscript {
|
|||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.0.1'
|
||||
classpath 'com.google.gms:google-services:4.0.0'
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
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());
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue