2

私はAppleコアBluetoothの例を使用しています.周辺機器は1つのiPhoneデバイスでフォアグラウンドで実行されています.1つのデバイスでcbcentralクライアントアプリケーションを実行しています.両方のアプリケーションがフォアグラウンド状態のときにうまくペアリングされています.クライアントcbcentralクライアントをbackground 、ローカル通知について言及したデリゲートメソッドは呼び出されません。通知はバックグラウンドモードでは来ません。NSUrlConnection と同じように、Bluetooth デリゲート メソッドを実行するために NSOperation を使用できますか? 最新の iOS バージョンで動作しますか? 確認しましたが、動作していません。

コード:

-(void) peripheral:(CBPeripheral *)aPeripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error  
 {

          ..............
          ...............
         UILocalNotification *localNotif = [[UILocalNotification alloc] init];

         localNotif.fireDate = [itemDate dateByAddingTimeInterval:-(minutesBefore*60)];

         localNotif.timeZone = [NSTimeZone defaultTimeZone];

         localNotif.alertBody =  @"hi";

         localNotif.alertAction = NSLocalizedString(@"View Details", nil);

         localNotif.soundName = UILocalNotificationDefaultSoundName;


         [[UIApplication sharedApplication] scheduleLocalNotification:localNotif];

        ..............
 }
4

1 に答える 1

1

UIBackgroundModes あなたが探しているのは、ここのコア bluetooth だと思います。

また、Core Bluetooth and backgrounding: Detection of a device and triggering an action, even after days in background mode? も参照してください。 CoreBluetooth アプリケーションは、バックグラウンドで正確に何を行うことができますか?

コア Bluetooth バックグラウンド モードは、iOS 5 以降で動作します。

于 2013-08-07T19:36:40.873 に答える