user1872384 user1872384 - 1 year ago 139
iOS Question

"WatchKit Simulator Actions" not working on actual apple watch device

I've tested the simulated apple watch push notification and it works fine...

However when I tried to send it to the actual apple watch, the button doesn't appear... why is it so?

And it doesn't vibrate or beep when I send the push notification in json format instead of text...

"aps": {
"alert": {
"body": "Great!\nNew input",
"title": "Optional title"
"category": "sCategory"

"WatchKit Simulator Actions": [
"title": "Details",
"identifier": "sDetailsButtonAction"

"customKey": "Use this file to define a testing payload for your notifications. The aps dictionary specifies the category, alert text and title. The WatchKit Simulator Actions array can provide info for one or more action buttons in addition to the standard Dismiss button. Any other top level keys are custom payload. If you have multiple such JSON files in your project, you'll be able to select them when choosing to debug the notification interface of your Watch App."

enter image description here

Answer Source

Have a look at this.

To specify custom action buttons, you need to create a custom notification category. When you create the notification, set the category to your customized one.

The example from the Apple Documentation:

func registerSettingsAndCategories() {
    var categories = NSMutableSet()

    var acceptAction = UIMutableUserNotificationAction()
    acceptAction.title = NSLocalizedString("Accept", comment: "Accept invitation")
    acceptAction.identifier = "accept"
    acceptAction.activationMode = UIUserNotificationActivationMode.Background
    acceptAction.authenticationRequired = false

    var declineAction = UIMutableUserNotificationAction()
    declineAction.title = NSLocalizedString("Decline", comment: "Decline invitation")
    declineAction.identifier = "decline"
    declineAction.activationMode = UIUserNotificationActivationMode.Background
    declineAction.authenticationRequired = false

    var inviteCategory = UIMutableUserNotificationCategory()

    inviteCategory.setActions([acceptAction, declineAction], forContext: UIUserNotificationActionContext.Default)
    inviteCategory.identifier = "invitation"

// Configure other actions and categories and add them to the set...

    var settings = UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: categories)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download