ChamomileGuides 3.0.4 Help

FCM APNS 환경설정 가이드(IOS)

p8 파일 생성

  1. APNS
    Apple Developer 접속

    2224-images.png

  2. Key

    • 왼쪽 메뉴 Keys 클릭

      2224-images.png
      2224-images.png

    • Keys + 추가하기 클릭(아이디당 2개 생성 가능)

      2224-images.png

    • Key Name, Apple Push Notification service (APNS) 체크

      2224-images.png

    • 등록 완료(p8 다운로드 필수, 한번 다운로드 이후 재시도 불가)

      2224-images.png

  3. 사용할 서비스 내 Push 기능 등록

    • Identifier 클릭

      2224-images.png

    • App ID 클릭

      2224-images.png

    • Bundle ID 입력

      2224-images.png

    • Push Notification 클릭

      2224-images.png

    • 저장

      2224-images.png

Firebase 연동

  1. 프로젝트 생성

    • 프로젝트 추가 클릭

      2224-images.png

    • 프로젝트 이름 입력(Xcode 프로젝트 이름과 무관)

      2224-images.png
      2224-images.png
      2224-images.png
      2224-images.png

  2. 앱 등록

    • 생성된 프로젝트 내 iOS 앱을 등록한다.

      2224-images.png

    • iOS 번들 ID 입력(필수), App Store ID(선택)

      2224-images.png

    • GoogleService Info 다운로드 후 Xcode 프로젝트로 드래그

      2224-images.png

  3. Firebase 설치
    pod 'Firebase/Analtyics' , 'Firebase/Messaging' 설치

    2224-images.png
    2224-images.png

  4. 코드 설정
    AppDelegate 내 configure() 코드 추가

    2224-images.png

Cloud Messaging

Messaging 설정

  1. 프로젝트 설정 진입

    2224-images.png

  2. 클라우드 메시징 클릭

    2224-images.png

  3. p8 파일 등록

    2224-images.png

  4. 업로드 완료

    2224-images.png

Xcode 설정

  1. 환경

    • Push Notification 설정 추가

      2224-images.png

    • AppDelegate import Firebase 추가

      2224-images.png

  2. 코드

    • 알림 권한

      public func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) { if #available(iOS 12.0, *) { UNUserNotificationCenter.current().requestAuthorization( options: [.alert, .sound, .badge, .providesAppNotificationSettings], completionHandler: { didAllow,Error in }) } else { UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge], completionHandler: { didAllow,Error in print(didAllow) }) } UNUserNotificationCenter.current().delegate = self FirebaseApp.configure() Messaging.messaging().delegate = self application.registerForRemoteNotifications() }
    • 토큰

      extension AppDelegate: UNUserNotificationCenterDelegate, MessagingDelegate { public func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) { let firebaseToken = fcmToken ?? "" print("firebase token: \(firebaseToken)") } public func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { completionHandler([.alert, .badge, .sound]) } public func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { completionHandler() } }
  3. 푸시 테스트

    • Firebase Cloud Messaging 진입

      2224-images.png
      2224-images.png

    • 메시지 알림 제목 및 내용 작성

      2224-images.png

    • Xcode에서 출력된 토큰값 입력

      2224-images.png

    • 푸시 알림 확인

      2224-images.png

Last modified: 21 4월 2025