2016-09-28 24 views
0

私はアプリをSwift 3にアップデートしようとしています。私は進歩していますが、ローカルの通知設定を登録する方法を理解できません。これは、AppDelegateファイルに存在私のコードです:Swift 3でローカル通知設定を作成/登録するにはどうすればよいですか?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 

    application.applicationIconBadgeNumber = 0 

    if application.currentUserNotificationSettings?.categories?.count == 0 { 
     // Updated Code 
     let types: UNAuthorizationOptions = [.alert, .badge, .sound] 

     let completeAction = UNNotificationAction(identifier: "complete", title: "Complete", options: []) 

     let ignoreAction = UNNotificationAction(identifier: "ignore", title: "Ignore", options: []) 

     let taskCategory = UNNotificationCategory(identifier: "taskCategory", actions: [completeAction, ignoreAction], intentIdentifiers: [], options: []) 

     // Old Code (stripped for simplicity) 
     let settings = UIUserNotificationSettings(types: _, categories: _) 
     application.registerUserNotificationSettings(settings) 
    } 
    print(application.currentUserNotificationSettings?.categories?.count) 
    return true 
} 
+0

のように試してみてください。地元の通知に関する私の質問には答えません。 – Greg

答えて

0

プッシュ通知にあるこの

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool 
{ 
    // Override point for customization after application launch. 
    let center = UNUserNotificationCenter.current() 
    center.requestAuthorization([.alert, .sound]) { (granted, error) in 
    } 
    return true 
} 
+0

ありがとう!私は実際にこれとAppleのドキュメントの残りの部分に着手しました。私は現在、私が必要とするものをまとめています。私が望んでいたほど簡単な変更ではありません。以前に実装したロジックとは異なるロジックが必要です。 – Greg

関連する問題