0

I am trying to present an alertview for users on their first launch of the app to give them instruction on how to use it. I am using the pod 'SCAlertView'. When I place the code in the viewDidLoad() or ViewWillAppear() section the code is not executed, however when I test after permissions the code is executed. Here is the following code

override func viewDidLoad() {
    super.viewDidLoad()

    if  defaults.bool(forKey: "launchedBefore") == false{
        let alert = SCLAlertView()
        alert.showInfo("Welcome to \(appName)", subTitle: "Swipe up on the bottom green button to find all your tools to navigate the app!")
    }

does anyone have suggestions on how I can get this code to execute after permissions for camera & microphone?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Onicha21
  • 141
  • 2
  • 11

1 Answers1

0

Doing something right after the permissions request is quite tricky because the knowledge that permission has been granted may come to you asynchronously. My solution is to write a utility function that accepts a completion handler and then looks at the permission status, summoning the permission request alert if need be. It then calls that completion handler only if we have or are granted permission.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • Complete example code here: https://github.com/mattneub/Programming-iOS-Book-Examples/blob/master/bk2ch17p702takeAPicture/ch30p962takeAPicture/ViewController.swift – matt Jan 27 '17 at 19:23
  • Has @matt 's suggestion solved your specific question? If so mark as correct. If not, let us know and we'll try to help. – thecloud_of_unknowing Jan 28 '17 at 07:37