-1

私のアプリケーション用のFirebaseを通じてプッシュ通知を設定しようとしています。 didFinishLaunchingOptions下AppDelegateでSwift 3:引数ラベル 'forTypes :, categories :)が使用可能なオーバーロードと一致しません

3が、私はこの行のエラーに実行していますスウィフト:

引数ラベル '(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) 

ありがとう!

答えて

3

スウィフト3では "for"はありません。それはtypes:であり、​​ではありません。

https://developer.apple.com/reference/uikit/uiusernotificationsettings/1615401-init

+0

作品完全に次の行を使用してコード

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

の次の行を置き換える必要がありlate.Butされる可能性があります。ありがとうございました! – Miles

0

私は解決策が

let userNotificationSettings = UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil) 
関連する問題