[ad_1]
I’ve code like this for the permission handler:
func authorizeMediaLibrary(forStatus standing: MPMediaLibraryAuthorizationStatus) -> Void{
swap standing {
case .licensed:
self.initializeMedia()
case .denied:
guard let settingUrl = URL(string: UIApplication.openSettingsURLString) else {return}
if UIApplication.shared.canOpenURL(settingUrl) {
UIApplication.shared.open(settingUrl) { success in}
}
case .notDetermined:
MPMediaLibrary.requestAuthorization { stat -> Void in
if stat == .licensed {
self.media.getMediaQueryCollection()
self.allMediaItems = self.media.getMPMediaItemCollection()
}
}
default:
break
}
}
I’ve even tried utilizing completion handler like this:
func getAuthrization(completionHandler:@escaping (Bool) -> Void) {
if MPMediaLibrary.authorizationStatus() == .licensed {
completionHandler(true)
} else {
MPMediaLibrary.requestAuthorization() { completionHandler($0 == .licensed) }
}
}
However each of them should not serving to me, the popup will show, however after accepted, it’s not calling the callback and it’s not refreshing my view to populate the info.
I do know it’s about refreshing my view from what i perceive as a result of when i run it once more i get the end result and the permission standing is modified to licensed.
[ad_2]
