FCM APNS 환경설정 가이드(IOS)
p8 파일 생성
APNS
Apple Developer 접속Key
왼쪽 메뉴 Keys 클릭
Keys + 추가하기 클릭(아이디당 2개 생성 가능)
Key Name, Apple Push Notification service (APNS) 체크
등록 완료(p8 다운로드 필수, 한번 다운로드 이후 재시도 불가)
사용할 서비스 내 Push 기능 등록
Identifier 클릭
App ID 클릭
Bundle ID 입력
Push Notification 클릭
저장
Firebase 연동
프로젝트 생성
프로젝트 추가 클릭
프로젝트 이름 입력(Xcode 프로젝트 이름과 무관)
앱 등록
생성된 프로젝트 내 iOS 앱을 등록한다.
iOS 번들 ID 입력(필수), App Store ID(선택)
GoogleService Info 다운로드 후 Xcode 프로젝트로 드래그
Firebase 설치
pod 'Firebase/Analtyics' , 'Firebase/Messaging' 설치코드 설정
AppDelegate 내 configure() 코드 추가
Cloud Messaging
Messaging 설정
프로젝트 설정 진입
클라우드 메시징 클릭
p8 파일 등록
업로드 완료
Xcode 설정
환경
Push Notification 설정 추가
AppDelegate import Firebase 추가
코드
알림 권한
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() } }
푸시 테스트
Firebase Cloud Messaging 진입
메시지 알림 제목 및 내용 작성
Xcode에서 출력된 토큰값 입력
푸시 알림 확인
Last modified: 21 4월 2025