iOS 14에서 Push 알림 라이센스 문제를 팝업할 수 없습니다.
오류 세부 정보
iOS 14 특유의 문제인 것 같습니다. 프로그램의 ProductName에 특정한 문자가 포함되어 있다면, Push 알림을 실행할 때 사용합니다.
UNUserNotificationCenter.current().requestAuthorization(options:, completionHandler:)
방법은 오류로 인해 튕겨져 사용자에게 허가를 요청하는 팝업이 나타나지 않습니다.자신의 경우는 ProductName에 히라가나를 넣었어요. (왜 넣었을까...)팝업이 뜨지 않아 푹 빠졌으니 먼저 오류에 대한 자세한 내용과 해결책을 적는다.
애플의 Forms에 이번 issue의 상세한 내용이 실렸다.나는 영어에 문제가 없는 사람이 링크를 읽는 것이 비교적 빠르다고 생각한다.
코드 및 오류 내용
AppDelegate
import UIKit
import UserNotifications
***
class AppDelegate: UIResponder, UIApplicationDelegate {
***
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
UNUserNotificationCenter.current().delegate = self
let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
UNUserNotificationCenter.current().requestAuthorization(options: authOptions, completionHandler: { granted, error in
print(error)
guard error == nil else { return }
if granted {
DispatchQueue.main.async {
application.registerForRemoteNotifications()
}
}
})
return true
}
}
사용자에게 알림을 보낼 때 UNUserNotificationCenter
requestAuthrization()
방법으로 허가를 요청하지만 ProductName에 문제가 있으면 completionHandler
오류가 발생하고 실행하지 않음registerForRemoteNotifications()
, 팝업 디스플레이를 실행하지 않습니다.print(error)
에서 내용을 확인한 후 다음과 같이 콘솔에 표시됩니다.Error Domain=UNErrorDomain Code=1 "Notifications are not allowed for this application"
해결책
TARGET->BuildSettings->Packaging 프로젝트 내의 ProductName은 문제가 없는 것으로 변경되었습니다(공식적으로 단순 ASCII characters가 있음).
ProductName은 사용자가 볼 수 없는 것이기 때문에 너무 깊이 생각할 필요가 없습니다.
이용자가 보는 곳(앱 아이콘 아래 애플리케이션명 등)에 히라가나 한자를 사용하려면 인포를 이용하세요.plist에 Bundle Display Name 항목을 추가하고 표시할 응용 프로그램 이름을 입력합니다.
문제 없는 팝업이 표시됩니다.
Reference
이 문제에 관하여(iOS 14에서 Push 알림 라이센스 문제를 팝업할 수 없습니다.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://zenn.dev/aphananthe42/articles/d335b43bfdcb68텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)