Skip to content

Commit 3aeff9b

Browse files
authored
Merge f0e61d3 into 3a58ecd
2 parents 3a58ecd + f0e61d3 commit 3aeff9b

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

messaging/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
</service>
2323

2424
<service android:name="com.google.firebase.messaging.cpp.RegistrationIntentService"
25+
android:permission="android.permission.BIND_JOB_SERVICE"
2526
android:exported="false" >
2627
</service>
2728
</application>

messaging/src/android/java/com/google/firebase/messaging/JobIds.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ public final class JobIds {
2020
private JobIds() {}
2121

2222
public static final int MESSAGE_FORWARDING_SERVICE = 1000;
23+
public static final int REGISTRATION_INTENT_SERVICE = 1001;
2324
}

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

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414

1515
package com.google.firebase.messaging.cpp;
1616

17-
import android.app.IntentService;
1817
import android.content.Context;
1918
import android.content.Intent;
19+
import androidx.core.app.JobIntentService;
2020
import com.google.firebase.iid.FirebaseInstanceId;
2121
import com.google.flatbuffers.FlatBufferBuilder;
2222
import java.io.FileOutputStream;
@@ -28,20 +28,14 @@
2828
* A class that manages Registration Token generation and passes the generated tokens to the native
2929
* OnTokenReceived function.
3030
*/
31-
public class RegistrationIntentService extends IntentService {
31+
public class RegistrationIntentService extends JobIntentService {
3232
private static final String TAG = "FirebaseRegService";
3333

34-
public RegistrationIntentService() {
35-
// The tag here is used only to name the worker thread; it's important only for debugging.
36-
// http://developer.android.com/reference/android/app/IntentService.html#IntentService(java.lang.String)
37-
super(TAG);
38-
}
39-
4034
// Fetch the latest registration token and notify the C++ layer.
4135
@Override
42-
protected void onHandleIntent(Intent intent) {
36+
protected void onHandleWork(Intent intent) {
4337
String token = FirebaseInstanceId.getInstance().getToken();
44-
DebugLogging.log(TAG, String.format("onHandleIntent token=%s", token));
38+
DebugLogging.log(TAG, String.format("onHandleWork token=%s", token));
4539
if (token != null) {
4640
writeTokenToInternalStorage(this, token);
4741
}

0 commit comments

Comments
 (0)