-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
53db36a
commit 616eae0
Showing
4 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
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
1 change: 1 addition & 0 deletions
1
modules/background-task/android/src/main/AndroidManifestNew.xml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> | ||
</manifest> |
29 changes: 29 additions & 0 deletions
29
...ask/android/src/main/java/com/expensify/reactnativebackgroundtask/BackgroundJobService.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.expensify.reactnativebackgroundtask | ||
|
||
import android.app.job.JobParameters | ||
import android.app.job.JobService | ||
import android.util.Log | ||
import com.facebook.react.ReactApplication | ||
|
||
class BackgroundJobService : JobService() { | ||
override fun onStartJob(params: JobParameters?): Boolean { | ||
// Get the stored taskName | ||
val extras = params?.extras | ||
val taskName = extras?.getString("taskName") | ||
|
||
taskName?.let { | ||
val reactApplication = application as ReactApplication | ||
val reactNativeHost = reactApplication.reactNativeHost | ||
val reactContext = reactNativeHost.reactInstanceManager.currentReactContext | ||
|
||
reactContext?.getNativeModule(ReactNativeBackgroundTaskModule::class.java) | ||
?.emitOnBackgroundTaskExecution(it) | ||
} | ||
return false | ||
} | ||
|
||
override fun onStopJob(params: JobParameters?): Boolean { | ||
// Return true to reschedule the job | ||
return true | ||
} | ||
} |
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