Closed PhilGauths closed 5 years ago
Is this not you?
yes but the log was with ionic app. my client want cordova, this is why i try to compile cordova-basic ignore all log before 13h30
It makes absolutely no difference, Ionic or not. This is a pure Native SDK with a thin layer of Javascript API to talk to it. It really doesn't matter.
This cordova-basic
example hasn't been touched in ages. Don't use it. Make your own Cordova Hello World app and drop this code into it, just as shown in the README of the plugin
cordova create foo com.foo.bar Foo
cd foo
cordova plugin add cordova-plugin-device
cordova plugin add cordova-background-geolocation-lt
cordova platform add android
config.xml
: add lines in green<?xml version='1.0' encoding='utf-8'?>
+<widget id="com.foo.bar" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<name>Foo</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="dev@cordova.apache.org" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<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:*" />
<platform name="android">
<allow-intent href="market:*" />
<!-- White-list all HTTP traffic so plugin can post to server -->
+ <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
+ <application android:usesCleartextTraffic="true" />
+ </edit-config>
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
</widget>
www/js/index.js
:/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var app = {
// Application Constructor
initialize: function() {
document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
},
// deviceready Event Handler
//
// Bind any cordova events here. Common events are:
// 'pause', 'resume', etc.
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);
});
// motionchange event: Fires when plugin changes state from Stationary->Moving and vice-versa.
bgGeo.onMotionChange(function(location) {
console.log('[event] motionchange', location);
});
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://tracker.transistorsoft.com/locations/philgauths-cordova',
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();
console.log('- BackgroundGeolocation is configured and ready to use');
});
},
// Update DOM on a Received Event
receivedEvent: function(id) {
var parentElement = document.getElementById(id);
var listeningElement = parentElement.querySelector('.listening');
var receivedElement = parentElement.querySelector('.received');
listeningElement.setAttribute('style', 'display:none;');
receivedElement.setAttribute('style', 'display:block;');
console.log('Received Event: ' + id);
}
};
app.initialize();
url: 'http://tracker.transistorsoft.com/locations/philgauths-cordova'
ok, this cordova app works and I will test it, thanks again
The pure native background geolocation SDK has no knowledge or care if you're using vanilla Cordova, Ionic with Cordova, React Native, Flutter or a pure native app.
It's the same native SDK.
Tracking behaviour is 100% guaranteed to be identical with an Ionic app vs pure Cordova app.
I see you live in Quebec. Did you see where my Pixel 3a is located?
I try examples\cordova-basic.
I build this example and try on my android device. But nothing working.
Home page appears but nothing occurs.
I look inspect and no console debug, no console log and no error can see.
Can you help me? I would like to try cordova on android before purchase.