-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
Hi, I am trying to use nativescript-background-fetch in Android App but it gives me error that BackgroundFetch.configure is not a function. I am using Javascript to develop android native app. My code in home-view-model.js is as below:
const observableModule = require("data/observable");
var permissions = require('nativescript-permissions');
var BackgroundFetch = require("nativescript-background-fetch");
function HomeViewModel() {
const viewModel = observableModule.fromObject({
/* Add your view model properties here */
onButtonTap: function () {
console.log(BackgroundFetch);
BackgroundFetch.configure({
minimumFetchInterval: 15, // minutes
stopOnTerminate: false, // Android-only
startOnBoot: false // Android-only
}, () => {
console.log("[js] BackgroundFetch event received");
//
// Do stuff. You have 30s of background-time.
//
// When your job is complete, you must signal completion or iOS can kill your app. Signal the nature of the fetch-event, whether you recevied:
// FETCH_RESULT_NEW_DATA: Received new data from your server
// FETCH_RESULT_NO_DATA: No new data received from your server
// FETCH_RESULT_FAILED: Failed to receive new data.
BackgroundFetch.finish(BackgroundFetch.FETCH_RESULT_NEW_DATA);
}, (status) => {
console.log('BackgroundFetch not supported by your OS', status);
});
console.log("Button was pressed");
},
textFieldValue: "",
});
return viewModel;
}
module.exports = HomeViewModel;
Metadata
Metadata
Assignees
Labels
No labels