:次に
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
// Start up the CBPeripheralManager
_peripheralManager = [[CBPeripheralManager alloc] initWithDelegate:self queue:nil];
// Start up the CBCentralManager
// And somewhere to store the incoming data
_data = [[NSMutableData alloc] init];
}
/** Required protocol method. A full app should take care of all the possible states,
* but we're just waiting for to know when the CBPeripheralManager is ready
*/
- (void)peripheralManagerDidUpdateState:(CBPeripheralManager *)peripheral {
if (peripheral.state == CBPeripheralManagerStatePoweredOn) {
// We're in CBPeripheralManagerStatePoweredOn state...
NSLog(@"self.peripheralManager powered on.");
// ... so build our service.
// Then the service
CBMutableService *transferService = [[CBMutableService alloc] initWithType:[CBUUID UUIDWithString:TRANSFER_SERVICE_UUID] primary:YES];
// And add it to the peripheral manager
[self.peripheralManager addService:transferService];
}
}
は後で私がIBActionボタンで広告掲載を開始するために私の周辺を呼び出しますこれらの警告を防止する。あとで不定期に宣伝を呼び出すだけなので、peripheralManagerに電源が供給されていて準備ができていることを確認する必要があります。
- (IBAction)advertise:(id)sender
{
if(self.peripheralManager.state == CBPeripheralManagerStatePoweredOn)
{
//Now you can call advertise
}
}
正確なエラーは何ですか?デバッガの – Undo
がBluetooth_RSSItest_iPad [2235:60b] CoreBluetooth [WARNING]の電源が入っていません。 –
ian
デバイス設定でBluetoothが鳴っていますか? –