evo-demos
evo-demos copied to clipboard
How to decrease latency in Beacon Entering and Exit time
What I did:-
I am using Gimbal beacons and creating a hybrid application using "angular js + ionic + cordova". My application is working good but beacon Entering and Exit takes too long, both in foreground and background. How can I resolve the issue?I am attaching my code snippet below:
Steps:-
First I am calling the delegates from angular using cordova My iOS delegate methods gets called but after a long delay didEnterRegion - called after 10 secs
didExitRegion - called after 20-30 secs
I have set Gimbal TRANSMISSION INTERVAL (MS) - 100
My snippet:-
Angular-js snippet:
// Request permission from user to access location info.
cordova.plugins.locationManager.requestAlwaysAuthorization();
// Create delegate object that holds beacon callback functions.
var delegate = new cordova.plugins.locationManager.Delegate();
console.log(delegate)
cordova.plugins.locationManager.setDelegate(delegate);
// Set delegate functions.
delegate.didDetermineStateForRegion = onDidDetermineStateForRegion;
delegate.didRangeBeaconsInRegion = onDidRangeBeaconsInRegion;
delegate.didEnterRegion = onDidRangeBeaconsInRegion
iOS snippet:-
-(void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region {
[self.queue addOperationWithBlock:^{
[self _handleCallSafely:^CDVPluginResult *(CDVInvokedUrlCommand *command) {
[[self getLogger] debugLog:@"didEnterRegion: %@", region.identifier];
[[self getLogger] debugNotification:@"didEnterRegion: %@", region.identifier];
NSMutableDictionary* dict = [NSMutableDictionary new];
[dict setObject:[self jsCallbackNameForSelector:(_cmd)] forKey:@"eventType"];
[dict setObject:[self mapOfRegion:region] forKey:@"region"];
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dict];
[pluginResult setKeepCallbackAsBool:YES];
return pluginResult;
} :nil :NO :self.delegateCallbackId];
}];
}
-(void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region {
[self.queue addOperationWithBlock:^{
[self _handleCallSafely:^CDVPluginResult *(CDVInvokedUrlCommand *command) {
[[self getLogger] debugLog:@"didExitRegion: %@", region.identifier];
[[self getLogger] debugNotification:@"didExitRegion: %@", region.identifier];
NSMutableDictionary* dict = [NSMutableDictionary new];
[dict setObject:[self jsCallbackNameForSelector:(_cmd)] forKey:@"eventType"];
[dict setObject:[self mapOfRegion:region] forKey:@"region"];
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dict];
[pluginResult setKeepCallbackAsBool:YES];
return pluginResult;
} :nil :NO :self.delegateCallbackId];
}];
}