You can add additional data to notifications, enabling actions tailored to each specific notification.
Place your custom fields at the root level of the remote notification JSON.
{
"aps": {
"alert": {
"title": "EducaSwift",
"subtitle": "Remote Notifications",
"body": "This is a Remote Push Notification test.",
},
"badge": 12
},
"custom_field": "1",
"another_custom_field": "2"
}
For local notifications, you can add this info to the content:
let content = UNMutableNotificationContent()
content.title = "EducaSwift"
content.body = "This is a Local Push Notification test."
content.userInfo = [
"custom_field": 1,
"another_custom_field": 2
]
Continue reading
Access to all the content with our plans.
- Junior level content
- Senior level content
- Expert level content
- Extra content
- Question submissions
Monthly
Yearly
Be the first to comment