私は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];
..............
}