UNUserNotificationCenter.current().getNotificationSettings { (settings) in
guard settings.authorizationStatus == .authorized else{
let alert = UIAlertController(title: "알림", message: "기기 내 [설정]>[앱 이름]>[알림]에서\n알림을 허용해주세요.", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "취소", style: .cancel, handler: nil))
alert.addAction(UIAlertAction(title: "확인", style: .default, handler: { _ in
DispatchQueue.main.async {
let settingUrl = NSURL(string: UIApplication.openSettingsURLString)!
if UIApplication.shared.canOpenURL(settingUrl as URL){
UIApplication.shared.open(settingUrl as URL, options: self.convertToUIApplicationOpenExternalURLOptionsKeyDictionary([:]), completionHandler: { (istrue) in
})
}
}
}))
self.present(alert, animated: true)
return
}
}
func convertToUIApplicationOpenExternalURLOptionsKeyDictionary(_ input: [String: Any]) -> [UIApplication.OpenExternalURLOptionsKey: Any] {
return Dictionary(uniqueKeysWithValues: input.map { key, value in (UIApplication.OpenExternalURLOptionsKey(rawValue: key), value)})
}
'개발 > 아이오에스' 카테고리의 다른 글
ios] leadingAnchor(trailingAnchor)와 leftAnchor(rightAnchor) 차이 (0) | 2021.09.17 |
---|---|
ios] 에러해결 - command phasescriptexecution failed with a nonzero exit code (0) | 2021.09.07 |
swift] 앱 최초 실행 시 push 설정 1회성 처리 UserDefaults (0) | 2021.08.17 |
swift] UIView에 background에 image 파일 적용하기 (0) | 2021.08.05 |
swift] scrollview안에서 uibutton - 액션이(touchupInside) 먹히지 않음 (0) | 2021.07.29 |