Question

I am using Apple core bluetooth example .The peripheral is running in foreground in one iphone device.I am running cbcentral client application in one device.It is pairing well when both application in foreground condition.My need is when I run client cbcentral client in background , that delegate methods are not called in which I have mentioned local notification .the notification is not coming in background mode. Can I use NSOperation for running bluetooth delegate methods as we do NSUrlConnection? Will it work in latest iOS version? I checked it, but it is not working.

The code:

-(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];

        ..............
 }
Was it helpful?

Solution

I believe what you are looking for are the core bluetooth UIBackgroundModes here.

Also, you may want to look at Core Bluetooth and backgrounding: Detection of a device and triggering an action, even after being days in background mode? and What exactly can CoreBluetooth applications do whilst in the background?

The core bluetooth background modes work in iOS 5 or later.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top