Skip to content
This repository has been archived by the owner on Oct 19, 2022. It is now read-only.

Commit

Permalink
Update Android components and try push workarounds #501 OT-779
Browse files Browse the repository at this point in the history
Fixed MethodChannels.java typo
Updated gradle
Update libs
Added more push callback for debugging
  • Loading branch information
Boehrsi committed Apr 29, 2020
1 parent 8ddc632 commit 773c525
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 10 deletions.
6 changes: 3 additions & 3 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ flutter {
}

dependencies {
implementation 'com.google.crypto.tink:apps-webpush:1.3.0-rc1'
implementation 'com.google.firebase:firebase-core:17.2.1'
implementation 'com.google.crypto.tink:apps-webpush:1.3.0'
implementation 'com.google.firebase:firebase-messaging:20.1.6'
implementation 'org.bouncycastle:bcprov-jdk16:1.46'

testImplementation 'junit:junit:4.12'
testImplementation 'junit:junit:4.13'

androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
Expand Down
5 changes: 3 additions & 2 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@
<uses-permission android:name="android.permission.VIBRATE" />

<application
android:name=".MainApplication" <!-- TODO this entry is a temporary hack to be able to try stuff with the FirebaseMessagingPlugin - See https://github.com/FirebaseExtended/flutterfire/issues/1754 for more information -->
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
tools:replace="android:label">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:windowSoftInputMode="adjustResize">
<!-- Specify that the launch screen should continue being displayed until Flutter renders its first frame. -->
<meta-data
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.openxchange.oxcoi;


import io.flutter.app.FlutterApplication;
import io.flutter.plugin.common.PluginRegistry;
import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback;
import io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin;
import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService;

// TODO this whole class is a temporary hack to be able to try stuff with the FirebaseMessagingPlugin - See https://github.com/FirebaseExtended/flutterfire/issues/1754 for more information
public class MainApplication extends FlutterApplication implements PluginRegistrantCallback {
@Override
public void onCreate() {
super.onCreate();
FlutterFirebaseMessagingService.setPluginRegistrant(this);
}

@Override
public void registerWith(PluginRegistry registry) {
FirebaseMessagingPlugin.registerWith(registry.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ abstract static class Security {
static final String NAME = "oxcoi.security";

abstract static class Methods {
static final String DECRYPT = "'decrypt'";
static final String DECRYPT = "decrypt";
}

abstract static class Arguments {
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.android.tools.build:gradle:3.6.3'
classpath 'com.google.gms:google-services:4.3.3'
}
}
Expand Down
4 changes: 2 additions & 2 deletions android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Thu Nov 28 13:37:47 CET 2019
#Wed Apr 29 13:11:03 CEST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
12 changes: 11 additions & 1 deletion lib/src/push/push_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,17 @@ import 'package:ox_coi/src/push/push_bloc.dart';
import 'package:ox_coi/src/push/push_event_state.dart';
import 'package:ox_coi/src/security/security_manager.dart';

final _logger = Logger("push_manager");

Future<void> onBackgroundMessage(Map<String, dynamic> message) {
//TODO: Add functionality
_logger.info("onBackgroundMessage $message");
return Future(null);
}

class PushManager {
final _firebaseMessaging = FirebaseMessaging();
final _notificationManager = DisplayNotificationManager();
final _logger = Logger("push_manager");

BuildContext _buildContext;
PushBloc _pushBloc;
Expand All @@ -83,11 +90,13 @@ class PushManager {
final decryptedContent = await decryptAsync(notificationData.content);
if (_isValidationPush(decryptedContent)) {
final validation = _getPushValidation(decryptedContent).validation;
_logger.info("Validation message with state validation: $validation received");
_pushBloc.add(ValidateMetadata(validation: validation));
} else {
final pushChatMessage = _getPushChatMessage(decryptedContent);
final fromEmail = pushChatMessage.fromEmail;
final body = "I sent you a new chat message"; // TODO replace decrypt
_logger.info("Chat message received from: $fromEmail");
await _notificationManager.showNotificationFromPushAsync(fromEmail, body);
}
}
Expand All @@ -103,6 +112,7 @@ class PushManager {
_logger.info("onLaunch $message");
return Future(null);
},
onBackgroundMessage: onBackgroundMessage,
);
_firebaseMessaging.requestNotificationPermissions(const IosNotificationSettings(sound: true, badge: true, alert: true));
}
Expand Down

0 comments on commit 773c525

Please sign in to comment.