alt beacon cordova not detecting beacons - android

I have a native Android SDK that uses the latest AltBeacon library.
I use my SDK within several Apps to detect beacons and perform business logic.
I now need to include my SDK within a Android Cordova app but it does not detect any beacons. (It does work within an iOS Cordova app). This is probably due to the Bluetooth management being controlled by Cordova and hence not allowing the Altbeacon lib to do it's thing.
Should the Altbeacon lib work within the Android Cordova environment and if so can someone point me in the right direction to get this to work.

I suspect the main issues are:
You need to set up the Android AppManifest.xml to enable Bluetooth LE permissions, and declare the scanning service. The native library AAR file gets this into your native app's manifest via manifest merging. You probably need to copy the entries manually from here.
On Android 5+ you need to request location permissions at runtime to scan for BLE beacons, otherwise you will get no results. I have not configured a Cordova app to request location permissions on Android, but you may get some hints from this answer.
If you do both these things and still have trouble, I would capture a LogCat excerpt and look for anything bluetooth related coming frin your app, and post the results in your question.

Related

What are reliable methods of finding geolocation on a cordova/hybrid app?

I am building a Cordova app that will run on android and ios (windows phone would be a plus).
I am having trouble finding a reliable way to get the geolocation coordinates of the device.
I have been using this API: https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/Using_geolocation
I have also used this Cordova plugin: https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-geolocation/
The plugin says that it is based on the W3C Geolocation API.
I am finding that these are not very robust and reliable ways of getting the location. It's not clear if the libraries eventually interface with the hardware or not.
I wrote a small native Java app that runs on Android and it was able to find my coordinates within 4 seconds. Native apps always interface with the hardware more closely so it makes sense that it would be more robust.
I am not seeing a lot of Cordova plugins that interface with native without going through this W3C API first.
I found some but they are not cross-platform:
https://www.npmjs.com/package/cordova-plugin-advanced-geolocation
Is it very difficult to write a plugin for just listening to the location updates?
Are there any reliable methods?

Bluetooth LE app, how to build it cross-plaftorm (iOS-Android)?

I am working on an app that talks to a Bluetooth LE device. I would like some way to avoid developing it twice, for iOS and for Android. Is there a cross-platform app framework that has good support for Bluetooth LE?
I have had a quick look at frameworks like Cordova (PhoneGap), Appcelerator, Xamarin etc (the usual suspects: for example this list) but I can't figure out if they (a) support Bluetooth LE on each platform at all, and (b) if they do, whether it is via native calls (accessed how?) or some kind of wrapper to the native API (what does the wrapper look like?), and (c) if it is a wrapper, how complete it is, and how stable it is.
If you have experience with these, could you summarize the status of Bluetooth LE support in different frameworks?
EDIT A bit of info from digging into various options and from the answers below:
Cordova: several open-source plugins, for example https://github.com/evothings/cordova-ble https://github.com/don/cordova-plugin-ble-central https://github.com/randdusing/BluetoothLE (not a complete list). Evothings is a nice Cordova + bluetooth setup. Do these work in other Cordova-based app frameworks like Appery.io, Telerik AppBuilder, Ionic Creator?
Xamarin: this just uses the native APIs via MonoTouch.CoreBluetooth and Android.Bluetooth. This means the code using them is not actually cross-platform, but they are likely to work the same as the native API (because they essentially are the native API).
Appcelerator has third-party commercial plugins for Bluetooth (https://marketplace.appcelerator.com/apps/3834 and
https://marketplace.appcelerator.com/apps/6611), no built-in support. Do these work?
P.S. Besides Bluetooth my needs are pretty minimal: this app will have a lot of UI elements but not of a complicated kind, just a bunch of buttons/checkboxes/sliders on a bunch of different screens (which would be very tedious to maintain on two platforms). I'd also need to make a few calls to a REST API. Speed is not super important, there isn't that much app logic (it is mostly written in C now), and native UI look is not that important. However working on older versions of the platforms is important, ideally back to Android 4.3 and iOS 7.0.
I have been using Randdusing's Cordova plugin for BluetoothLE and it works well for Android and iOS (Windows phone still under development). Being Cordova it's designed to work with an HTML5/JavaScript app, but the plugins themselves (as all Cordova plugins?) are written in native code .
Earlier in my project I tried Evothings which also has BLE plugin but I found some problems, and I don't know if these have been resolved yet.
My app sounds pretty similar to yours in terms of the UI requirements, and I can possibly help with integrating the BLE code if you like - but you'll need to rewrite your 'c' into javascript first.
BTW you ask for using with older Android but AFAIK BLE is only supported in Android 4.3 or higher.
I am using Qt framework developing cross-platform apps with BLE support:
http://doc.qt.io/qt-5/qtbluetooth-lowenergyscanner-example.html
Currently the supported platforms are Andriod, iOS, OSX, Linux. Windows platform is said to support BLE in the forthcoming version Qt 5.6 (really looking forward to it). The BLE related classes are easy to use and Qt provided two sample projects in examples/documentation. The thing I am not sure about is getting Manufacturer Specific Data during a scan. Right now I am making a connection to the devices to get certain information which wouldn't be needed if I can read the Manufacturer Specific Data. Qt's BLE currently only support central role.
Qt is based on C++, if that matters to you.

Android Wear project - with an existing Android project

I have an existing Android app (for 4.2) written using Eclipse.
I'm exploring the possibility of adding an Android Wear component - there's part of the app which I think could work on a watch.
Reading through the docs at https://developer.android.com/training/building-wearables.html I'm unsure of what I'd need to do in order to integrate Wear into my existing project.
For example, under prerequisites it says Android Studio. Does that mean I'd need to migrate my Eclipse solution into Android Studio? Or can I build the Wear component independently?
Essentially, I'm just hoping to hear from someone who has added a Wear component to their existing Android solution so I can understand the basics of what's involved.
Android Wear is essentially very light application. The basic processing happens on the handheld device. Only user interaction functionalities such as accept, reject etc. is deplyed to the wear. Here also the processing is carried on by the handheld device.
So yes, you can include Wear to your project if it adds any value.

Setting android permissions in Icenium

I've developed an android app using Icenium Graphite. When I install my app onto my phone, it always displays a long list of permissions that my app supposedly needs approval for prior to installation. The only thing my app needs are the camera and sound recorder. When I add these permissions in via the Properties page in Graphite and remove all other permissions, my app still keeps asking for permission for everything in creation (location, contacts, etc.) upon installation to a device. What am I doing wrong?
Thanks,
Dave
You are probably using the Cordova 3.0.0 framework that comes with a set of core plugins. The core plugins let you access native system functionality such as the accelerometer, camera, compass etc. By default Icenium includes all of those core plugins. They require some additional Android permissions so when you build your project, the build process adds these permissions by default.
The next Icenium version would let you disable the core plugins that are not required by your application and this would eliminate the need of the additional Android permissions.

How to track the device location (iOS and Android) device using Phonegap

I would like to know when a user arrives or leaves certain location. I was trying to do this using the wireless network (check for mobile devices), but I couldn't for several reasons.
1) I needed real time updates or every 1 - 5 min of the information about which devices are connected and which devices have just disconnected.
2) I had very high ping from my PC to my iPhone on the same network (still don't know why).
Now I want to do it using geolocation from a Phonegap application (running in the background) suspended on iOS or running in the background in Android.
Any help would be appreciated.
Update 25 May 2019
My original answer below is 6 years old and out-of-date with respect to current mobile OS versions.
For example partial wakelocks no longer work on modern Android versions.
Today my recommendation would be (if you have a serious commercial app and not a hobby project) to use the paid-for version of the cordova-background-geolocation plugin by Transistorsoft.
The free version works for iOS but for Android a license is required which costs in the order of several hundred US dollars.
However I think the price is worth it: in my 10+ years of experience in creating location-aware mobile apps, this has been the most sophisiticated and reliable solution I've encountered.
For the cost of your license, you get access to the private repo which is continually updated and maintained to be compatible with new versions of Android & iOS.
If you're looking for a free/open-source solution, I would go with cordova-plugin-background-geolocation which is an open-source fork of the original plugin by Transistorsoft.
However my experience with this plugin has been of mixed success; due to being free/open-source, it's not updated as frequently as the paid-for Transistorsoft plugin.
I encountered problems due to new more stringent restrictions on background location in recent versions of Android which took a significant time to be resolved or have not been fixed at all (see the plugin's issue list).
Original answer (11 Jun 2013)
The first thing to say is that creating a Phonegap app that receives location updates while running in the background is entirely possible, but not trivial. I've done it myself and released apps on both the Android and iOS platforms.
If you need accurate and regular position updates, I'd suggest using the GPS receiver on the target devices. In Phonegap, you can do this setting the "highAccuracy" flag when requesting position updates. The watchPosition() function will deliver new position information as and when the device receives updates from the GPS receiver, so you use it something like this:
navigator.geolocation.watchPosition(successCallback, errorCallback, {
enableHighAccuracy: true,
timeout: 10000,
maximumAge: 0
});
See the Phonegap geolocation API documentation for more details (note the permissions that are required to make this work on Android and iOS).
To keep your app running in the background on either Android or iOS you will need to setup their respective native development environments: Eclipse for Android, XCode for iOS. You will not be able to use Phonegap Build because custom settings are needed in both cases to make it work. See the Phonegap platform guides for how to do this.
To keep your app running in the background on Android, you either need to write a custom Android service, or you could do what I did and use a Phonegap plugin to acquire a "partial wakelock" (see here) to keep your app running in the background and receive position updates while the screen is off. Note that the original version of this plugin is out-of-date and doesn't work with more recent versions of Phonegap, and also doesn't support partial wakelocks. However, I've updated and extended it for my own use: you can find the source code for it in my answer to this question.
To keep your app running in the background on iOS, you need to do things slightly differently; you don't need a plugin, just a project setting.
You can either manually edit the project .plist and add the key “UIBackgroundModes” key with a value of “location” or, with your project open in XCode, add the "Required Background Modes" key with a value of "App registers for location updates". This will cause iOS to trigger the JS callback function you have registered with watchPosition() each time a location update is received. See here for more about iOS project keys and background modes.
Hope this helps!

Categories

Resources