UILocalNotificationでローカル通知を行いたいのですが、ダイアログのボタンをタップしてもアプリに移動しないようにする方法がわかりません。イメージとしては、デフォルトの「閉じる」と「開く」の2つのボタンのうち、「開く」ボタンを無くして「閉じる」ボタンのみにしたいです。
hasActionプロパティでできると思い下記のようなコードを作りましたが、機能しません。お手数ですが、皆様のお知恵をお貸しください。環境はiOS9、swift2.0、xcode7です。
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for customization after application launch. let settings = UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil) UIApplication.sharedApplication().registerUserNotificationSettings(settings) return true } func applicationDidEnterBackground(application: UIApplication) { // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. let notification = UILocalNotification() notification.alertAction = nil notification.alertBody = "テスト" notification.fireDate = NSDate(timeIntervalSinceNow: 1) notification.soundName = nil notification.applicationIconBadgeNumber = 0 notification.hasAction = false application.scheduleLocalNotification(notification) } }
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。