xcode 10에서 swift3을 사용하여 알림 서비스를 만들고 있습니다. 이제 푸시 알림이 백그라운드에서 제공 될 때 (앱이 종료 된 경우에도) 배지는 처음에는 증가하지만 두 번째 푸시 알림에서 1 씩 증가합니다. 또한 앱에 들어가서 배경으로 돌아 왔을 때 배지 수는 정상이지만 위와 같은 문제가 다시 발생합니다.백그라운드에서 푸시 알림 배지를 다시로드하십시오.
지연 또는 로컬 알림을 통해 문제를 확인하려고했지만 문제가 무엇인지 파악하지 못했습니다.
다음은 AppDelegate 내의 알림과 관련된 알림입니다. 푸시 알림 클릭 이벤트도 정상적으로 작동합니다.
class AppDelegate: UIResponder, UIApplicationDelegate, GIDSignInDelegate, NaverThirdPartyLoginConnectionDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions:[UIApplicationLaunchOptionsKey: Any]?) -> Bool {
UNUserNotificationCenter.current().delegate = self
UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .sound, .alert,], completionHandler: {(granted, error) in
if (granted)
{
application.registerForRemoteNotifications()
}
else{
}
})
return true
}
...
...
extension AppDelegate: UNUserNotificationCenterDelegate {
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler([.badge, .alert, .sound])
UIApplication.shared.applicationIconBadgeNumber = UIApplication.shared.applicationIconBadgeNumber + 1
}
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping() -> Void) {
print("userInfo: \(response.notification.request.content.userInfo)")
var userInfo:[AnyHashable: Any]?
let pushId:Int32 = userInfo?["uid"] as! Int32
self.moveView(pushId)// My app load method
}
}
의견에 감사 드리며 늦어서 죄송합니다. 신속하게 신청합시다. –