杂记小知识

获取授权通知

/// UNAuthorizationOptionBadge:The ability to update the app’s badge.
/// UNAuthorizationOptionSound:The ability to play sounds.
/// UNAuthorizationOptionAlert:The ability to display alerts.
/// UNAuthorizationOptionCarPlay:The ability to display notifications in a CarPlay environment.
if (@available(iOS 10.0, *)) {
        [[UNUserNotificationCenter currentNotificationCenter]
         requestAuthorizationWithOptions:UNAuthorizationOptionAlert 
         | UNAuthorizationOptionBadge 
         | UNAuthorizationOptionSound 
         completionHandler:completion];
    }

iOS系统版本判断

  • OC
if @available(iOS 10.0, *) {
  // TODO:
}

*Swift

if #available(iOS 10.0, *) {
  // TODO:
}

你可能感兴趣的:(杂记小知识)