16
16
17
17
import android .content .Context ;
18
18
import android .content .Intent ;
19
+ import android .os .Bundle ;
19
20
import androidx .core .app .JobIntentService ;
20
21
import com .google .firebase .messaging .cpp .DebugLogging ;
21
22
import com .google .firebase .messaging .cpp .MessageWriter ;
22
23
24
+
23
25
/**
24
26
* Listens for Message intents from the application and sends them to the C++ app via the
25
27
* ListenerService.
@@ -28,6 +30,14 @@ public class MessageForwardingService extends JobIntentService {
28
30
private static final String TAG = "FIREBASE_MSG_FWDR" ;
29
31
public static final String ACTION_REMOTE_INTENT = "com.google.android.c2dm.intent.RECEIVE" ;
30
32
33
+ /**
34
+ * Convenience wrapper over enqueueWork to either directly start the service (when running on
35
+ * pre-O platforms) or enqueue work for it as a job (when running on Android O and later).
36
+ */
37
+ public static void enqueueWork (Context context , Intent intent ) {
38
+ enqueueWork (context , MessageForwardingService .class , JobIds .MESSAGE_FORWARDING_SERVICE , intent );
39
+ }
40
+
31
41
// Handle message intents sent from the ListenerService.
32
42
@ Override
33
43
protected void onHandleWork (Intent intent ) {
@@ -46,7 +56,7 @@ static void handleIntent(Context context, Intent intent, MessageWriter messageWr
46
56
if (intent != null
47
57
&& intent .getAction () != null
48
58
&& intent .getAction ().equals (ACTION_REMOTE_INTENT )) {
49
- android . os . Bundle extras = intent .getExtras ();
59
+ Bundle extras = intent .getExtras ();
50
60
DebugLogging .log (TAG , "extras: " + (extras == null ? "(null)" : extras .toString ()));
51
61
if (extras != null ) {
52
62
RemoteMessage message = new RemoteMessage (extras );
0 commit comments