Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

Commit 66243dd

Browse files
committed
Remove deprecated API (firebase-iid).
1 parent 84ca4d5 commit 66243dd

File tree

4 files changed

+9
-19
lines changed

4 files changed

+9
-19
lines changed

android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotification.java

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636

3737
import com.google.android.gms.tasks.OnCompleteListener;
3838
import com.google.android.gms.tasks.Task;
39-
import com.google.firebase.iid.FirebaseInstanceId;
40-
import com.google.firebase.iid.InstanceIdResult;
4139
import com.google.firebase.messaging.FirebaseMessaging;
4240

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

142-
FirebaseInstanceId.getInstance().getInstanceId()
143-
.addOnCompleteListener(new OnCompleteListener<InstanceIdResult>() {
140+
FirebaseMessaging.getInstance().getToken()
141+
.addOnCompleteListener(new OnCompleteListener<String>() {
144142
@Override
145-
public void onComplete(@NonNull Task<InstanceIdResult> task) {
143+
public void onComplete(@NonNull Task<String> task) {
146144
if (!task.isSuccessful()) {
147145
Log.e(LOG_TAG, "exception", task.getException());
148146
return;
149147
}
150148

151149
WritableMap params = Arguments.createMap();
152-
params.putString("deviceToken", task.getResult().getToken());
150+
params.putString("deviceToken", task.getResult());
153151
fMjsDelivery.sendEvent("remoteNotificationsRegistered", params);
154152
}
155153
});
@@ -282,17 +280,8 @@ public void removeDeliveredNotifications(ReadableArray identifiers) {
282280
* Unregister for all remote notifications received
283281
*/
284282
public void abandonPermissions() {
285-
new Thread(new Runnable() {
286-
@Override
287-
public void run() {
288-
try {
289-
FirebaseInstanceId.getInstance().deleteInstanceId();
290-
Log.i(LOG_TAG, "InstanceID deleted");
291-
} catch (IOException e) {
292-
Log.e(LOG_TAG, "exception", e);
293-
}
294-
}
295-
}).start();
283+
FirebaseMessaging.getInstance().deleteToken();
284+
Log.i(LOG_TAG, "InstanceID deleted");
296285
}
297286

298287
@ReactMethod

example/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ DerivedData
2626
build/
2727
.idea
2828
.gradle
29+
2930
local.properties
3031
*.iml
3132

@@ -39,7 +40,6 @@ yarn-error.log
3940
buck-out/
4041
\.buckd/
4142
*.keystore
42-
!debug.keystore
4343

4444
# fastlane
4545
#

example/android/app/debug.keystore

-2.2 KB
Binary file not shown.

example/android/app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
android:icon="@mipmap/ic_launcher"
1414
android:roundIcon="@mipmap/ic_launcher_round"
1515
android:allowBackup="false"
16-
android:theme="@style/AppTheme">
16+
android:theme="@style/AppTheme"
17+
android:usesCleartextTraffic="true">
1718
<activity
1819
android:name=".MainActivity"
1920
android:label="@string/app_name"

0 commit comments

Comments
 (0)