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 locally.
However, what is the difference of the other two types?
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 locally.
However, what is the difference of the other two types?
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 see here.
Main changes are:
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!).
Some random notes:
To receive a silent or remote notification, you need to register for a token using:
application.registerForRemoteNotifications()