UILocalNotification Minimal Actions - One Blue, One Clear?

Im screwed in with the help UILocalNotificationand notification actions - all work as pending Id, except that when I provide two actions Minimalin my category, when I detect actions using a swipe in the Notification Center, most actions are always blue.

Since the actions in my application are equal, Id, and both of them are a clear gray color, and not one blue, one clear. I know that I can make them red with destructive, but this is also wrong, and if I explicitly set destructiveto false, I still get one blue, one clear.

Here is an image showing what I'm talking about:

enter image description here

And heres the code I used to do this:

let note = UILocalNotification()

note.fireDate = NSDate(timeIntervalSinceNow: 5)
note.timeZone = NSTimeZone.defaultTimeZone()

note.alertBody = "Actions: A and B"
note.alertTitle = "Notification!"

let action1 = UIMutableUserNotificationAction()
action1.identifier = "ACTION_A"
action1.title = "A"
action1.activationMode = .Background

let action2 = UIMutableUserNotificationAction()
action2.identifier = "ACTION_B"
action2.title = "B"
action2.activationMode = .Background

let category = UIMutableUserNotificationCategory()
category.identifier = "ANSWERS_CATEGORY"
category.setActions([action1, action2], forContext: .Default)

note.category = "ACTIONS_CATEGORY"

let categories = Set(arrayLiteral: category)
let settingsRequest = UIUserNotificationSettings(forTypes: [.Alert, .Sound, .Badge], categories: categories)
UIApplication.sharedApplication().registerUserNotificationSettings(settingsRequest)

UIApplication.sharedApplication().scheduleLocalNotification(note)
+4
1

HiG . , , , :

, ; , .

, , , , , iOS

+3

Source: https://habr.com/ru/post/1616974/


All Articles