반응형
iOS 15.5, Xcode 13.31, Swift 5, UIKit 환경에서 진행했습니다.
import UIKit
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
// Delegate 등록, 없으면 실행 X
UNUserNotificationCenter.current().delegate = self
return true
}
...
}
extension AppDelegate: UNUserNotificationCenterDelegate {
// foreground에서 알림 받기
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler([.list,.banner,.sound,.badge])
}
}
반응형
'iOS > 코드조각' 카테고리의 다른 글
[iOS, Swift] UIImagePickerController 이미지 선택 화면 띄우기 (0) | 2022.08.21 |
---|---|
[iOS, Swift] UIImage 그라데이션 그리기 (Gradient Image) (0) | 2022.08.21 |
[iOS, Swift] LocalNotification Badge 숫자 올리기 (0) | 2022.08.21 |
[iOS, Swift] LocalNotification 실행하기 (0) | 2022.08.21 |
[iOS, Swift] UILabel 밑줄긋기(Underline) (0) | 2022.08.20 |