petermetz / cordova-plugin-ibeacon

An iBeacon plugin for Phonegap / Cordova 3.x and upwards. Supports both iOS and Android (contributions are welcome)
Apache License 2.0
726 stars 373 forks source link

Start advertising device as an iBeacon (iOS only) #137

Open dev-npm opened 9 years ago

dev-npm commented 9 years ago

Start advertising device as an iBeacon (iOS only) ... If i use this below code to make my phone act as a Ibeacon then can i send any information also meaning can I broadcast any data packets with some information . if yes , can any one please advice how ?? thanks !!!

Start advertising device as an iBeacon (iOS only)

var uuid = 'DA5336AE-2042-453A-A57F-F80DD34DFCD9'; 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(conole.error)
            .done();
    } else {
        console.log("Advertising not supported");
    }
})
.fail(console.error)
.done();
prakeshcdn commented 4 years ago

my iphone will work as a ibeacon ?