com.facebook.react.HeadlessJsTaskService Java Examples

The following examples show how to use com.facebook.react.HeadlessJsTaskService. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HeartbeartService.java    From rn-heartbeat with MIT License 5 votes vote down vote up
@Override
public void run() {
    Context context = getApplicationContext();
    Intent myIntent = new Intent(context, HeartbeatEventService.class);
    context.startService(myIntent);
    HeadlessJsTaskService.acquireWakeLockNow(context);
    handler.postDelayed(this, 2000);
}
 
Example #2
Source File: BoundaryEventJobIntentService.java    From react-native-boundary with Apache License 2.0 5 votes vote down vote up
private void sendEvent(Context context, String event, ArrayList<String> params) {
    final Intent intent = new Intent(RNBoundaryModule.GEOFENCE_DATA_TO_EMIT);
    intent.putExtra("event", event);
    intent.putExtra("params", params);

    Bundle bundle = new Bundle();
    bundle.putString("event", event);
    bundle.putStringArrayList("ids", intent.getStringArrayListExtra("params"));

    Intent headlessBoundaryIntent = new Intent(context, BoundaryEventHeadlessTaskService.class);
    headlessBoundaryIntent.putExtras(bundle);

    context.startService(headlessBoundaryIntent);
    HeadlessJsTaskService.acquireWakeLockNow(context);
}
 
Example #3
Source File: RNCallKeepModule.java    From react-native-callkeep with ISC License 4 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    WritableMap args = Arguments.createMap();
    HashMap<String, String> attributeMap = (HashMap<String, String>)intent.getSerializableExtra("attributeMap");

    switch (intent.getAction()) {
        case ACTION_END_CALL:
            args.putString("callUUID", attributeMap.get(EXTRA_CALL_UUID));
            sendEventToJS("RNCallKeepPerformEndCallAction", args);
            break;
        case ACTION_ANSWER_CALL:
            args.putString("callUUID", attributeMap.get(EXTRA_CALL_UUID));
            sendEventToJS("RNCallKeepPerformAnswerCallAction", args);
            break;
        case ACTION_HOLD_CALL:
            args.putBoolean("hold", true);
            args.putString("callUUID", attributeMap.get(EXTRA_CALL_UUID));
            sendEventToJS("RNCallKeepDidToggleHoldAction", args);
            break;
        case ACTION_UNHOLD_CALL:
            args.putBoolean("hold", false);
            args.putString("callUUID", attributeMap.get(EXTRA_CALL_UUID));
            sendEventToJS("RNCallKeepDidToggleHoldAction", args);
            break;
        case ACTION_MUTE_CALL:
            args.putBoolean("muted", true);
            args.putString("callUUID", attributeMap.get(EXTRA_CALL_UUID));
            sendEventToJS("RNCallKeepDidPerformSetMutedCallAction", args);
            break;
        case ACTION_UNMUTE_CALL:
            args.putBoolean("muted", false);
            args.putString("callUUID", attributeMap.get(EXTRA_CALL_UUID));
            sendEventToJS("RNCallKeepDidPerformSetMutedCallAction", args);
            break;
        case ACTION_DTMF_TONE:
            args.putString("digits", attributeMap.get("DTMF"));
            args.putString("callUUID", attributeMap.get(EXTRA_CALL_UUID));
            sendEventToJS("RNCallKeepDidPerformDTMFAction", args);
            break;
        case ACTION_ONGOING_CALL:
            args.putString("handle", attributeMap.get(EXTRA_CALL_NUMBER));
            args.putString("callUUID", attributeMap.get(EXTRA_CALL_UUID));
            args.putString("name", attributeMap.get(EXTRA_CALLER_NAME));
            sendEventToJS("RNCallKeepDidReceiveStartCallAction", args);
            break;
        case ACTION_AUDIO_SESSION:
            sendEventToJS("RNCallKeepDidActivateAudioSession", null);
            break;
        case ACTION_CHECK_REACHABILITY:
            sendEventToJS("RNCallKeepCheckReachability", null);
            break;
        case ACTION_WAKE_APP:
            Intent headlessIntent = new Intent(reactContext, RNCallKeepBackgroundMessagingService.class);
            headlessIntent.putExtra("callUUID", attributeMap.get(EXTRA_CALL_UUID));
            headlessIntent.putExtra("name", attributeMap.get(EXTRA_CALLER_NAME));
            headlessIntent.putExtra("handle", attributeMap.get(EXTRA_CALL_NUMBER));
            Log.d(TAG, "wakeUpApplication: " + attributeMap.get(EXTRA_CALL_UUID) + ", number : " + attributeMap.get(EXTRA_CALL_NUMBER) + ", displayName:" + attributeMap.get(EXTRA_CALLER_NAME));

            ComponentName name = reactContext.startService(headlessIntent);
            if (name != null) {
                HeadlessJsTaskService.acquireWakeLockNow(reactContext);
            }
            break;
    }
}