Skip to content

Converted RegistrationIntentService to a JobIntentService #436

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 4, 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
1 change: 1 addition & 0 deletions messaging/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
</service>

<service android:name="com.google.firebase.messaging.cpp.RegistrationIntentService"
android:permission="android.permission.BIND_JOB_SERVICE"
android:exported="false" >
</service>
</application>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ public final class JobIds {
private JobIds() {}

public static final int MESSAGE_FORWARDING_SERVICE = 1000;
public static final int REGISTRATION_INTENT_SERVICE = 1001;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

package com.google.firebase.messaging.cpp;

import android.app.IntentService;
import android.content.Context;
import android.content.Intent;
import androidx.core.app.JobIntentService;
import com.google.firebase.iid.FirebaseInstanceId;
import com.google.flatbuffers.FlatBufferBuilder;
import java.io.FileOutputStream;
Expand All @@ -28,20 +28,14 @@
* A class that manages Registration Token generation and passes the generated tokens to the native
* OnTokenReceived function.
*/
public class RegistrationIntentService extends IntentService {
public class RegistrationIntentService extends JobIntentService {
private static final String TAG = "FirebaseRegService";

public RegistrationIntentService() {
// The tag here is used only to name the worker thread; it's important only for debugging.
// http://developer.android.com/reference/android/app/IntentService.html#IntentService(java.lang.String)
super(TAG);
}

// Fetch the latest registration token and notify the C++ layer.
@Override
protected void onHandleIntent(Intent intent) {
protected void onHandleWork(Intent intent) {
String token = FirebaseInstanceId.getInstance().getToken();
DebugLogging.log(TAG, String.format("onHandleIntent token=%s", token));
DebugLogging.log(TAG, String.format("onHandleWork token=%s", token));
if (token != null) {
writeTokenToInternalStorage(this, token);
}
Expand Down