Ios handles pushnotification in the background

I want to keep the push notification that will arrive when the application is in the background. I know about

-(void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo

This delegate method is called when the application is in the foreground or in the background (if the user simply clicks on the notification received).

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

This method is called only once when the application starts.

What if the user does not click on the notification? How to save the data of this notification in the database of my application in this case?

+1
source share
2 answers

In this case, you cannot save data in the "database of [your] application"; instead, you save the data in a database on your server, where PushNotification is primarily generated. Then, when your application is running, it queries your database to receive notification data.

+1
source

If the user does not click on the notification, you cannot save this data. Even if the user opens the application by clicking the start icon, the application will not receive this data.

Also remember that the notification design is designed to deliver a small payload to alert the user. After starting the application, the application can load the real data that you want to save.

+3
source

Source: https://habr.com/ru/post/1260980/


All Articles