본문 바로가기

iOS/Swift

Push Notification 권한 허용 팝업이 뜨지 않을 때

개발 환경

  1. Xcode 15
  2. Target iOS: 12.1
  3. 테스트 기기: iOS 17

문제

앱을 빌드하고 실행하면 이전엔 푸시 허용 팝업이 잘 떴었으나, 어느 순간부터 안 뜨기 시작했고, device token을 가져오지 못함.

 

Appdelegate.swfit

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        ...
        
        UNUserNotificationCenter.current().requestAuthorization(options:[.badge, .alert, .sound]){ (granted, error) in
                print(granted)
                print(error)
        }
        
        ...
}

 

위 처럼 error를 출력해 보니, "Error Domain=UNErrorDomain Code=1"라는 에러가 발생하고 있었다.


원인

프로젝트의 Product Name 항목을 한글로 바꾼 것이 원인이었다.


해결

아래와 같이 Product Name 항목을 영어로 바꾸면 된다.

 

 

설치된 앱의 이름을 바꾸려면 아래 설정에서 바꿔주면 된다.


참고

https://developer.apple.com/forums/thread/660715