objective c - iOS background bluetooth on phone startup -
i'm developing iphone app user can wake bluetooth le peripheral. uses bluetooth-central
ui background mode, , seems working well.
the next code works great when app launched user tapping icon:
// called appdelegate’s didfinishlaunchingwithoptions: // next phone call result in callback centralmanagerdidupdatestate mycentral=[[cbcentralmanager alloc]initwithdelegate:self queue:nil]; ... //cbcentralmanager delegate methods -(void)centralmanagerdidupdatestate:(cbcentralmanager *)central { nslog(@"centralmanagerdidupdatestate called"); if (central.state != cbcentralmanagerstatepoweredon) { // error handling } else { nslog(@"scanning peripherals"); //following phone call result in callback centralmanager diddiscoverperipheral ... nsdictionary *options = [nsdictionary dictionarywithobjectsandkeys:[nsnumber numberwithbool:yes], cbcentralmanagerscanoptionallowduplicateskey, nil]; [central scanforperipheralswithservices:@[desired_service_uuid] options:options]; } }
however, don't want user have tap icon. want app spring life in background, , summoned foreground btle peripheral. used voip background mode launch app in background, , in fact launch background mode. however, centralmanagerdidupdatestate:
never called until user brings app foreground.
how can activate background bluetooth functionality on startup?
i using ios 8.1, believe applies ios 7 well.
ios objective-c bluetooth-lowenergy core-bluetooth
No comments:
Post a Comment