본문 바로가기

SWIFT30

Swift 푸시(FCM) 알림 클릭 시 원하는 웹뷰 페이지로 이동하기 AppDelegate에서 extension AppDelegate : UNUserNotificationCenterDelegate { func userNotificationCenter(_ center: UNUserNotificationCenter,didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { } } 해당 함수를 사용이 가능 합니다. 해당 함수는 푸시를 클릭 했을 시 호출됩니다. 그리고 이제 웹서버에서 보내준 데이터를 받아야 하는데요. let userInfo = response.notification.request.content.userInfo var link .. 2021. 12. 8.
Swift 로컬에서 Notification(알림) 구현하기. import UserNotifications 우선 이렇게 임포트 하나 해주시구요. let userNotificationCenter = UNUserNotificationCenter.current() 클래스 딴 전역으로 하나 선언해줍니다. func callNotification(seconds: Double, title : String, body : String) { let notificationContent = UNMutableNotificationContent() notificationContent.title = title notificationContent.body = body let trigger = UNTimeIntervalNotificationTrigger(timeInterval: seconds, .. 2021. 12. 6.
Swift 키보드 상태 감지 하기 키보드가 현재 보여진 상태인지 보여지지않은 상태인지 감지 하는 코드입니다. func addKeyBoardListener() { NotificationCenter.default.addObserver(self, selector: #selector(self.keyboardWillShow(_:)), name: UIResponder.keyboardWillShowNotification, object: nil); NotificationCenter.default.addObserver(self, selector: #selector(self.keyboardWillHide(_:)), name: UIResponder.keyboardWillHideNotification, object: nil); } @objc func keyb.. 2021. 12. 6.
Xocde sceneDelegate 사용하지 않고 AppDelegate 사용 유지하기 프로젝트 생성 시 sceneDelegate가 생성되는 걸 볼 수 있습니다. 해당 sceneDelegate를 사용하려면 기존에 AppDelegate 사용을 중단하고 AppDelegate의 코드를 sceneDelegate에 맞게 다시 작성 하셔야 하는 번거로움이 생길 수 도 있습니다. 이번에는 sceneDelegate를 사용하지않고 기존 AppDelegate를 사용하는 방법. // MARK: UISceneSession Lifecycle @available(iOS 13.0, *) func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.. 2021. 11. 1.