As you may know, on the PushNotificationPayload.aps file, actions can be set on the "WatchKit Simulator Actions" node.
Can someone provide me a real push notification payload that includes actions?
Thanks!
We use a test payload that looks something like this:
{
"aps": {
"alert": {
"title": "My Alert Title",
"body": "The body message",
},
"category": "myCategoryName"
},
"WatchKit Simulator Actions": [
{
"title": "Like it!",
"identifier": "MY_LIKE_ACTION"
}
],
"myCategoryDictionary": {
"image" : "http://.....",
"subject" : "The subject of the alert message",
"content": "Detailed content info can go here"
},
"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."
}
Related
Flutter Push Notification
I implemented Push Notification and notification has image link in Flutter.
In Android, The image display in Notification center automatically with notification details.
In iOS, The image does not display in Notification center but only notification details display in Notification center.
please see format of Push notification. Curl through, Php developer is sending notification. I am getting notification successfully but image not display automatically at iOS side and, in Android image is display automatically
I already add "mutable-content": true and,
already tried to add "mutable-content": true in notification block but not getting success
{
"to": "device token",
"mutable-content": true,
"notification": {
"title": "Note 3",
"body": "11:41",
"click_action": "FLUTTER_NOTIFICATION_CLICK",
"image": "https://homepages.cae.wisc.edu/~ece533/images/airplane.png"
},
"data": {
"notification_type": "Nice Thoughts",
"post_details": {
"message": "hello",
"color": "#e0e0e0",
"url": "www.recurpost.com",
"img_url": "https://homepages.cae.wisc.edu/~ece533/images/airplane.png",
"video_url": "",
"name": "abc xyz"
}
},
"priority": "high"
}
You need to create a notification service extension as described here
How can I make the notifications to show in the status bar instead of queuing up and received in the app when brought to the foreground?
I have set up the FCM-account with the APNs, enabled push notification, background fetch and remote notifications.
I've done the equivalent on android where it works as expected.
My message looks like this:
{
"notification": {
"body": "this is a body",
"title": "this is a title",
"content_available": true
},
"priority": "high",
"data": {
"click_action": "FLUTTER_NOTIFICATION_CLICK",
"id": "1",
"status": "done"
},
"to": "TOKEN"
}'
What am I missing?
The notifications appear only when the app is not in foreground. If you want to display them when in foreground, you should implement your custom UI for this.
the scenario that I am trying to achieve is that when the iOS app is closed, the remote firebase notification with an image should popup,the image can be in place of the app logo or a bigger image can open on user tap.
I am successfully getting the notification but I dont know how to add an image into it.I am guessing I"ll have to override the UNUserNotificationCenterfunctionalities and add something to the payload like
{
"priority":"high",
"notification": {
"title": "Portugal vs. Denmark",
"body": "5 to 1",
"icon": "my desired image"
},
"to": "ebBUO1R..."
}
I'd be glad if anyone can point me towards the right direction or any help(preferably in swift).
Regards
When creating a new Apple Watch App in Xcode, the following APNS payload example is created:
{
"aps": {
"alert": {
"body": "Test message",
"title": "Optional title"
},
"category": "myCategory"
},
"WatchKit Simulator Actions": [
{
"title": "First Button",
"identifier": "firstButtonAction"
}
],
"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." }
I am confused by the use of body and title within the alert dictionary. The following payload is ordinarily used in iOS apps:
{
"aps": {
"alert": "Test message",
"title": "Opt title",
"category": "default"
},
"WatchKit Simulator Actions": [
{
"title": "First Button",
"identifier": "firstButtonAction"
}
],
"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."
}
Which is the correct way? Although a default payload file is created in this way, the Apple documentation provides a screenshot using the latter variant.
In the Local and Remote Notification Programming Guide(Table 3-1), the value type of alert key can be string or dictionary, as Dhawal said, both formats are correct.
If alert is dictionary, it can contain title, body, title-loc-key etc(Table 3-2). What's the purpose of title key? This key was added in iOS 8.2 which contain WatchKit, and WatchKit has a Short-Look Notification interface, there is no enough space for full notification, so Apple Watch use title to describe the purpose of the notification and display in Short-Look Notification.
(source: edgekey.net)
In this picture, "Gray's Birthday" is the title in alert. Because you can't see Short-Look Notification in simulator, you should test result of title key in REAL Apple Watch.
Based on the Apple documentation, here is the following keys that you can have in the aps dictionary: alert, badge, sound and content-available. And here is keys that you can have in the alert dictionary: title, body, title-loc-args etc. You can check it the Push Notification Programming Guide for more information here:
Push Notification Programming Guide
Check this as well for your WatchKit Extension, Apple Watch Programming Guide
Also, the second way you describe should be the correct way. I just create a Watch App and it includes the sample payload. And the category is put inside the aps outside the alert which should be incorrect in this case. Hope this helps. It means that aps can only contain those four default properties. So, category should be contained inside the alert.
Apple Documentation for Push Notification Payload has mentioned a Note,
Note: If you want the device to display the message text as-is in an
alert that has both the Close and View buttons, then specify a string
as the direct value of alert. Don’t specify a dictionary as the value
of alert if the dictionary only has the body property.
So as per above note, both formats are correct but we should use second format (alert with directly text value instead of dictionary) when you only need body property in Alert. If you need to use other child properties of Alert like body, title,...then you should use first format (Alert with dictionary as value).
I'm working with Apple Watch Notifications.
I defined my own category "myAppcategory" and passed the same to notification payload.
But, still i'm receiving below warning in XCode.
Warning: Notification category "(null)" not found. Define this category or a default category in your storyboard.
And result in watch simulator is below
Can any one help me to fix this issue?
I recently had the same issue. For me it was an invalid push notification payload. If you're using a .apns file (for example the sample one provided for notification controllers) to test make sure it's formatted correctly.
This issue is most probably is caused after a mistaken edit that broke the formatting on the PushNotificationPayload.apns file. To resolve this issue fix the formatting in your .apns file.
The most problematic part is when you add data to alert. Make sure you add comma after each entry, except last one.
"alert": {
"body": "Test message",
"title": "Optional title",
"name": "MyName"
},
Like this.
Try to remove application from iphone simulator. I had the same error and I've resolved it in this way
Also, watch for the comma in the button list
"WatchKit Simulator Actions": [
{
"title": "Stop/Save Activity",
"identifier": "stopsave"
}, // <===== THIS ONE HERE
{
"title": "Cancel Activity",
"identifier": "cancel"
}
],
You should add category value in your payload and define it in your storyboard.
"aps": {
"alert": "Test message",
"sound": "Optional title",
"category":"myCategory"
}
reference: https://developer.apple.com/library/ios/documentation/General/Conceptual/WatchKitProgrammingGuide/CustomzingthePushNotificationInterface.html