본문 바로가기

Xcode43

Swift rootView 변경하기. let ad = UIApplication.shared.delegate as! AppDelegate //델리데이트 값 받아오기. ad.window?.rootViewController = self //루트뷰를 현재 메인뷰로 변경 해당 2줄로 간단하게 해결 가능합니다. 2021. 12. 8.
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.