2016-05-18 9 views
2

Hat jemand erfolgreich ein iOS-Gerät verwendet, um mit cordova/phonegap als iBeacon zu werben? Ich habe es mit einer nativen Anwendung gemacht (airLocate ist eine nette Demo-App, um genau das zu tun). Was ich suche ist Werbung mit einem phonegap/cordova Plugin.iOS - Werben Sie als iBeacon mit Phonegap

Ich habe das folgende Plugin: https://github.com/petermetz/cordova-plugin-ibeacon Mit diesem Plugin habe ich für Beacons erfolgreich überwacht, für Beacons erfolgreich, aber ich bin nicht in der Lage zu werben. Ich habe den folgenden Code (von dieser Website) verwendet:

var uuid = '00000000-0000-0000-0000-000000000000'; 
var identifier = 'advertisedBeacon'; 
var minor = 2000; 
var major = 5; 
var beaconRegion = new cordova.plugins.locationManager.BeaconRegion(identifier, uuid, major, minor); 

// The Delegate is optional 
var delegate = new cordova.plugins.locationManager.Delegate(); 

// Event when advertising starts (there may be a short delay after the request) 
// The property 'region' provides details of the broadcasting Beacon 
delegate.peripheralManagerDidStartAdvertising = function(pluginResult) { 
    console.log('peripheralManagerDidStartAdvertising: '+ JSON.stringify(pluginResult.region)); 
}; 
// Event when bluetooth transmission state changes 
// If 'state' is not set to BluetoothManagerStatePoweredOn when advertising cannot start 
delegate.peripheralManagerDidUpdateState = function(pluginResult) { 
    console.log('peripheralManagerDidUpdateState: '+ pluginResult.state); 
}; 

cordova.plugins.locationManager.setDelegate(delegate); 

// Verify the platform supports transmitting as a beacon 
cordova.plugins.locationManager.isAdvertisingAvailable() 
    .then(function(isSupported){ 

     if (isSupported) { 
      cordova.plugins.locationManager.startAdvertising(beaconRegion) 
       .fail(console.error) 
       .done(); 
     } else { 
      console.log("Advertising not supported"); 
     } 
    }) 
    .fail(function(e) { console.error(e); }) 
    .done(); 

Dieser Code wird erfolgreich ausgeführt, aber es werben nicht. Ich habe einen Beacon-Scanner benutzt, aber er hebt ihn nicht auf. Ich betreibe den Code zu überprüfen, ob es sich um Werbung, aber es kommt immer wieder falsch:

cordova.plugins.locationManager.isAdvertising() 
.then(function(isAdvertising){ 
    console.log("isAdvertising: " + isAdvertising); 
}) 
.fail(function(e) { console.error(e); }) 
.done(); 

Ich habe auch für die Erlaubnis von dem Benutzer über das folgende Verfahren gestellt:

cordova.plugins.locationManager.requestWhenInUseAuthorization(); 

Also, hat jemand getan das erfolgreich? Ich habe keine Ideen mehr und hoffe, dass jemand da draußen es getan hat und mir zumindest sagen kann, dass es (relativ einfach) möglich ist. :)

Danke!

Antwort

2

So bekam ich endlich die Antwort von jemandem auf ibeacon Plugin-Probleme Abschnitt. Sie können die Antwort hier sehen - ein dickes Lob für die Antwort auf cgewecke:

https://github.com/petermetz/cordova-plugin-ibeacon/issues/231

Aber im Grunde, müssen Sie „Location Updates“ in Xcode ermöglichen (nachdem Sie es mit cordova gebaut haben). Gehen Sie zu dem Projekt (wo die allgemeinen Einstellungen sind), dann gehen Sie zu Fähigkeiten-> Hintergrund-Modi-> klicken Sie auf "Location Updates" ...