Skip to content

Commit

Permalink
Remove deprecated API (firebase-iid).
Browse files Browse the repository at this point in the history
  • Loading branch information
Dallas62 committed May 12, 2021
1 parent 84ca4d5 commit 66243dd
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@

import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.iid.InstanceIdResult;
import com.google.firebase.messaging.FirebaseMessaging;

public class RNPushNotification extends ReactContextBaseJavaModule implements ActivityEventListener {
Expand Down Expand Up @@ -139,17 +137,17 @@ public void checkPermissions(Promise promise) {
public void requestPermissions() {
final RNPushNotificationJsDelivery fMjsDelivery = mJsDelivery;

FirebaseInstanceId.getInstance().getInstanceId()
.addOnCompleteListener(new OnCompleteListener<InstanceIdResult>() {
FirebaseMessaging.getInstance().getToken()
.addOnCompleteListener(new OnCompleteListener<String>() {
@Override
public void onComplete(@NonNull Task<InstanceIdResult> task) {
public void onComplete(@NonNull Task<String> task) {
if (!task.isSuccessful()) {
Log.e(LOG_TAG, "exception", task.getException());
return;
}

WritableMap params = Arguments.createMap();
params.putString("deviceToken", task.getResult().getToken());
params.putString("deviceToken", task.getResult());
fMjsDelivery.sendEvent("remoteNotificationsRegistered", params);
}
});
Expand Down Expand Up @@ -282,17 +280,8 @@ public void removeDeliveredNotifications(ReadableArray identifiers) {
* Unregister for all remote notifications received
*/
public void abandonPermissions() {
new Thread(new Runnable() {
@Override
public void run() {
try {
FirebaseInstanceId.getInstance().deleteInstanceId();
Log.i(LOG_TAG, "InstanceID deleted");
} catch (IOException e) {
Log.e(LOG_TAG, "exception", e);
}
}
}).start();
FirebaseMessaging.getInstance().deleteToken();
Log.i(LOG_TAG, "InstanceID deleted");
}

@ReactMethod
Expand Down
2 changes: 1 addition & 1 deletion example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ DerivedData
build/
.idea
.gradle

local.properties
*.iml

Expand All @@ -39,7 +40,6 @@ yarn-error.log
buck-out/
\.buckd/
*.keystore
!debug.keystore

# fastlane
#
Expand Down
Binary file removed example/android/app/debug.keystore
Binary file not shown.
3 changes: 2 additions & 1 deletion example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
Expand Down

1 comment on commit 66243dd

@sheyko-d
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Please sign in to comment.