を入力して終了時間ビーコンでの待ち時間を減らすために: -どのように私が何をしたか
私はジンバルビーコンを使用して「角度JS +イオン+コルドバ」を用いたハイブリッドアプリケーションを作成しています。私のアプリケーションはうまくいきますが、ビーコンの入力と終了は、フォアグラウンドとバックグラウンドの両方で時間がかかりすぎます。 ?どのように私はこの問題を解決することができ、私は以下の私のコードスニペットを添付しています:
ステップ: -を
まず私はコルドバ
私の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は、スニペット: - 私たちは、特にdidExitRegionに関して、ネイティブiBeacon領域の機能と同様の動作を気づいた
-(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];
}];
}