Skip to content

Commit

Permalink
Ignore when called from other platform than iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
dumbest committed Apr 15, 2020
1 parent 7566d82 commit e145fa5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion index.js
@@ -1,5 +1,5 @@

import { NativeModules } from 'react-native';
import { NativeModules, Platform } from 'react-native';

const RNBackgroundExecution = NativeModules.RNBackgroundExecution;

Expand All @@ -9,6 +9,10 @@ export default class BackgroundExecution {
*/
static beginBackgroundTask() {
return new Promise((resolve, reject) => {
if (Platform.OS !== 'ios') {
resolve();
return;
}
RNBackgroundExecution.beginBackgroundTaskWithExpirationHandler((error) => {
resolve(error);
});
Expand All @@ -20,6 +24,9 @@ export default class BackgroundExecution {
* Failure to end the task explicitly will result in the termination of the app.
*/
static endBackgroundTask() {
if (Platform.OS !== 'ios') {
return;
}
RNBackgroundExecution.endBackgroundTask();
}
};
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "rn-background-execution",
"version": "1.0.4",
"version": "1.0.5",
"description": "Ensure that critical tasks finish when your app moves to the background",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit e145fa5

Please sign in to comment.