Open wloges opened 5 years ago
`<?xml version='1.0' encoding='utf-8'?>
`
No, that old Cordova example is broken. Make your own hello world.
var BackgroundGeolocation = window.BackgroundGeolocation
See the README
What about config.xml? This is Ok?
`<?xml version='1.0' encoding='utf-8'?> <widget id="com.foo.bar" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Aplikacja</name>
<description>
Aplikacja
</description>
<author email="aaa@xxxx.com">
Author
</author>
<content src="index.html" />
<preference name="DisallowOverscroll" value="true" />
<preference name="android-minSdkVersion" value="15" />
<preference name="android-targetSdkVersion" value="23" />
<preference name="detect-data-types" value="true" />
<preference name="StatusBarOverlaysWebView" value="false" />
<preference name="StatusBarBackgroundColor" value="#ee6e73" />
<preference name="StatusBarStyle" value="blacktranslucent" />
<platform name="android">
<allow-intent href="market:*" />
<icon density="ldpi" src="/res/android/ldpi.png" />
<icon density="mdpi" src="/res/android/mdpi.png" />
<icon density="hdpi" src="/res/android/hdpi.png" />
<icon density="xhdpi" src="/res/android/xhdpi.png" />
</platform>
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<engine name="android" spec="^6.3.0" />
<plugin name="cordova-plugin-whitelist" spec="^1.3.3" />
<plugin name="cordova-background-geolocation-lt" spec="https://github.com/transistorsoft/cordova-background-geolocation-lt.git">
<variable name="GOOGLE_API_VERSION" value="11.6.0" />
<variable name="APPCOMPAT_VERSION" value="26.1.0" />
</plugin>
<plugin name="cordova-plugin-device" spec="^1.1.7" />
<plugin name="cordova-plugin-dialogs" spec="^1.3.4" />
`
No it's not ok.
<variable name="GOOGLE_API_VERSION" value="11.6.0" />
<variable name="APPCOMPAT_VERSION" value="26.1.0" />
play-services-location:11.6.0
is over 2 years old. The latest version is 16.0.0
.
Unfortunately I have still a problem. While testing in browser on desktop I got '- BackgroundGeolocation is configured and ready to use'. No errors. On Samsung device last alert is ' - Start ready'. It seems app fails on bgGeo.ready. I'm really confused. Please tell me what I'm doing wrong?
var app = {
initialize: function() {
document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
},
onDeviceReady: function() {
this.receivedEvent('deviceready');
var bgGeo = window.BackgroundGeolocation;
bgGeo.onLocation(function(location) {
console.log('[event] location: ', location);
}, function(error) {
console.warn('[event] location error: ', error);
});
bgGeo.onMotionChange(function(location) {
console.log('[event] motionchange', location);
});
alert('- Start ready');
bgGeo.ready({
desiredAccuracy: bgGeo.DESIRED_ACCURACY_HIGH, // Highest possible accuracy: GPS + Wifi + Cellular
distanceFilter: 10, // Record a location every 10 meters.
stopOnTerminate: false, // Don't stop tracking when app is terminated.
url: 'http://www.mysite.com/geoloc.php',
params: bgGeo.transistorTrackerParams(window.device),
debug: true, // Debug sounds & notifications
autoSync: true, // Auto sync each recorded location to #url immediately.
logLevel: bgGeo.LOG_LEVEL_VERBOSE
},
function(state) {
bgGeo.start();
alert('- BackgroundGeolocation is configured and ready to use');
console.log('- BackgroundGeolocation is configured and ready to use');
});
alert('- End');
}
You can’t use the plugin in the browser.
Test on real device
On real device application fails on bgGeo.ready.
See wiki Debugging
More specific please, I'm new in phonegap applications.
Click link Wiki followed by Debugging
Problem solved. Plugin cordova-background-geolocation-lt@~3.3.1 needs cordova ver:^7.0.0.
To achieve it I set <preference name="phonegap-version" value="cli-8.1.1" />
Below is working config.xml for all who want to save many hours for finding right solution :)
`<?xml version='1.0' encoding='utf-8'?>
<widget id="com.foo.bar" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>App</name>
<description>
Application
</description>
<author email="admin@aaa.com">
Author
</author>
<content src="index.html" />
<preference name="phonegap-version" value="cli-8.1.1" />
<preference name="DisallowOverscroll" value="true" />
<preference name="android-minSdkVersion" value="19" />
<preference name="android-targetSdkVersion" value="23" />
<preference name="detect-data-types" value="true" />
<preference name="StatusBarOverlaysWebView" value="false" />
<preference name="StatusBarBackgroundColor" value="#ee6e73" />
<preference name="StatusBarStyle" value="blacktranslucent" />
<platform name="android">
<allow-intent href="market:*" />
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
<application android:usesCleartextTraffic="true" />
</edit-config>
<icon density="ldpi" src="www/res/android/ldpi.png" />
<icon density="mdpi" src="www/res/android/mdpi.png" />
<icon density="hdpi" src="www/res/android/hdpi.png" />
<icon density="xhdpi" src="www/res/android/xhdpi.png" />
</platform>
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<plugin name="cordova-plugin-whitelist" spec="^1.3.3" />
<plugin name="cordova-plugin-device" spec="^1.1.7" />
<plugin name="cordova-plugin-dialogs" spec="^1.3.4" />
<plugin name="cordova-background-geolocation-lt" spec="~3.3.1">
<variable name="LICENSE" value="YOUR_LICENSE_KEY" />
<variable name="GOOGLE_API_VERSION" value="16.0.0" />
<variable name="APPCOMPAT_VERSION" value="27.1.0" />
</plugin>
</widget>`
But the way to full happiness is still long :) I'v got LICENSE VALIDATION FAILURE although I run the application in debug mode. Chris, what to do to test for free this plugin?
Why are you using GOOGLE_API_VERSION 11.6.0
?? It's over 2 years old.
I'v got LICENSE VALIDATION FAILURE
It's normal. It's fully functional in DEBUG builds. Ignore everything about "license" until you buy one.
You are right, it should be
<variable name="GOOGLE_API_VERSION" value="16.0.0" /> <variable name="APPCOMPAT_VERSION" value="27.1.0" />
I didn't mention that my problem was building the application in https://build.phonegap.com :)
I try to build ios version. After adding to above config a part from https://github.com/transistorsoft/cordova-background-geolocation-lt for ios
`
<platform name="ios">
<config-file parent="NSLocationAlwaysAndWhenInUseUsageDescription" target="*-Info.plist">
<string>LOCATION_ALWAYS_AND_WHEN_IN_USE_USAGE_DESCRIPTION</string>
</config-file>
<config-file parent="NSLocationAlwaysUsageDescription" target="*-Info.plist">
<string>LOCATION_ALWAYS_USAGE_DESCRIPTION</string>
</config-file>
<config-file parent="NSLocationWhenInUseUsageDescription" target="*-Info.plist">
<string>LOCATION_WHEN_IN_USE_USAGE_DESCRIPTION</string>
</config-file>
<config-file parent="NSMotionUsageDescription" target="*-Info.plist">
<string>MOTION_USAGE_DESCRIPTION</string>
</config-file>
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform> `
Adobe PhoneGap Build doesn't even start with building ios. Log is empty. Android is Ok. I would appreciate any ideas.
You’re trying to build the SampleApp on PhoneGap?
I don’t use PhoneGap so that’s never been tested by me.
What way do You recomend to build this app?
I use Ionic and Cordova CLI in terminal:
$ ionic cordova build ios
I like to launch iOS directly from XCode; better logging.
For Android
$ ionic cordova run android
PhoneGap is a release build service, not a development build server. I you don't have a Mac, get one. You're a mobile developer.
I've installed on my Samsung S9 this example https://github.com/transistorsoft/cordova-background-geolocation-SampleApp/tree/master/examples/cordova-basic with config shown below. On screen I've got blinking "Stopped". Clicking on "Start" or another buttons change nothing. I would appreciate any suggestions. Maybe another working sample which I can develop for my purposes? Thx in advance.
<?xml version='1.0' encoding='utf-8'?>