ios - Core Bluetooth will not restore when coming back to view controller -
i'm working on bluetooth heart rate monitor , followed code https://www.raywenderlich.com/52080/introduction-core-bluetooth-building-heart-rate-monitor
i have app running great. within same app have several other view controllers other things login page , simple "about us" page. issue have when coming view controller, containing actual heart rate monitor, monitor sits @ 0 , not update values.
i have restore code , delegates in place:
-(void)centralmanager:(cbcentralmanager *)central willrestorestate:(nsdictionary *)state { nslog(@"willrestorestate called"); self.polarh7hrmperipheral = [state[cbcentralmanagerrestoredstateperipheralskey] firstitem]; self.polarh7hrmperipheral.delegate = self; }
central manager declared so:
cbcentralmanager *centralmanager =[[cbcentralmanager alloc] initwithdelegate:self queue:nil options:@{ cbcentralmanageroptionrestoreidentifierkey:@"mycentralmanageridentifier" }];
when coming view controller, noticed willrestorestate
not being called.
i'm lost next. can out? in advance.
if object of cbcentralmanager
gets deallocated methods not work delegate methods of cbcentralmanager
.
to make work have reinitialize object of cbcentralmanager
, heart rate.
like this
self.hrcbmanager = [[cbcentralmanager alloc] initwithdelegate:self queue:nil];
Comments
Post a Comment