As I can see in the APNS documentation, silent notifications are handled in didreceiveremotenotification if the app is not running, but they have an low priority. So sometimes my iOS application doesn't receive silent notifications.
Does iOS show non silent notifications, if the app is not running (not in foreground, not in background)? And will a non silent notification trigger the didreceiveremotenotification?
For non silent notifications,
didreceiveremotenotificationwill be triggered if the app is inactiveorinactivestate. Not whenterminatedorsuspendedstate. In case ofterminatedorsuspendedstate when user taps on notification app will be launched by callingdidFinishLaunchingWithOptionsandlaunchingOptionswill have the payload asDictionary.In case you provide
UNNotificationServiceExtensionthen iOS will calldidReceive(_: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/unnotificationserviceextensionIn case you provide
UNNotificationContentExtensionthen iOS will call thedidReceiveon 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-availablekey and must not contain alert, sound, or badge keys. read : https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.htmlWhere as in case of normal notification, there is no way to hide notification banner/alert/sound unless the user setting on phone says so.