Refresh SQLite with push notification content when app is not running

Is there a way to update SQLite as soon as the push notification is received, but the app is not currently running (or the app was killed).

If notification comes while app is running or in background - didReceiveRemoteNotification method handles my update.

If the notification arrived when the app is not running, I want to update the content of the push notification to my sqlite. The update works when the user clicks on the notification, but it doesn't work when the user clicks on the app icon. Please help. Thank.

0


source to share


1 answer


I think there is no way to update the database without pushing. But if your app is using background modes like VOIP or location updates as stated in apple doc https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html



It can then wake up your application for a specific duration and do part of the update.

EDIT
By the way, when a push notification comes in, the server needs to be updated as well, I don't think push notifications are a good way to update your database. Instead, you should make a call to your server to get the latest local events and then update your sqlite. You can do this in didFinishLaunching or didEnterForeground. Just a suggestion.

+2


source







All Articles