Skip to content

Commit 132288a

Browse files
Googlera-maurice
authored andcommitted
Remove deprecated FirebaseInstanceIdService
This replaces the deprecated usage with FirebaseMessagingService#onNewToken PiperOrigin-RevId: 242530618
1 parent dbe0be8 commit 132288a

File tree

5 files changed

+9
-52
lines changed

5 files changed

+9
-52
lines changed

messaging/AndroidManifest.xml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,6 @@
2121
</intent-filter>
2222
</service>
2323

24-
<service android:name="com.google.firebase.messaging.cpp.FcmInstanceIDListenerService"
25-
android:exported="false" >
26-
<intent-filter>
27-
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
28-
</intent-filter>
29-
</service>
30-
3124
<service android:name="com.google.firebase.messaging.cpp.RegistrationIntentService"
3225
android:exported="false" >
3326
</service>

messaging/messaging_additional.pro

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Additional Proguard rules for Messaging.
22
-keep,includedescriptorclasses public class com.google.android.gms.messaging.cpp.DebugLogging { *; }
3-
-keep,includedescriptorclasses public class com.google.android.gms.messaging.cpp.FcmInstanceIDListenerService { *; }
43
-keep,includedescriptorclasses public class com.google.android.gms.messaging.cpp.ListenerService { *; }
54
-keep,includedescriptorclasses public class com.google.android.gms.messaging.cpp.RegistrationIntentService { *; }

messaging/src/android/java/com/google/firebase/messaging/cpp/FcmInstanceIDListenerService.java

Lines changed: 0 additions & 36 deletions
This file was deleted.

messaging/src/android/java/com/google/firebase/messaging/cpp/ListenerService.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,10 @@ public void onSendError(String messageId, Exception exception) {
6767
messageWriter.writeMessageEventToInternalStorage(
6868
this, messageId, MESSAGE_TYPE_SEND_ERROR, exception.toString());
6969
}
70+
71+
@Override
72+
public void onNewToken(String token) {
73+
DebugLogging.log(TAG, String.format("onNewToken token=%s", token));
74+
RegistrationIntentService.writeTokenToInternalStorage(this, token);
75+
}
7076
}

messaging/src/android/java/com/google/firebase/messaging/cpp/RegistrationIntentService.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,15 @@ public RegistrationIntentService() {
4040
// Fetch the latest registration token and notify the C++ layer.
4141
@Override
4242
protected void onHandleIntent(Intent intent) {
43-
refreshToken(this);
44-
}
45-
46-
// Get the current instance ID token and send it to the C++ layer.
47-
// This is public so that it can be called by FcmInstanceIDListenerService.
48-
public static void refreshToken(Context context) {
4943
String token = FirebaseInstanceId.getInstance().getToken();
5044
DebugLogging.log(TAG, String.format("onHandleIntent token=%s", token));
5145
if (token != null) {
52-
writeTokenToInternalStorage(context, token);
46+
writeTokenToInternalStorage(this, token);
5347
}
5448
}
5549

56-
private static void writeTokenToInternalStorage(Context context, String token) {
50+
/** Write token to internal storage so it can be accessed by the C++ layer. */
51+
public static void writeTokenToInternalStorage(Context context, String token) {
5752
byte[] buffer = generateTokenByteBuffer(token);
5853
ByteBuffer sizeBuffer = ByteBuffer.allocate(4);
5954
// Write out the buffer length into the first four bytes.

0 commit comments

Comments
 (0)