Skip to content

Commit

Permalink
stop using deprecated firebase iid (#751)
Browse files Browse the repository at this point in the history
In order to solve #741 it seems we need to stop using firebase iid that is [deprecated](https://firebase.google.com/docs/reference/android/com/google/firebase/iid/package-summary). As part of it, I bumped the firebase-messaging version to 21.1.0

Co-authored-by: Yogev Ben David <yogev132@gmail.com>
  • Loading branch information
DanielEliraz and yogevbd authored Jun 23, 2021
1 parent 9a670a6 commit e214fd9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def DEFAULT_COMPILE_SDK_VERSION = 29
def DEFAULT_MIN_SDK_VERSION = 21
def DEFAULT_KOTLIN_VERSION = "1.3.61"
def DEFAULT_KOTLIN_STDLIB_VERSION = "kotlin-stdlib-jdk8"
def DEFAULT_FIREBASE_MESSAGING_VERSION = "20.2.0"
def DEFAULT_FIREBASE_MESSAGING_VERSION = "21.1.0"

def androidSdkVersion = safeExtGet('androidSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
def androidMinSdkVersion = safeExtGet('androidMinSdkVersion', DEFAULT_MIN_SDK_VERSION)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.modules.core.DeviceEventManagerModule;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.iid.InstanceIdResult;
import com.google.firebase.messaging.FirebaseMessaging;
import com.wix.reactnativenotifications.BuildConfig;
import com.wix.reactnativenotifications.core.JsIOHelper;

Expand Down Expand Up @@ -75,17 +72,19 @@ public void onAppReady() {
}

protected void refreshToken() {
FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener(new OnSuccessListener<InstanceIdResult>() {
@Override
public void onSuccess(InstanceIdResult instanceIdResult) {
sToken = instanceIdResult.getToken();
FirebaseMessaging.getInstance().getToken()
.addOnCompleteListener(task -> {
if (!task.isSuccessful()) {
if (BuildConfig.DEBUG) Log.w(LOGTAG, "Fetching FCM registration token failed", task.getException());
return;
}
sToken = task.getResult();
if (mAppContext instanceof IFcmTokenListenerApplication) {
((IFcmTokenListenerApplication) mAppContext).onNewFCMToken(sToken);
}
if (BuildConfig.DEBUG) Log.i(LOGTAG, "FCM has a new token" + "=" + sToken);
sendTokenToJS();
}
});
});
}

protected void sendTokenToJS() {
Expand Down

0 comments on commit e214fd9

Please sign in to comment.