我做了什么:-
我正在使用Gimbal 信标并使用"angular js + ionic + cordova"创建一个混合应用程序。我的应用程序运行良好,但信标进入和退出在前台和后台都需要很长时间。我该如何解决这个问题?我在下面附上了我的代码片段:
脚步:-
首先,我使用科尔多瓦从角度呼叫代表
我的 iOS 委托方法被调用但经过长时间的延迟
didEnterRegion - 10 秒后调用
didExitRegion - 在 20-30 秒后调用
我已设置云台传输间隔 (MS) - 100
我的片段:-
Angular-js 片段:
// 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片段:-
-(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];
}];
}