Estimote iBeacon error: Service not available

Estimote iBeacon error: Service not available

我正在研究 Estimote iBeacon 项目,它将显示 iBeacon 的属性。现在,我的应用程序显示了 iBeacon 的许多属性,但我想更改 iBeacon 的主要值和次要值。当我更改 iBeacon 的 major 或 minor 值时,出现错误消息,即 "Service not available."。这是我的代码,有人可以帮助我吗?

谢谢。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    switch (indexPath.row)
    {
        case 1:
        {
            UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Enter Major Value", @"") message:nil delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", @"") otherButtonTitles:NSLocalizedString(@"Write", @""), nil];
            alertView.alertViewStyle = UIAlertViewStylePlainTextInput;
            UITextField *textField = [alertView textFieldAtIndex:0];
            textField.text = [NSString stringWithFormat:@"%u", [beacon.major unsignedShortValue]];
            textField.clearButtonMode = UITextFieldViewModeWhileEditing;
            textField.keyboardType = UIKeyboardTypeNumberPad;
            alertView.tag = 50;
            [alertView show];
        }
            break;
}

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    switch (alertView.tag)
    {
        case 50:
            switch (buttonIndex)
        {
            case 1:
                [self writeMajor:[[alertView textFieldAtIndex:0].text integerValue] completion:^(unsigned short value, NSError *error)
                 {

                 }
                 ];
}

- (void)writeMajor:(unsigned short)major completion:(ESTUnsignedShortCompletionBlock)completion
{
    [beacon writeMajor:major completion:^(unsigned short value, NSError *error)
     {
         if (error)
         {
             NSLog(@"%s: %@", __PRETTY_FUNCTION__, error);
             UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Could Not Write Major Value", @"") message:[error localizedDescription] delegate:nil cancelButtonTitle:NSLocalizedString(@"OK", @"") otherButtonTitles:nil];
             [alertView show];
         }
         else
         {

         }
     }];
}

为了能够修改信标的任何设置,您需要先连接到信标:

ESTBeacon connect

请注意,这是一个异步方法,您需要等到 ESTBeaconDelegatebeaconConnectionDidSucceeded: 方法被调用后才能开始写入信标。

此步骤的一个先决条件:使用 Estimote Beacons,只有信标所有者授权的应用程序才能连接到它。您使用 ESTConfig setupAppID:andAppToken:. The ID and token are created and retrieved from the Estimote Cloud web dashboard at http://cloud.estimote.com.

对应用程序进行身份验证