I want to trigger iOS7 to ask users permission to use Bluetooth and Twitter account

别来无恙 提交于 2019-12-01 09:08:25
allprog

Only the peripheral role needs user permission to run. The central can do whatever it wants to. Simply instantiate a CBPeripheralManager when you want the user to give permission and it will trigger the dialog.

pmanager = [[CBPeripheralManager alloc] initWithDelegate:self queue:nil];

Then you use the peripheralManagerDidUpdateState: delegate method to get informed about the user's decision. You needn't set the bluetooth-peripheral backgrounding mode in the plist if your app does not operate in the background.

Keep in mind that the dialog will be popped only once during the lifetime of the application and the setting won't be reset when the app is deleted and reinstalled.

Note also that in light of this behavior, the

The only one reference I can find is that by having a plist key for bluetooth-peripheral the user will be prompted automagically on app launch.

Is not true.

For the twitter part. I haven't tried to use that API yet but found several answers that suggest authorization is either handled automatically for you or iOS will ask only the first time.

To test the popup questions you should manually reset the settings in
Settings->General->Reset->Reset Location & Privacy

Just a small addition: best practices for asking for user permission

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!