diff --git a/gplay.gradle b/gplay.gradle
index 4182d5ce5c77..97d1c7d400b5 100644
--- a/gplay.gradle
+++ b/gplay.gradle
@@ -1,3 +1,3 @@
dependencies {
- implementation "com.google.firebase:firebase-messaging:17.3.0"
+ implementation "com.google.firebase:firebase-messaging:20.1.3"
}
diff --git a/scripts/analysis/lint-results.txt b/scripts/analysis/lint-results.txt
index 7fa79531c206..aefe63532610 100644
--- a/scripts/analysis/lint-results.txt
+++ b/scripts/analysis/lint-results.txt
@@ -1,2 +1,2 @@
DO NOT TOUCH; GENERATED BY DRONE
- Lint Report: 78 warnings
+ Lint Report: 77 warnings
diff --git a/src/gplay/AndroidManifest.xml b/src/gplay/AndroidManifest.xml
index 4334383cbc53..5392401c6c49 100644
--- a/src/gplay/AndroidManifest.xml
+++ b/src/gplay/AndroidManifest.xml
@@ -66,13 +66,6 @@
-
-
-
-
-
-
.
- */
-package com.owncloud.android.services.firebase;
-
-import android.text.TextUtils;
-
-import com.google.firebase.iid.FirebaseInstanceId;
-import com.google.firebase.iid.FirebaseInstanceIdService;
-import com.nextcloud.client.account.UserAccountManager;
-import com.nextcloud.client.preferences.AppPreferences;
-import com.owncloud.android.R;
-import com.owncloud.android.utils.PushUtils;
-
-import javax.inject.Inject;
-
-import dagger.android.AndroidInjection;
-
-public class NCFirebaseInstanceIDService extends FirebaseInstanceIdService {
-
-
- @Inject AppPreferences preferences;
- @Inject UserAccountManager accountManager;
-
- @Override
- public void onCreate() {
- super.onCreate();
- AndroidInjection.inject(this);
- }
-
- @Override
- public void onTokenRefresh() {
- //You can implement this method to store the token on your server
- if (!TextUtils.isEmpty(getResources().getString(R.string.push_server_url))) {
- preferences.setPushToken(FirebaseInstanceId.getInstance().getToken());
- PushUtils.pushRegistrationToServer(accountManager, preferences.getPushToken());
- }
- }
-}
diff --git a/src/gplay/java/com/owncloud/android/services/firebase/NCFirebaseMessagingService.java b/src/gplay/java/com/owncloud/android/services/firebase/NCFirebaseMessagingService.java
index c8c5a88c335c..d875c834cf9e 100644
--- a/src/gplay/java/com/owncloud/android/services/firebase/NCFirebaseMessagingService.java
+++ b/src/gplay/java/com/owncloud/android/services/firebase/NCFirebaseMessagingService.java
@@ -19,28 +19,56 @@
*/
package com.owncloud.android.services.firebase;
+import android.text.TextUtils;
+
import com.evernote.android.job.JobRequest;
import com.evernote.android.job.util.support.PersistableBundleCompat;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
+import com.nextcloud.client.account.UserAccountManager;
+import com.nextcloud.client.preferences.AppPreferences;
+import com.owncloud.android.R;
import com.owncloud.android.jobs.NotificationJob;
+import com.owncloud.android.utils.PushUtils;
+
+import javax.inject.Inject;
+
+import androidx.annotation.NonNull;
+import dagger.android.AndroidInjection;
public class NCFirebaseMessagingService extends FirebaseMessagingService {
+ @Inject AppPreferences preferences;
+ @Inject UserAccountManager accountManager;
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ AndroidInjection.inject(this);
+ }
@Override
- public void onMessageReceived(RemoteMessage remoteMessage) {
- if (remoteMessage != null && remoteMessage.getData() != null) {
- PersistableBundleCompat persistableBundleCompat = new PersistableBundleCompat();
- persistableBundleCompat.putString(NotificationJob.KEY_NOTIFICATION_SUBJECT, remoteMessage.getData().get
- (NotificationJob.KEY_NOTIFICATION_SUBJECT));
- persistableBundleCompat.putString(NotificationJob.KEY_NOTIFICATION_SIGNATURE, remoteMessage.getData().get
- (NotificationJob.KEY_NOTIFICATION_SIGNATURE));
- new JobRequest.Builder(NotificationJob.TAG)
- .addExtras(persistableBundleCompat)
- .setUpdateCurrent(false)
- .startNow()
- .build()
- .schedule();
+ public void onMessageReceived(@NonNull RemoteMessage remoteMessage) {
+ remoteMessage.getData();
+ PersistableBundleCompat persistableBundleCompat = new PersistableBundleCompat();
+ persistableBundleCompat.putString(NotificationJob.KEY_NOTIFICATION_SUBJECT, remoteMessage.getData().get
+ (NotificationJob.KEY_NOTIFICATION_SUBJECT));
+ persistableBundleCompat.putString(NotificationJob.KEY_NOTIFICATION_SIGNATURE, remoteMessage.getData().get
+ (NotificationJob.KEY_NOTIFICATION_SIGNATURE));
+ new JobRequest.Builder(NotificationJob.TAG)
+ .addExtras(persistableBundleCompat)
+ .setUpdateCurrent(false)
+ .startNow()
+ .build()
+ .schedule();
+ }
+
+ @Override
+ public void onNewToken(@NonNull String newToken) {
+ super.onNewToken(newToken);
+
+ if (!TextUtils.isEmpty(getResources().getString(R.string.push_server_url))) {
+ preferences.setPushToken(newToken);
+ PushUtils.pushRegistrationToServer(accountManager, preferences.getPushToken());
}
}
}