Warning pushNotification - Using push notification with Firebase Cloud Messaging

Overview

재난문자 푸시 알림 구현

1) 구현 기능

2) 기본 개념

(1) Remote Notification

  • 불시에 발생한 업데이트
  • 불특정 시간
  • 예측 불가하므로 local static 하게 작성할 수 없다
  • 따라서 원격 알림을 보낼 Provider(Server) 필요

- Provider (Server) - APNS

(2) APNS

Apple Push Notification Service

원격 알림을 사용할 때에 꼭 거쳐야 하는 핵심 서비스 서버에서 바로 기계로 보내지 않고 반드시 APNS를 거친다

  • 저장 외 전달 기능을 수행하는 QOS 포함 전달받을 기기가 오프라인 상태인 경우 일정 기간동안 메세지를 보관하고 기기가 Online 상태가 되었을 때 전달하고 기기, 앱 별로 가장 최근의 알림만 저장 각 서버에서 보내는 알림을 최신 상태로 저장 하다가 장비의 오프라인 시간이 길어지면 모든 알림을 삭제

=> 기기 상태에 따라 최신의 알람을 보내도록 관리

  • 보안 특정 사용자에게만 전달되어야 하는 정보가 제3자에 보내지지 않게 메세지가 오염되지 않게 자체 보안 아키텍처를 통해 보안 강화
    • Connection trust
      • 연결 신뢰
      • provider-to-APNs connection trust (애플과 계약을 맺은 서버만)
        • token-based: valid authentication key certificate
        • certificate-based: SSL certificate
      • APNs-to-device connection trust
    • Device token
      • 각 원격 알림에서 End to End (제공자와 디바이스)
      • 디바이스가 APNs 에게 받은 고유 token을 provider에 전달
      • 고유 식별자 NSData
      • APNs 만 해석 가능
      • provider는 각각의 push 알림에 token 을 포함시켜 전송한다.
      • 상황에 따라 새롭게 발급 가능 (새 장치, 백업 복원, iOS 업데이트)

<참고 자료> https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/APNSOverview.html#//apple_ref/doc/uid/TP40008194-CH8-SW1

APN 구성하기
  1. Xcode에서 Capability 추가 : push message
  2. Apple Developer 에서 key 생성: APNs
  3. Firebase 프로젝트 설정 -> APN 인증 키 업로드

(3) Firebase Cloud Messaging

remote notification 관리 위한 서버

  • 원격 알림 메세지 전송 : 사용자에게 표시되는 알림 메세지를 실시간 또는 예약 전송
  • 다양한 메시지 타겟팅 : 단일 기기, 기기 그룹, 주제를 구독한 기기
  • 발송 메시지 저장, 관리 : 알림 내용, 상태, 플랫폼, 최종 전송 시간, 열람율 관리

A/B testing 을 위한 방법

  1. Remote config
  2. Cloud messaging
registration tokens

The FCM SDK generates a registration token for the client app instance on app launch. Similar to the APNs device token, this token allow you to send targeted notifications to any particular instance of your app

In the same way that Apple platforms typically deliver an APNs device token on app start, FCM provides a registration token via FIRMessagingDelegate’s messaging:didReceiveRegistrationToken

  • FCM의 현재 등록 토큰, 갱신되는 시점에 대해 알고
  • 그에 따른 적절한 액션을 취할 수 있다.
  • 이 토큰을 등록하여 Cloud Message 를 보낸다.

https://firebase.google.com/docs/cloud-messaging/ios/client

3) 새롭게 알게 된 것

  • UNUserNotificationCenterDelegate
    • willPresent
    • 전달받은 Notification를 어떻게 display할 것인지 알림 형태를 지정할 수 있다.
    • 기본값 지정
extension AppDelegate: UNUserNotificationCenterDelegate {
    func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
        completionHandler([.list, .banner, .sound])
    }
}
  • UIApplication.shared

applicationIconBadgeNumber 을 컨트롤하는 데에 사용했음

UIApplication

shared

  • The singleton app instance
  • return the app instance is created in the UIApplicationMain(::::) function
  • The UIApplicationMain function creates the shared app instance at launch time
You might also like...
The ToDoList application using FireBase allows you to register users
The ToDoList application using FireBase allows you to register users

ToDoFirebase Приложение ToDoList с использовавнием FireBase позволяет зарегистри

📱 Very simple and lightweight messenger using Firebase
📱 Very simple and lightweight messenger using Firebase

📱 Very simple and lightweight messenger using Firebase 🔥. It is a training project for the practice of MVVM architecture.

 SwiftUI, Firebase, Kingfisher, googleapis
SwiftUI, Firebase, Kingfisher, googleapis

SwiftUI-KokaiByWGO Xcode Version 12.0 SwiftUI, Firebase, Kingfisher, googleapis Learn Thai with pictures and sounds Note : This version have no CMS so

Social Media platform build with swiftUI and Firebase with google and apple account integration for Signing In Users
Social Media platform build with swiftUI and Firebase with google and apple account integration for Signing In Users

Social Media platform build with swiftUI and Firebase with google and apple account integration for Signing In Users . Providing Users availability to upload posts and images add caption allowing other users to comment , with Find section to explore new people , new stories , User Profile section to allow the user to take control of his account .

Instagram clone with firebase and swift
Instagram clone with firebase and swift

Instagram clone with firebase and swift

 iOS Open-Source Telematics App with Firebase© integration
iOS Open-Source Telematics App with Firebase© integration

Open-source telematics app for iOS. The application is suitable for UBI (Usage-based insurance), shared mobility, transportation, safe driving, tracking, family trackers, drive-coach, and other driving mobile applications

The app demonstrates how to use Firebase in a SwiftUI iOS app

Firebase SwiftUIDemo app This app demonstrates how to use Firebase in a SwiftUI iOS app. Firebase Setup Go to firebase.com Click new project. Copy app

A detailed clone of the Instagram app built with Firebase
A detailed clone of the Instagram app built with Firebase

[This repository is no longer being maintained] InstagramClone A detailed clone

Learning App with Firebase Auth
Learning App with Firebase Auth

Learning App Displays how to make a learning app with Swift, iOS's programming l

Owner
null
Firebase Cloud Firestore support library for iOS. 🧢

?? Ballcap-iOS Ballcap is a database schema design framework for Cloud Firestore. Why Ballcap Cloud Firestore is a great schema-less and flexible data

1amageek 229 Jan 2, 2023
Swush - macOS Application to play with the Apple Push Notification service (APNs)

Swush ✨ Description A macOS app to push notifications to APNS with ease. ⚡ ?? Pe

Quentin Eude 80 Dec 23, 2022
Aplikasi iOS Advanced Level To Do List dengan Firebase Auth, SwiftUI, MVVM Design Pattern, dan Firebase Firestore

Aplikasi Tasker adalah aplikasi iOS To Do List yang dibuat menggunakan Autentikasi Firebase / Firestore dan MVVM Design Pattern.

DK 10 Oct 17, 2022
A macOS auxiliary app to choose results from cloud input methods

CloudInputAssist Introduction 介绍 一个 macOS 辅助应用程序,用于使用云输入法(例如谷歌云输入法)API 提供辅助的候选词结果。 Motivation 动机 使用不联网的本地输入法时,长句的候选词往往不太理想,尤其是使用双拼输入时。这种情况下,借助一些输入法的云计

JJAYCHEN 1 Jan 3, 2023
Native iOS app using the exposure notification framework from Apple.

Corona Warn App - iOS Development • Documentation • Contribute • Support • Changelog • Licensing The goal of this project is to develop the official C

Corona-Warn-App 1.7k Dec 18, 2022
A SwiftUI iOS App and Vapor Server to send push notifications fueled by Siri Shortcuts.

Puffery An iOS App written in SwiftUI to send push notifications fueled by Siri Shortcuts. You can follow other's channels and directly receive update

Valentin Knabel 29 Oct 17, 2022
CloudKit Samples: Private Sync with Subscriptions and Push

CloudKit Samples: Private Sync with Subscriptions and Push Goals This project demonstrates using CloudKit Database Subscriptions and push notification

null 0 Nov 11, 2021
Simple Todo Application using SwiftUI / Firebase / Redux.

Simple Todo Application using SwiftUI/Firebase/Redux/Combine. Light _ _ _ _ Dark _ _ _ Feature Use SwiftUI fully. Use Firebase. Authentication Cloud F

Suguru Kishimoto 337 Dec 25, 2022
Completed Project for Authentication in SwiftUI using Firebase Auth SDK & Sign in with Apple

Completed Project for Authentication in SwiftUI using Firebase Auth SDK & Sign in with Apple Follow the tutorial at alfianlosari.com Features Uses Fir

Alfian Losari 43 Dec 22, 2022
A grocery list app for families written in Swift using Firebase Realtime Database

FamiList | Grocery list app in Swift FamiList is a grocery list app for families written in Swift using Firebase Realtime Database. You can add differ

Wasan Ibrahim 2 Jul 31, 2022