From 390aa83370bcd4bac1a184f423e75b11809ec183 Mon Sep 17 00:00:00 2001 From: Boehrsi Date: Wed, 29 Apr 2020 15:19:15 +0200 Subject: [PATCH] Update Android components and try push workarounds #501 OT-779 Fixed MethodChannels.java typo Updated gradle Update libs Added more push callback for debugging --- android/app/build.gradle | 6 +- android/app/src/main/AndroidManifest.xml | 6 +- .../openxchange/oxcoi/MainApplication.java | 63 +++++++++++++++++++ .../com/openxchange/oxcoi/MethodChannels.java | 45 ++++++++++++- android/build.gradle | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 4 +- lib/src/push/push_manager.dart | 12 +++- 7 files changed, 127 insertions(+), 11 deletions(-) create mode 100644 android/app/src/main/java/com/openxchange/oxcoi/MainApplication.java diff --git a/android/app/build.gradle b/android/app/build.gradle index 7aef609b..3727217d 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -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' diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 674c37b7..74b4b424 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -15,16 +15,18 @@ + onBackgroundMessage(Map 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; @@ -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); } } @@ -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)); }