//
// AppDelegate.swift
// apnstest
//
// Created by targetcloud on 2016/11/20.
// Copyright © 2016年 targetcloud. All rights reserved.
//
import UIKit
import UserNotifications
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
if #available(iOS 10.0, *) {
let center = UNUserNotificationCenter.current()
center.requestAuthorization(options: UNAuthorizationOptions(rawValue : UNAuthorizationOptions.alert.rawValue | UNAuthorizationOptions.badge.rawValue | UNAuthorizationOptions.sound.rawValue)){ (granted: Bool, error:Error?) in
if granted {
print("success")
}
}
UIApplication.shared.registerForRemoteNotifications()
// center.delegate = self
}else if #available(iOS 8.0, *) {
// 请求授权
let type = UIUserNotificationType.alert.rawValue | UIUserNotificationType.badge.rawValue | UIUserNotificationType.sound.rawValue
let set = UIUserNotificationSettings(types: UIUserNotificat
swift 远程通知(二)接收
最新推荐文章于 2021-10-28 16:30:07 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)