Skip to content

Permissions dialog

If your app integrates NearIT services, you surely want your user to grant your app location permissions. NearIT supports the use of Beacon technology, so bluetooth could also be a requirement for your app.

Basic example

If you want your app to ask user for both location and notification permissions, use the following code:

let controller = NITPermissionsViewController()
controller.delegate = self
controller.show()
NITPermissionsViewController *controller = [[NITPermissionsViewController alloc] init];
controller.delegate = self;
[controller show];

NearIT-UI permissions

You can check the request results using the delegate protocol NITPermissionsViewControllerDelegate

optional func dialogClosed(locationGranted: Bool, notificationsGranted: Bool)
- (void)dialogClosedWithLocationGranted:(BOOL)locationGranted notificationsGranted:(BOOL)notificationsGranted;

Note about Bluetooth

NearIT supports the use of Beacon technology, but bluetooth on iOS is a global setting and therefore can not be expicitly requested by an app.

Advanced examples

You can customize the permissions request controller to request location or notifications only.

let vc = NITPermissionsViewController()
vc.type = .locationOnly
vc.locationType = .always
vc.show()
NITPermissionsViewController *vc = [[NITPermissionsViewController alloc] init];
vc.type = NITPermissionsTypeLocationOnly;
vc.locationType = NITPermissionsLocationTypeAlways;
[vc show];

UI Customization

The UI can be fully customized.

let vc = NITPermissionsViewController()
vc.headerImage = UIImage(named: "header")
vc.textColor = .black
vc.isEnableTapToClose = true
vc.checkedButtonColor = UIColor.blue
vc.uncheckedButtonColor = UIColor.brown
vc.locationText = "Turn on location"
vc.notificationsText = "Turn on notications"
vc.explainText = "We'll notify you of content that's interesting"
vc.locationInUse = "only in use"
vc.locationAlways = "always"
vc.locationNever = "never"
vc.happyImage = UIImage(named: "happy")
vc.worriedImage = UIImage(named: "worried")
vc.sadImage = UIImage(named: "sad")
vc.notificationsIcon = UIImage(named: "notifications")
vc.locationIcon = UIImage(named: "location")
vc.autoCloseDialog = .on
vc.show { (dialogController: NITDialogController) in
    dialogController.backgroundStyle = .blur
}
NITPermissionsViewController *vc = [[NITPermissionsViewController alloc] init];
vc.headerImage = [UIImage imageNamed:@"header"];
vc.textColor = [UIColor blackColor];
vc.isEnableTapToClose = TRUE;
vc.checkedButtonColor = [UIColor blue];
vc.uncheckedButtonColor = [UIColor brown];
vc.locationText = @"Turn on location";
vc.notificationsText = @"Turn on notications";
vc.explainText = @"We'll notify you of content that's interesting";
vc.locationInUse = @"only in use";
vc.locationAlways = @"always";
vc.locationNever = @"never";
vc.happyImage = [UIImage imageNamed:@"happy"];
vc.worriedImage = [UIImage imageNamed:@"worried"];
vc.sadImage = [UIImage imageNamed:@"sad"];
vc.notificationsIcon = [UIImage imageNamed:@"notifications"];
vc.locationIcon = [UIImage imageNamed:@"location"];
vc.autoCloseDialog = NITPermissionsAutoCloseDialogOn;
[vc showWithConfigureDialog:^(NITDialogController *dialogController) {
    dialogController.backgroundStyle = CFAlertControllerBackgroundStyleBlur;
}];