Skip to main content

Add Permissons

Permissions are set to get control of your phone and access to your camera, photos, contact list, location, and phone storage. App permission requests pop up the first time an app needs access to data on your phone and are related to user privacy.

In Permissions, a helper class file is added under Utilities-> Permissions -> CameraPermissions.swift, likewise the same for other permissions.

Under info.Plist file all the required parameters for permissions are set.

The permission call setup is generated in View.swift file, as below is the example for Camera + Gallery permission.

CameraPermission.swift
Button(
action: {
CameraPermission.shared.request(result: { isGranted in
GalleryPermission.shared.request(result: { isGranted in
if !isGranted {
GalleryPermission.shared.onDeniedOrRestricted()
}
})
})
},
label: {
Text(StringConstants.kLblCameraGallery)
}
)
ContactPermission.swift
Button(
action: {
ContactPermission.shared.request(result: { isGranted in
if !isGranted {
ContactPermission.shared.onDeniedOrRestricted()
}
})
},
label: {
Text(StringConstants.kLblContact)
}
)
LocationPermission.swift

Button(
action: {
let location = LocationPermission()
location.request()
location.result = { isGranted in
if !isGranted {
location.onDeniedOrRestricted()
}
}
},
label: {
Text(StringConstants.kLblLocation)
}
)


Got a question? Ask here.