Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
537 views
in Technique[技术] by (71.8m points)

objective c - Disable Warning Dialog if Bluetooth is powered off iOS

My ios application uses bluetooth to connect to an accessory. If Bluetooth is not enabled, a popup appears asking me to activate.

Bluetooth Popup

I noticed that popup appears every time I run the application.

My question is whether it is possible to display the popup once, ie only after the first launch (fitbit app do that. I also want to know if it is possible to change the language of the popup.

My application is for iOS7 and iOS6

If we can't change the langage, is there a way to disable this popup then i will develop my own view (popup) with localized system ?

Thanks you a lot !

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I got the following response from an apple developer : In iOS7, the CBCentralManagerOptionShowPowerAlertKey option lets you disable this alert.

If you have a CBCentralManager, then when you initialise it, you can use the method -[CBCentralManager initWithDelegate:queue:options]

Example:

In my .h file, I have a CBCentralManager * manager.

In my .m file:

NSDictionary *options = @{CBCentralManagerOptionShowPowerAlertKey: @NO};
    
_manager = [[CBCentralManager alloc] initWithDelegate:self queue:nil options:options];
    
[_manager scanForPeripheralsWithServices:nil options:options];

With this code, the warning no longer appears. I hope that helps!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...