针对iOS 10的React Native,PushNotification提供了" UIUserNotificationSettings已被弃用"

时间:2016-11-22 04:41:25

标签: ios react-native

当将iOS 10设置为React Native的构建目标时,我收到此错误

  

/Users/krishan/Projects/CandidApp/node_modules/react-native/Libraries/PushNotificationIOS/RCTPushNotificationManager.h:15:46:' UIUserNotificationSettings'不推荐使用:在iOS 10.0中首先弃用 - 使用UserNotifications Framework的UNNotificationSettings`

1 个答案:

答案 0 :(得分:0)

而不是你可以使用“UserNotifications” 你只需导入它并使用它的两个委托方法如下:

 func userNotificationCenter(center: UNUserNotificationCenter, willPresentNotification notification: UNNotification, withCompletionHandler completionHandler: (UNNotificationPresentationOptions) -> Void) {

       print(notification.request.content.userInfo)
  }

@available(iOS 10.0, *)
func userNotificationCenter(center: UNUserNotificationCenter, didReceiveNotificationResponse response: UNNotificationResponse, withCompletionHandler completionHandler: () -> Void) {
   print(response.notification.request.content.userInfo)
}