Last active
June 24, 2019 14:02
-
-
Save SkyTreasure/0b984877c029b5f4a18ad26a6d4a0ccc to your computer and use it in GitHub Desktop.
HeadlessService
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.yourpackagename; | |
import android.content.Intent; | |
import android.os.Bundle; | |
import android.support.annotation.Nullable; | |
import com.facebook.react.HeadlessJsTaskService; | |
import com.facebook.react.bridge.Arguments; | |
import com.facebook.react.jstasks.HeadlessJsTaskConfig; | |
public class HeadlessService extends HeadlessJsTaskService { | |
@Override | |
protected @Nullable | |
HeadlessJsTaskConfig getTaskConfig(Intent intent) { | |
Bundle extras = intent.getExtras(); | |
if (extras != null) { | |
return new HeadlessJsTaskConfig( | |
"BeaconScanTask", | |
Arguments.fromBundle(extras), | |
5000, // timeout for the task | |
true // optional: defines whether or not the task is allowed in foreground. Default is false | |
); | |
} | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment