Skip to content

stop using deprecated firebase iid #751

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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