Open TarakShah17 opened 6 years ago
I see I haven't provided an ISSUE_TEMPLATE
for this repo. Please provide the following information:
tns info
):Hi Chris, here is the Environment info:
Change this:
var BackgroundFetch = require("nativescript-background-fetch");
to this:
import {BackgroundFetch} from "nativescript-background-fetch";
Changing to below line gives error "unexpected token {" (its a opening curly bracket after import) on load of that page and view is not rendered.
import {BackgroundFetch} from "nativescript-background-fetch";
are you not using typescript?
No.
try this:
var BackgroundFetch = require("nativescript-background-fetch").BackgroundFetch;
Now, above errors are resolved but getting new error:
TypeError: Cannot read property 'Builder' of undefined. File: /nativescript-background-fetch/background-fetch.js, line 27, Column 38
I've created a new blank app (without typescript) and it works.
$ tns create Fetch
$ tns plugin add nativescript-background-fetch
$ tns info
✔ Getting NativeScript components versions information...
✔ Component nativescript has 4.1.2 version and is up to date.
✔ Component tns-core-modules has 4.1.0 version and is up to date.
✔ Component tns-android has 4.1.3 version and is up to date.
✖ Component tns-ios is not installed.
main-view-model.js
var Observable = require("data/observable").Observable;
var BackgroundFetch = require("nativescript-background-fetch").BackgroundFetch;
function getMessage(counter) {
if (counter <= 0) {
return "Hoorraaay! You unlocked the NativeScript clicker achievement!";
} else {
return counter + " taps left";
}
}
function createViewModel() {
var viewModel = new Observable();
viewModel.counter = 42;
viewModel.message = getMessage(viewModel.counter);
BackgroundFetch.configure({
minimumFetchInterval: 15
}, function() {
console.log('- NativeScript BackgroundFetch Received');
}, function() {
console.log('- NativeScript BackgroundFetch error');
});
viewModel.onTap = function() {
this.counter--;
this.set("message", getMessage(this.counter));
}
return viewModel;
}
exports.createViewModel = createViewModel;
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: