For non silent notifications,
didreceiveremotenotification
will be triggered if the app is in active
or inactive
state. Not when terminated
or suspended
state.
In case of terminated
or suspended
state when user taps on notification app will be launched by calling didFinishLaunchingWithOptions
and launchingOptions
will have the payload as Dictionary
.
In case you provide UNNotificationServiceExtension
then iOS will call didReceive(_:withContentHandler:)
on receiving the notification and you can use it to customize the content of a remote notification before it is delivered to the user.
read:https://developer.apple.com/documentation/usernotifications/unnotificationserviceextension
In case you provide UNNotificationContentExtension
then iOS will call the didReceive
on receiving the notification and you can use it custom load notification content.
Read : https://developer.apple.com/documentation/usernotificationsui/unnotificationcontentextension
P.S:
Normal notifications can not be used as an alternative/work around to silent notification just because you cant use silent notification in app terminated state.
Silent notifications are intended for syncing the client app with the updated content available at server. As this can be done without the explicit user interaction silent notification can be used.
Silent notifications must contain content-available
key and must not contain alert, sound, or badge keys.
read : https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html
Where as in case of normal notification, there is no way to hide notification banner/alert/sound unless the user setting on phone says so.