cordova/phonegapを使用してiOSデバイスをiBeaconとして宣伝するのに成功した人はいますか?私はネイティブのアプリケーションでそれをやった(airLocateはちょうどそれをする素晴らしいデモアプリケーションです)。私が探しているのは、phonegap/cordovaプラグインを使って宣伝することです。iOS - Phonegapを使用してiBeaconとして広告する
私は次のプラグインを持っています:https://github.com/petermetz/cordova-plugin-ibeacon このプラグインを使用して、ビーコンを正常に監視し、正常にビーコンを送信しましたが、広告できません。私はそのサイトから次のコードを使用しました:
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();
このコードは正常に実行されますが、アドバタイズされません。私はビーコンスキャナを使用しましたが、それはそれを拾いません。私はそれが広告だかどうかを確認するためのコードを実行されますが、それは常にfalse戻ってくる:
cordova.plugins.locationManager.isAdvertising()
.then(function(isAdvertising){
console.log("isAdvertising: " + isAdvertising);
})
.fail(function(e) { console.error(e); })
.done();
私はまた、次のような方法を介してユーザからの許可を求めています、
cordova.plugins.locationManager.requestWhenInUseAuthorization();
だから、誰が行っていますこれは正常にですか?私はアイデアがなく、そこにいる誰かがそれをして、それが可能であることを(少なくとも比較的簡単に)知らせることを望んでいます。 :)
ありがとう!