Skip to content

Permission bar

Your app should ask the user to grant location permission, notifications and to turn the bluetooth on (if your use case implies beacons).

If you want to show a persistent bar that alert the user if any permission is missing, this library provides a convenient NITPermissionsView. This bar visually specifies what is missing and will automatically hide itself when every permission has been granted.

All missing

Almost permission

The bar can be allocated by code or added using the Interface Builder.

override func viewDidLoad() {

    let permissionView = NITPermissionsView.init(frame:

        permissionView.leftAnchor.constraint(equalTo: self.view.leftAnchor),
        permissionView.rightAnchor.constraint(equalTo: self.view.rightAnchor),
        permissionView.topAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.topAnchor),
- (void)viewDidLoad {
    [super viewDidLoad];

    NITPermissionsView *permissionView = [[NITPermissionsView alloc] initWithFrame:CGRectZero];
    [self.view addSubview:permissionView];

    [permissionView.leftAnchor constraintEqualToAnchor:self.view.leftAnchor].active = TRUE;
    [permissionView.rightAnchor constraintEqualToAnchor:self.view.rightAnchor].active = TRUE;
    [permissionView.topAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.topAnchor].active = TRUE;

Interface builder instructions

Step 1: add an empty UIView in your view controller

The view must have an height of 50 points but any width, position it according to your UI


Step 2: configure a custom class for the view

Use class NITPermissionsView and Module NearUIBinding


Step 3: customize the look


Not all properties can be edited by IB, plese refer to the main source code for the complete list of customizations variables.

Step 4: set-up constraints

Anchor the view to the left, right, and top sides


Step 5: configure the intrinsic size

IB requires an height to properly resolve all constraints; do not add an height constraints or the auto-hide functionality may stop working instead configure the view as a placeholder of intrinsic size with height 50



The bar can be customized to show only a subset of permissions

let permissionView = NITPermissionsView.init(frame:
permissionView.permissionsRequired = .locationAndNotifications
NITPermissionsView *vc = [[NITPermissionsView alloc] initWithFrame:CGRectZero];
vc.permissionsRequired = NITPermissionsViewPermissionsLocationAndNotifications;

When asking for location permission, you can customize the minimum grant level (.always or .whenInUse) for the permission to be considered granted. This will influence both the permission bar and permission dialog behavior. The default value is .always.

permissionView.locationType = .always
permissionView.locationType = NITPermissionsLocationTypeAlways;

While the default behavior on button tap is to show the default NITPermissionViewController, a custom callback can be provided:

permissionView.callbackOnPermissions = { (view) in
    let vc = NITPermissionsViewController()
    vc.autoCloseDialog = .on
    vc.delegate = view { (dialogController: NITDialogController) in
        dialogController.backgroundStyle = .blur
permissionView.callbackOnPermissions = ^(NITPermissionsView * _Nonnull view) {
    NITPermissionsViewController *vc = [[NITPermissionsViewController alloc] init];
    vc.autoCloseDialog = NITPermissionsAutoCloseDialogOn;
    vc.delegate = view;
    [vc showWithConfigureDialog:^(NITDialogController * _Nonnull dialogController) {
        dialogController.backgroundStyle = CFAlertControllerBackgroundStyleBlur;

More UI customizations

permissionViewA.backgroundColor = .gray
permissionViewA.messageColor = .black
permissionViewA.messageFont = UIFont.boldSystemFont(ofSize: 15.0)
permissionViewA.missingBluetoothIcon = UIImage(named: "missingBluetooth")
permissionViewA.missingLocationIcon = UIImage(named: "missingLocation")
permissionViewA.missingNotificationIcon = UIImage(named: "missingNotification")
permissionViewA.sadColor =
permissionViewA.worriedColor = UIColor.yellow
permissionViewA.sadImage = UIImage(named: "sadImage")
permissionViewA.worriedImage = UIImage(named: "worriedImage")
permissionView.backgroundColor = UIColor.grayColor;
permissionView.messageColor = UIColor.blackColor;
permissionView.messageFont = [UIFont boldSystemFontOfSize:15.0];
permissionView.missingBluetoothIcon = [UIImage imageNamed:@"missingBluetooth"];
permissionView.missingLocationIcon = [UIImage imageNamed:@"missingLocation"];
permissionView.missingNotificationIcon = [UIImage imageNamed:@"missingNotification"];
permissionView.sadColor = UIColor.redColor;
permissionView.worriedColor = UIColor.yellowColor;
permissionView.sadImage = [UIImage imageNamed:@"sadImage"];
permissionView.worriedImage = [UIImage imageNamed:@"worriedImage"];