简体   繁体   中英

iOS Swift - push notification: Save all Remote-Notifications in a Database (also while App is terminated)

I would like to save all received notifications in a database.

This works if someone clicks on the notification or the notification is received while the app is in the foreground.

But the challenge is to save the notification while the app is terminated (loud push).

After the launch of the terminated app the function didFinishLaunchingWithOptions is called but the launchOptions aways is nil so I can't handle push notifications.

Does anybody have any idea to solve this problem?

Thank you in advance.

Thanks to Goergisn.

The solution to my problem:

  1. Create an UNNotificationServiceExtension ( https://developer.apple.com/documentation/usernotifications/modifying_content_in_newly_delivered_notifications or https://medium.com/gits-apps-insight/processing-notification-data-using-notification-service-extension-6a2b5ea2da17 )
  2. Create an App Group
  3. Save data from Notification Service to App Group
  4. Create a function in the ViewController to transfer the data from the App Group into a sql-database

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM