-1

我正在为通过Firebase设置我的应用程序的推送通知。 斯威夫特3Swift 3:参数标签'(forTypes :, categories :)'与任何可用重载不匹配

在根据didFinishLaunchingOptions的AppDelegate中,我遇到了在这条线的错误:

参数标签 '(forTypes :, :)类' 不匹配任何可用的重载

let notificationSettings = UIUserNotificationSettings(forTypes: notificationTypes, categories: nil) 

代码:

class AppDelegate: UIResponder, UIApplicationDelegate { 

var window: UIWindow? 


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 
    // Override point for customization after application launch. 

    FIRApp.configure() 

    FIRDatabase.database().persistenceEnabled = true 

    SKCache.sharedCache.imageCache = CustomImageCache() 

    let notificationTypes : UIUserNotificationType = [UIUserNotificationType.alert, UIUserNotificationType.badge, UIUserNotificationType.sound] 
    let notificationSettings = UIUserNotificationSettings(forTypes: notificationTypes, categories: nil) 

    application.registerForRemoteNotifications() 
    application.registerUserNotificationSettings(notificationSettings) 

谢谢!

回答

0

我可能会late.But我有一个解决方案替换代码

let notificationTypes : UIUserNotificationType = [UIUserNotificationType.alert, UIUserNotificationType.badge, UIUserNotificationType.sound] 
let notificationSettings = UIUserNotificationSettings(forTypes: notificationTypes, categories: nil) 

以下行通过下面的一行

let userNotificationSettings = UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil) 
相关问题