/ Alerts

App Usage Permission Alert to comply with the new App Store Guidelines

App Usage Permission Alert to comply with the new App Store Guidelines

Send App Usage Permission

Inspired WWDC App I made class to help developers & community save time and comply with the App Store Guidelines.

Installation

Just drag and drop it to your project.

Usage

Display Alert

Put this code in viewDidAppear

  override func viewDidAppear(_ animated: Bool) {
        if !AppUsagePermission.isAsked(){
            AppUsagePermission.displayAlert(viewController: self, completionHandler: nil)
        }

    }

сompletionHandler

AppUsagePermission.displayAlert(viewController: self, completionHandler: { result in
                if (result == PermissionStatus.allowed){
                    print("User allowed data usage")
                } else if (result == PermissionStatus.denied){
                    print("User denied data usage")
                }
            })

Get permission statuses

switch(AppUsagePermission.status()){
        case .allowed:
           print("Permission given")
        case .denied:
            print("Permission denied")
        case .notAsked:
             print("Data usage permission is not yet requested")
        case .undefined:
            print("Something went wrong")
        }
enum PermissionStatus{
   case allowed
   case denied
   case notAsked
   case undefined
}

Quck access functions

 if AppUsagePermission.isAsked(){
   print("Dalogue has been already presented to user")
 }
  if AppUsagePermission.isAllowed(){
    print("Send App Data Usage is allowed")
  }

Reset saved value

   AppUsagePermission.resetValue()

GitHub