iOS remote push notifications in a nutshell

What are remote Push Notifications?

What can Push Notifications do?

Stuff needed prepared Before APNS configuration can start

APNS Configuration and initial step-by-step implementation

Enable Push Notifications in Capabilities in Xcode
Push Notifications Configurable
Spotlight Search
Keychain Access dropdown on left and Certificate Information window on right
Upload CSR file screen
Download .cer file screen
Developer Push Notifications enabled
import UserNotifications
registerForPushNotifications function and what it does with comments.
Calling registerForPushNotifications in the proper place.
Notification Authorization within App
Converting the device token or printing out an error code.
Default start-up for Pusher
Example Push Certificate
Example Device Token
Testing simple notification

Adding media attachments

File->New->Target… selection
Filtering Notification Service Extension
Notification Service file group
  “mutable-content”:1
{ 
   "aps": {
"alert":"Testing.. (0)",
"badge":1,
"sound":"default",
"mutable-content": 1,
"attachment-url": "https://tinyurl.com/y9exh3by"
   }
}
A helper function to download an image from the internet using a url and return it as a notification attachment.
Implementing the download function within the didReceive method and attaching the downloaded image.
Testing notification with image.

Adding custom actions

Adding actions.
Testing notification with actions.
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void)
Code for demo handling of custom actions
Printing on the console.

Conclusion


Update providing additional clarification regarding APNs certificates


Flawless iOS

🍏 Community around iOS development, mobile design, and marketing

Deyan Aleksandrov

Written by

iOS Developer at Tumba Solutions

Flawless iOS

🍏 Community around iOS development, mobile design, and marketing