0

Will restore state delegate method is not called when system kills the app in background i am using the below code in button action to check system kill

kill(getpid(), SIGKILL);

When i kill the app using this function but willrestore state delegate method is not called in my application i am using the below code to connect to the central manager.

 dispatch_queue_t centralQueue = dispatch_queue_create("mycentral", DISPATCH_QUEUE_SERIAL);// or however you want to create your dispatch_queue_t
NSDictionary *options = @{
                          CBCentralManagerOptionRestoreIdentifierKey:@"restoremyapp",
                          CBCentralManagerOptionShowPowerAlertKey:[NSNumber numberWithBool:YES],
                          };

self.CM = [[CBCentralManager alloc] initWithDelegate:self queue:centralQueue options:options];

i have searched stack overflow and in some link they said if we use dispatch queue it will works but for me its not working.

ashok vadivelu
  • 493
  • 5
  • 12
  • possible duplicate of [CoreBluetooth state preservation issue: willRestoreState not called in iOS 7.1](http://stackoverflow.com/questions/22412376/corebluetooth-state-preservation-issue-willrestorestate-not-called-in-ios-7-1) – Deepesh Jul 23 '14 at 08:05
  • Thanks i got a solution ,you need to use shouldrestorestate application method in appdelagate and always return yes to the function then it work. – ashok vadivelu Jul 26 '14 at 14:25
  • I have the same problem, could you say more information about your shouldrestorate application method? – user3745888 Feb 12 '17 at 22:15
  • To call "willrestorestate" method in corebluetooth .we need to use shouldRestoreApplicationState method in app delegate and we need to return always yes to that method. E.g : -(BOOL)application:(UIApplication *)application shouldRestoreApplicationState:(NSCoder *)coder { return YES; } – ashok vadivelu Feb 14 '17 at 13:23

1 Answers1

0

This might best be marked as a duplicate of other questions on the matter.

In short, it appears as though you're out of luck (we found the same thing) — evidence suggests that this functionality will help you restore connections to bluetooth devices or will ensure that interrupted sightings of peripherals are still sent to you, but will not allow scanning to continue in the background after your app is killed.

It looks as though this is just not supported.

Community
  • 1
  • 1
MarcWan
  • 2,943
  • 3
  • 28
  • 41