Blackberry Phonegap geolocation Issues - blackberry

I'm having a problem when testing the geolocation API using the Blackberry devices. I'm using Phonegap 1.2.0 to build my app and I use the common HTML 5 geolocation API to get the location information.
I'm testing using Bold 9900 device on wi-fi and rarely I could get the lat long. Most of the time it returns time out error. Using the simulator, I get everything running smoothly, my google map shows up just fine. Even when I test using other devices like Torch 9860 on wi-fi, I have to retry many times until I get the lat long. On Bold 9900, it just time out all the time. I checked the device location service from the Settings and I actually could see that the device GPS working, the lat long were detected fine. This must be something wrong with the Blackberry devices, the exact same codes I have running fine on iPhone.
I tested using the SIM card as well to make sure is not the wi-fi causing the problem, but the same thing happens. It just can't get the lat long right away, only when you're lucky.
As recommended by Blackberry Webworks, I do not need to specify permissions or feature elements inside the config file. My code is just as simple as this one:
navigator.geolocation.getCurrentPosition(success, error, { maximumAge: 600000,
timeout: 10000, enableHighAccuracy: true });
var success = function(position) { // do something };
var error = function(e) { // do something };
Can someone help me on this?? Before I throw my Blackberry devices...

Related

ISO14443 - React Native NFC sometimes "Tag connection lost" - only on iOS

Context & Problem:
I’m writing a React Native application which has to communicate with NFC MiFare Ultralight tags. I have NXP NTAG I2C PLUS ISO14443-3 tags.
I’m using the react-native-nfc-manager library for this. On android I didn’t notice any problems just on the iOS side. I’m testing on iOS 13 and 14 and my device is an iPhone 7.
I am able to find and connect to NFC Mifare Ultralight tags (can read and write them too), but in the 75% of the situations I get the following error during the communications:
[CoreNFC] 00000002 803f43f0 -[NFCTagReaderSession transceive:tagUpdate:error:]:771 Error Domain=NFCError Code=100 "Tag connection lost" UserInfo={NSLocalizedDescription=Tag connection lost}
This problem only appears on iOS. Android works fine.
How I communicate:
I added the NDEF and TAG formats to the entitlements file to the …readersession.formats.
I also added value to the info.plist for the Privacy - NFC Scan Usage Description.
I’m requesting NfcTech.MifareIOS tech and calling the NfcManager.sendMifareCommandIOS() method as the library’s MiFare example shows. I’ve tried to use other transmitter methods and requesting other tech types, but in those situations I didn’t even get any responses.
This is how I create the writing commands and how I call my transmit method:
// WRITE COMMAND looks like: [0xA2, Addr, datas]
const writeCommand = [0xa2, offset, data[0], data[1], data[2], data[3]];
const response = await this.transmit(writeCommand);
This is how I create the reading commands:
// FAST_READ COMMAND looks like: [0x3A, StartAddr, EndAddr]
const readCommand = [0x3a, offset, offset + readLength];
And here is my transmit method:
private async transmit(msg: number[]): Promise<number[]> {
...
const cmd = Platform.OS === 'ios' ? NfcManager.sendMifareCommandIOS : NfcManager.transceive;
return await cmd(msg);
}
What I noticed and tried:
I noticed that the iPhone is very sensitive for the positioning. If I hold the device in a certain position I can also achieve 80% success. I noticed too that if I leave the phone on the tag I get this error more often. I got better results when I took away the phone after a communication and then put it back again.
When I added some sleep after the communication for example 100 ms, the communication seemed to be more stable. Because of the number of communications, I can't wait that much. Even if I wait I get the error, but fewer times.
I saw a very similar issue which describes a CRC problem, which appears when you try to send CRC, but that has been automatically added already by the iOS. I’m not sending the CRC (which was the solution in the mentioned issue), so that shouldn't be a problem.
Also saw the following issue with similar problem, but I have another type of tags - ISO-14443 and I'm also able to connect and communicate with the tags which wasn't the case in the mentioned issue.
Tried to invalidate the session after each communication, but didn’t help to stabilize the connection.
Tried with multiple tags (but with the same tag type), but got the same results.
I'd appreciate very much any ideas that could help me solve this problem.
At the end I managed to try out our app on multiple iPhones and the NFC worked properly.
We also found out that our test device is a refurbished unit and we think that maybe that is the problem's cause.

indexedDB.open() takes around 10sec on iOS Safari

I have an indexedDB database used in a web app on my iPhone.
Lately it started to take more time to start. After diagnosing this case for some time I've found that it happens because of indexedDB.open() running for 10+ seconds.
Here is a little code example
var db;
var promise = utils.promise();
var openRequest = indexedDB.open(this.dbName, this.version);
openRequest.onsuccess = function(evt) {
db = openRequest.result;
promise.resolve();
};
openRequest.onerror = function(evt) {
promise.reject();
onError(evt, 'Database open');
};
Database itself didn't change lately so much. Also I don't have lots of data. It has around 300 records.
Any idea how to diagnose such an issue?
UPD may be related https://bugs.chromium.org/p/chromium/issues/detail?id=402980
Apparently it was a result of iOS update (from 11.1.* to 11.2.*).
I have my web app added to the Home Screen. And as far as I understand when you do iOS updates the web app container is moved to a new iOS environment but conserves some features from the original iOS version (probably something related to WebView used for web app but I am not sure).
So I have added my web app to Home Screen again and it starts without delays.

IONIC2 - app gets killed after some time even when using Background Geolocation

I have an IONIC2 app, which needs to wake up every morning at 8 AM for 20 minutes to send user reminders based on the user's geolocation.
I am using this plugin (which uses IOS significant changes API to monitor changes in user's location)
https://github.com/mauron85/cordova-plugin-background-geolocation
The problem:
The app doesn't get killed when I close the app and the background geolocation works for me fine for some time. I have tested upto an hour. But when I wake up next morning, I find the app was killed by IOS.
I know there is another plugin to keep the app running in the background https://github.com/katzer/cordova-plugin-background-mode, but I have read tons of complaints from people that it will cause your app to be rejected by the AppStore (In fact, the plugin has a disclaimer to the same effect too).
For waking up the app tomorrow, I simply set a setTimeout
setTimeout(function(){
console.log('waking up');
self.helper.scheduleLocalNotification('Hello World', 'Good Morning', 10, "");
self.ionViewDidEnter();
}, wakeupinMilliSeconds);
Here is my geolocation code:
setupBackGroundGeolocation(){
let config = {
desiredAccuracy: 100,
stationaryRadius: 50,
distanceFilter: 100,
interval: 5000,
pauseLocationUpdates: false,
debug: false, // enable this hear sounds for background-geolocation life-cycle.
stopOnTerminate: false, // enable this to clear background location settings when the app terminates
};
BackgroundGeolocation.configure((location) => {
console.log('[js] BackgroundGeolocation callback: ' + location.latitude + ',' + location.longitude);
this.currentLocation.lat = location.latitude;
this.currentLocation.lng = location.longitude;
Promise.all([
//I do some calculations here.
]).then(d => {
// IMPORTANT: You must execute the finish method here to inform the native plugin that you're finished,
// and the background-task may be completed. You must do this regardless if your HTTP request is successful or not.
// IF YOU DON'T, ios will CRASH YOUR APP for spending too much time in the background.
BackgroundGeolocation.finish(); // FOR IOS ONLY
});
}, (error) => {
console.log('BackgroundGeolocation error');
}, config);
// Turn ON the background-geolocation system. The user will be tracked whenever they suspend the app.
BackgroundGeolocation.start();
}
I don't use this plugin but had same symptons. I couldn't figure out what was wrong: no error messages, no clues but app kept closing after a few hours.
I guess there was something messed up after installing and uninstalling so many cordova plugins. Now the app is much more stable. I removed and added platform. That seemed to do the job.
I've been reading about ionic2 and performance. Among so many reasons, a possibility about low performance and crash is related not to unsubscribe from observables. Read about async pipe and .unsubscribe observables when component is destroyed ngOnDestroy
Another problem i found was a very basic mistake developing in angular. I loaded everything in the app module so this required lot of memory to load the entire app at once. I guess with slow terminals that can affect more. Anyway, basic angular concepts as .module files should be understood.

Detecting Firebase connection state uses huge amount of memory in react-native app

When I add the following code to my react-native app, memory usage soars from 40MB to 400MB in ten minutes (and keeps going) as soon as I take the app offline.
root.child(".info/connected").on("value", (snap) => {
if (snap.val() === true) {
this.online = true;
info("Going online");
if (this.user) { /* counter already loaded */
debug("posting offline transactions");
}
} else {
this.online = false;
info("Going offline");
}
});
The app itself is entirely quiescent and the .on() listener is not getting triggered. When I bring the phone back online memory usage stabilizes but does not decrease.
I have no idea how to debug this. I cannot run the app under the Chrome debugger because the phone has to be online to connect to the debugger. I cannot use the iOS simulator because to bring that offline you have to bring the whole computer offline and then you get the error: WebSocket connection failed
The only way I have to debug is to view console.log messages in xcode and my app has lots of them, but nothing is happening in the app itself.
I need to monitor offline/online state in order to work around the fact that Firebase transactions consume a large amount of memory when the app is used offline.

getCurrentPosition does not refresh

I have an app which uses forge.geolocation.getCurrentPosition. It seems that at times, the location does not refresh. I can open the iOS app in one position, and then an hour later 5 miles away, open the app again (either resume, or completely close the app from the tray, and re-open) and still the old location is returned.
I am using this form
forge.geolocation.getCurrentPosition({enableHighAccuracy: true}, function (location) {})
Note that when opening/resuming the App, the GPS icon at the top DOES show up however the location returned to the javascript code is incorrect.
The above bug was reproduced on iOS 6
After opening the Maps app, and going back to my app, the correct location is finally returned.
Any idea how to fix this?
getCurrentPosition returns the best data it has at that particular time - I'd recommend calling the method a number of times until the indicated accuracy is reduced to an acceptable level.
What we might do in the future is support watchPosition so that something like https://stackoverflow.com/a/8554835 would be possible through the forge API

Resources