Turn on Bluetooth to allow "XXX" to connect to the accessory

Source: Internet
Author: User

All along, when using someone else's app, you will often see a "turn on Bluetooth to allow" xxx "connect to Accessories" pop-up box (pictured below),


Click the Settings button to jump to the setting interface of the iOS system.

Then I finally understood what was going on. It was a hint from the iOS system, like using a system album, prompting the user.

Here's how it's implemented.

With the use of Bluetooth, it is necessary to corebluetooth.framework, that is, to add the framework to the project. Then join the Cbcentralmanager class and build delegate.

. h file

#import <CoreBluetooth/CoreBluetooth.h>

@interface mainviewcontroller:uiviewcontroller<cbcentralmanagerdelegate> {

}

@property (nonatomic, strong) Cbcentralmanager *manager;

@end


. m file

@implementation Mainviewcontroller

-(void) Viewdidload {

_manager = [[Cbcentralmanager alloc] initwithdelegate:self Queue:nil]; The point here is to establish a delegate

}

Start viewing the service, Bluetooth turned on

-(void) Centralmanagerdidupdatestate: (Cbcentralmanager *) Central

{

Switch (central.state) {

Case Cbcentralmanagerstatepoweredon:

NSLog (@ "Bluetooth is turned on, please scan peripherals");

Break

Case Cbcentralmanagerstatepoweredoff:

NSLog (@ "Bluetooth off ...");

Break

Default

Break

}

}

In this way, when Bluetooth is off in the setting interface, it will be prompted with the diagram, click "Settings" in the pop-up box and jump to the Bluetooth interface.

Attention:

Be sure if Bluetooth is turned off.


In the same vein, the WiFi interface should be the same principle, but it is unclear which framework is used.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.