ios에서 fcm 푸시 알람 기능을 구현하려면 애플 개발자 계정이 필요하다.
1. 애플 개발자 계정 로그인
2. Certificates, Identifiers & Profiles 페이지의 Keys 탭에서 Key 추가
3. Apns 체크 후 완료 및 다운로드
** 한번 다운로드 받으면 다시 받을 수 없으니 보관 잘하기
4. Firebase 프로젝트 - 클라우드 메시징 탭 - Apple 앱 구성 - APN 인증 키 업로드
5. Xcode - Runner - Capability 추가
참고 : https://firebase.flutter.dev/docs/messaging/apple-integration/
FCM via APNs Integration | FlutterFire
iOS & macOS require additional configuration steps to be completed before you can receive messages.
firebase.flutter.dev
6. Backgroud fetch, Remote notifications 체크
7. AppDelegate.swift 푸시 알람 코드 추가
override func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// ios 10.0 이후 UserNotificationCenter가 푸시 알람 관리
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
}
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
8. 포그라운드에서 푸시 알림 띄우기
안드로이드와 ios 둘 다 포그라운드 알림을 위해 따로 코드를 작성해줘야 한다.
await FirebaseMessaging.instance.setForegroundNotificationPresentationOptions(
alert: true, // Required to display a heads up notification
badge: true,
sound: true,
);
'dev > flutter' 카테고리의 다른 글
flutter - local_auth, 지문인증, Unresolved reference: activity (0) | 2023.08.02 |
---|---|
flutter - flutter_staggered_grid_view, 서로 다른 높이를 가진 그리드뷰 (0) | 2023.07.31 |
앱 아이콘 (0) | 2023.07.18 |
flutter - 앱 빌드 사이즈 확인 (0) | 2023.07.14 |
flutter - 백그라운드 푸시 메세지 클릭 이벤트 (0) | 2023.07.10 |