iOS 10 UNUserNotificationCenterDelegate not called. push notifications not working

前端 未结 5 700
日久生厌
日久生厌 2020-12-23 10:06

Tearing my hair out tying to get push notifications to work in iOS10. Current setup:

in func application(_ application: UIApplication, didFinishLaunchingWithOp

5条回答
  •  难免孤独
    2020-12-23 10:28

    Maybe not set UNNotificationCategory's intentIdentifiers, if code like this:

    UNNotificationCategory* expiredCategory = [UNNotificationCategory
                                                   categoryWithIdentifier:@"TIMER_EXPIRED"
                                                   actions:@[snoozeAction, stopAction]
                                                   intentIdentifiers:@[]
                                                   options:UNNotificationCategoryOptionCustomDismissAction];
    

    it will not called UNUserNotificationCenter's delegate methods, so you must set intentIdentifiers like this :

    UNNotificationCategory* expiredCategory = [UNNotificationCategory
                                                   categoryWithIdentifier:@"TIMER_EXPIRED"
                                                   actions:@[snoozeAction, stopAction]
                                                   intentIdentifiers:@[@"a",@"b"]
                                                   options:UNNotificationCategoryOptionCustomDismissAction];
    

提交回复
热议问题