-
Notifications
You must be signed in to change notification settings - Fork 28
Description
I've been trying to use https://github.com/petermetz/cordova-plugin-ibeacon to add iBeacon support to one of my projects, but I ran into issues which I believe are caused by the DOM replacement of MeteorRider.
The iBeacon package provides a didRangeBeaconsInRegion method that should fire about every second. It uses uses a delegate pattern (https://github.com/petermetz/cordova-plugin-ibeacon/blob/master/www/LocationManager.js#L41), which for some reason will break after MeteorRider is initialised.
Here's a sample implementation:
delegate = new cordova.plugins.locationManager.Delegate().implement
didRangeBeaconsInRegion: (pluginResult) ->
console.log pluginResult
cordova.plugins.locationManager.setDelegate delegate
beaconRegion = new cordova.plugins.locationManager.BeaconRegion(identifier, uuid);
cordova.plugins.locationManager.startRangingBeaconsInRegion beaconRegion And here are a few scenarios I tried out, all including the startup.js script for Hot Code Push:
- Initialise
cordova.plugins.locationManager(iBeacon plugin) in meteor app onMetoer.startup. Result: No errors, but delegate callbacks are not fired. - Initialise the plugin in the Cordova project index.html before MeteorRider (within
onDeviceReady), init MR after a 3 secondsetTimeout. Result: plugin methods are fired successfully for 3 seconds, and then stop. - Don't init MR at all. Result: Plugin works as expected, but obviously Meteor doesn't load.
The strange thing is that in the first two scenarios, if I update the Meteor project to cause a hot code push, all of the delegate methods are fired as the project reloads -- they seemed to have queued up in the background, and I get the all of the previously expected logs flooding the console at once.
I eventually switched to packmeteor and had no issues, but I would prefer to use MeteorRider if this issue is resolved.
This may be too much of a fringe case to look into, but I figured I should flag it. If anyone has any potential solutions I'd be happy to try them out.
Cheers!