iOS SDK Notification Demo

my IOS version is 7.0

Please refer this link. Or you can upgrade to iOS 8.x

Hi,
I want to disconnect the device after getting its Battery Status and MacID , I tried to use [self disconnectdevice] method but it did not worked. Can you advice?

You should try - (void)disconnectBeacon

You should open a new thread if the topic is not about the thread. It’s better for search index.

Thank you.

Hi,
I am using the class ABSelectDeviceViewController.h and .m same file from ur provided AprilBeaconDemo project, the same classes are copied and pasted over there in my project but

  • (void)beaconManager:(ABBeaconManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(ABBeaconRegion *)region
  • (void)beaconManager:(ABBeaconManager *)manager rangingBeaconsDidFailForRegion:(ABBeaconRegion *)region withError:(NSError *)error

above both methods are not getting called in my classes . what should I do?
I have assigned that class in story board and used transmitter class and all that but any thing didn’t made worked the delegate method calling.

Please advice as soon as possible.

Are you open location?

Apparently in iOS 8 SDK, requestAlwaysAuthorization (for background location) or requestWhenInUseAuthorization (location only when foreground) call on CLLocationManager is needed before starting location updates.

There also needs to be NSLocationAlwaysUsageDescription or NSLocationWhenInUseUsageDescription key in Info.plist with a message to be displayed in the prompt.

Okey you mean I have to take permission for accessing CLLocationManager in my application?

Yes, AprilBeaconSDK have obtained permission location.
You need to be NSLocationAlwaysUsageDescription or NSLocationWhenInUseUsageDescription key in Info.plist with a message to be displayed in the prompt.

okey thanks , it worked :smile:

I want to modify the minor value of the Beacon, in your demo you have used “doModify” function. I also used same but the minor value has not changed and it doesnt go to the completion block. do I need to do anything else except from calling doModify function?

First, you need to connect beacon.
[self.beacon connectToBeacon:ABConnectedReadStatedAllInfo].

Yes , I have done that but still i am not able to rewrite the value to my app

Can you paste your code?

  • (void)beaconDidConnected:(ABBeacon *)beacon withError:(NSError *)error
    this delegate method is called back?
  • (IBAction)btnSaveChangesClicked:(id)sender
    {
    NSInteger minor = [self.beacon.minor integerValue];

    if (minor==0) {
    [self doModify];
    } else {
    [self databaseUpdate];
    }

    // [self.navigationController popToRootViewControllerAnimated:YES];
    }

pragma mark Write Modified Values to the Beacons

  • (void)doModify
    {
    unsigned short minor = 1234;

    [self.beacon writeBeaconMinor:minor withCompletion:^(NSError *error) {
    NSLog(@“error = %@”, error);
    if (!error) {
    NSLog(@“Updation Successful”);
    [self.navigationController popToRootViewControllerAnimated:YES];
    }
    }];
    }

  • (void)beaconDidConnected:(ABBeacon *)beacon withError:(NSError *)error
    {
    if (error) {
    [self showAlertWithMessage:@“connect failed”];
    return;
    }
    NSLog(@“Firmware Revision: %@”, self.beacon.firmwareRevision);
    NSLog(@“Manufacturer Name: %@”, self.beacon.manufacturerName);
    NSLog(@“Model Number:%@”, self.beacon.modelNumber);

    _lblBatteryStatus.text = [NSString stringWithFormat:@"%@",self.beacon.batteryLevel];
    CBPeripheral *peripheral = beacon.peripheral;
    _txtDeviceName.text = peripheral.name;
    }

Yes, I find the reason,
Password authorization is required before you modify data. The default password
is ‘AprilBrother’.
It’s my code.

- (void)doMofiy {
    [self.beacon authBeaconWithPassword:@"AprilBrother" withCompletion:^(NSError *error) {
        if (!error) {
            [self.beacon writeBeaconMinor:minor withCompletion:^(NSError *error) {
                NSLog(@"error = %@", error);
                if (!error) {
                    NSLog(@"Updation Successful");
                    [self.navigationController popToRootViewControllerAnimated:YES];
                }
            }];
        }
    }];
}

or

- (void)doMofiy {
    [self.beacon writeBeaconInfoByPassword:@"AprilBrother"
                                      uuid:nil
                                     major:nil
                                     minor:minor
                                   txPower:nil
                               advInterval:nil
                             measuredPower:nil
                               newpassword:nil
                                 autoRestart:YES
                            withCompletion:^(NSError *error) {
                                NSLog(@"error = %@", error);
                                if (!error) {
                                    NSLog(@"pdate successful and restart device");
                                    [self.navigationController popViewControllerAnimated:YES];
                                }
                            }];
}

No, the same code you given is not modifying the Beacon minor value. Is there any other thing I need to do like taking permission or anything like that?

Modify failure? What is the error log Print?

okey, Now its done. I had some password issue that someone had modified the password. I again set it to AprilBrother and its working fine now.
Now, In my logs the value is displayed the 1234 which is my new minor value but in my range demo and in ur demo also, the minor value is still remaining 0 even if I got the log that value is successfully Updated.

Reboot the device after successfully modified .SDK update to the latest version.


you can try.
- (void)doMofiy {
    [self.beacon writeBeaconInfoByPassword:@"AprilBrother"
                                      uuid:nil
                                     major:nil
                                     minor:minor
                                   txPower:nil
                               advInterval:nil
                             measuredPower:nil
                               newpassword:nil
                                 autoRestart:YES
                            withCompletion:^(NSError *error) {
                                NSLog(@"error = %@", error);
                                if (!error) {
                                    NSLog(@"pdate successful and restart device");
                                    [self.navigationController popViewControllerAnimated:YES];
                                }
                            }];
}