petermetz/cordova-plugin-ibeacon — pull request #19 by mrtree1 (2014-07-11 10:37:03+00:00)
Title: Android bug fix and stubs for advertising

Hi Peter,

There were a few minor bugs which have been fixed in Android including #18 on your issues list.

Additionally I've added some stubs for isAdvertising, startAdvertising, stopAdvertising. I've not done the iOS side except for empty methods, and on Android it returns meaningful error messages for the start/stop calls. I figured you knew what you wanted to do on iOS!

Additionally I added an isRegionTypeAvailable, as CircularRegions are currently not supported on the Android side. It also parses the region to ensure it's a valid region. I think it's important to have something like this cross-platform.

I have also added enableDebugNotifications/disableDebugNotifications to Android but it just stops logging for now, and doesn't attempt to push a local notification. I think on Android it would be more likely to be a toast message, which I may add next time I get some time.

Last point: you may want to edit the summary description of the project as it still says 'and later possibly Android' ;-)

I've verified what I've done works on iOS and Android with these simple tests returning expected results:

var latitude = 51.5072;
var longitude = -0.1275;
var radius = 200; // 200 meters of radius
var identifier = 'charingCrossRegion';
var circularRegion = new CircularRegion(identifier, latitude, longitude, radius);

var uuid = 'B7CFA126-510E-4E18-83AB-59F6780B3AF6';
var identifier = 'BeaconNextToTheHouse';
var major = 12345;
var beaconRegion = new BeaconRegion(identifier, uuid, major);

locationManager.isAdvertisingAvailable().then(function(isSupported) {
if (isSupported)
console.log('Advertising supported');
else
console.log('Advertising not supported');
}).fail(function(error){
console.log('Advertising check failed: ' + error);
});

locationManager.isRegionTypeAvailable(circularRegion).then(function(isSupported) {
if (isSupported)
console.log('CircularRegion supported');
else
console.log('CircularRegion not supported');
}).fail(function(error){
console.log(error);
});

locationManager.isRegionTypeAvailable(beaconRegion).then(function(isSupported) {
if (isSupported)
console.log('BeaconRegion supported');
else
console.log('BeaconRegion not supported');
}).fail(function(error){
console.log(error);
});

locationManager.startAdvertising(beaconRegion).then(function() {
console.log('Advertising started');
}).fail(function(error){
console.log(error);
});

locationManager.stopAdvertising().then(function() {
console.log('Advertising stopped');
}).fail(function(error){
console.log(error);
});

Cheers

Tree