Working on Apple Watch Notifications:- so if i add button in Notification Interface (from object Lib) then the error is :
Buttons are not Supported in Notification Interface
PushNotificationPayload.apns
has the WatchKit Simulator Actions
Like This :
"WatchKit Simulator Actions":
[
{
"title": "View",
"identifier": "firstButtonAction"
}
],
and the Simulator Shows this to me
Now my Question is, How can I Handle this View
Button when send a PushNotification
from server,
If the aps
file contain the action button is the only option for Apple Watch,
How to send it from server in Notification Dictionary with specified Key?
How to Change the Action button BG Color?
Will anyone please give me the sample aps
file that include ActionButton
for Device the Apple Watch
not for the Simulator
I just test by changing the WatchKit Simulator Actions
Key to WatchKit Actions
Key but it shows no Action Button.
As suggested by @vivekDas in Answer, I checked by replacing in the aps
as :
"alert" : {
"body" : "Acme message received from Johnny Appleseed",
"action-loc-key" : "VIEW",
"action" : [
{
"id" : "buttonTapped",
"title" : "View"
}
]
}
but simulator in Xcode does show an action button.
I think this may run on Device Apple Watch
, is this...?
What would you suggest to me on this.
Use Json Payload like given below
Check this apple doc link https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html
The Notification Payload section.
I've been struggling with this for two Hours, so this is how I do for notifications buttons in production, via real APNS Serv,
1) Register for the category in your appDelegate's parent app :
2) From your Apns server add the category (for me "respond")
3) In your WatchKitExtention, you have the data passed in :
4) In your Parent app's appDelegate :
Warning ! you'll have to handle this action too in your Parent app ( because the respond button will be visible too on iphone when you pan down the notification. in the :