keeping track of push notifications while in background Swift - swift

I'm trying to listen for a push notification while the app is running in the background. This is because when the app re enters the foreground I need it to update a counter of how many push notifications I received while I was in the background. Now when you click the push notification it brings you back to the app and updates fine, however if you press the home button receive a push notification and then reopen the background app manually the notification data is lost. How would I go about this?

To solve my problem I added 'content-available' => 1

Related

FCM Background handling in Flutter - iOS

What I want to achieve
I'm implementing FCM in flutter for iOS in such a way that in every state (foreground, background and terminated) when the notification is received, we need to show an alert with sound on the screen for some time (Say 2 mnts).
What is clear
Implementation is clear when the app is in foreground which can easily be done using onMessage callback.
Where is the issue
The confusion is with background and terminated part:
How to detect in the background that notification is received (I
know on Resume is called when we click on the notification in the
notification try). But we need to show alert on notification arrival
not on Clicking the notification.
How to detect when the app is terminated(I know onLaunch is called
when we click on the notification in the notification tray) But we
need to show alert on notification arrival not on Clicking the
notification.
Is it possible to show any system alert when the app is not running
like when notification is received while app is terminated and we
show a customized alert like Alarm alert on the screen.
There is onBackgroundMessage call back but I don't know if it works
for iOS (as documentation is more focused on Android settings in
onBackgroundMessage call back part).

Push notification is not working when app is opened

I have an issue with my app's push notification on ios 7, it works when app in back ground or remove it from dock. But push messages DO NOT work (not appearing) when the app screen comes to foreground.
But it was fine with iOS 6. Any change require in coding or storyboard settings?
When PushNotification is arrive it calls didReceiveRemoteNotification method when app is in foreground.
And when your app is not in foreground it will send to Notification Center, and if user tap on notification from notification center then it will call didReceiveRemoteNotificationmethod.
//According to Apple Push notification Document.
Push notifications serve much the same purpose as a background application on a desktop system, but without the additional overhead. For an application that is not currently running—or, in the case of iOS, not running in the foreground—the notification occurs indirectly.
Check Link :)

How does Groupon and Fab's push notifications show up as soon as I turn on my phone?

It seems as soon as I unlock my iPhone in the morning Groupon's notifications show up on the top of my notification tray. This can happen anywhere between 8-10am, so I was wondering how are they able to do this.

iOS add notification to the lockscreen that will not disappear

is it possible to add a notification to the lockscreen that will not disappear?
or (my second choice)
Is it possible to add a notification to the lockscreen, which will be thre until the iPhone is unlocked the next time?
For example:
iPhone is unlocked
message incoming
lock iPhone
message is in lockscreen
unlock iPhone
message is not longer in lockscreen
Edit:
My goal is to have a notification on the lockscreen every time.
No, neither is possible. If your app is in foreground, it gets delivered to your app directly and is not displayed. If the screen is locked or you app is in background, the notification is shown.
in ios5 there is a new feature in notification that notifications are automatically shown in the lockscreen if the user select the option from the setting but your app cannot receive any notification if your app in foreground.

Is it possible to receive push notifications in background mode

Is it possible to receive all push notifications that app recieved in background mode.
I mean that when app runned and then app went to background mode and then app recieve push notifications(in background mode) and user does not press view button on alert message (this button run app) and after some minutes user launch app, in this point I want get all push notifications that my app recieve in background mode.
Yes, applications can and do receive Push Notifications whether they are backgrounded or not even active. In your applicationDidEnterBackground: method you can check to see if your app has received a notification, then handle it from there.