When I read Apple Docs, they mention 3 types of notification: local, remote, and silent.
Local notification can be inferred from its name, that is sent by the app loc
Silent push notification reaches device, user does not know anything about the notification but his app gets the notification and app will be given some time to download new content and present it to the user, regardless to the state of the app (i.e. running or not running)
Remote push notification method is called only when your app is running. If app is suspended or not running, then the system wakes up or launches your app and puts it into the background running state before calling the method. This method is intended for showing the updated content to the user.When this method is called, your app has up to 30 seconds of wall-clock time to perform the download operation and call the specified completion handler block. If the handler is not called in time, your app will be suspended.
For more technical details, you can go through this links:
Apple Notifications
Silent Notifications
The push notification will let the user know that they receive a notification (Showing the notification popup for example). The silent notification will update, but the user won't get notified about it. In any case, you can perform actions when notified with silent, just as if it was a push notification. The only difference is the user will not get notify with the popup notification.
With push notification:
With silent notification:
The difference is in the payload:
Push notification:
aps {
content-available: 1
alert: {...}
}
Silent notification:
aps {
content-available: 0
alert: {...}
}
And you have to set in Capabilities the background mode you choose.
EDIT: While this answer is fully applicable, there are some additions (not changes) to notifications in iOS 12. I highly recommend watching WWDC 2018: What’s New in User Notifications and read this amazing and must read article.
Main changes are:
IMPORTANT NOTE: Not sure since when but from the Apple docs, the 'silent notification' has been renamed to 'background notification'
There are too many settings that need to be set right for it to work. I'll try to dissect them and make it easier to understand.
Overall, several things are important.
content-available
I highly recommend everyone to watch the first 7 minutes of: WWDC 2015: What's new in Notifications. From there, the presenter mentions that there are 2 major types of notifications:
They happen in the background, hence you never see any alert/badge/sound. Things get downloaded without you knowing about them.
iOS 11 bug
See here. iOS 11 initial releases were buggy for silent notifications. Make sure you have the latest version for your testing, otherwise it may not work
As the name says, it has something to do with the user. That is, the user will see an alert/badge or hear a sound. It has 2 types.
Local Notifications
A Local Notification can be triggered in 3 different ways:
UNLocationNotificationTrigger
:
You see an alert when you're close to a Walmart store.
UNTimeIntervalNotificationTrigger
: e.g. You see an alert every 10 minutes.
UNCalendarNotificationTrigger
like December 1st 1:00PM 2017.
Remote Notifications
They are similar to localNotifications but they are triggered from the server, e.g. a WhatsApp message that has a From field (Mom) and a body field (I love you!).
To receive a silent or remote notification, you need to register for a token using:
application.registerForRemoteNotifications()