Call a web service from iOS at a particular time daily in the background

橙三吉。 提交于 2019-12-01 01:19:12
Saheb Roy

You have the following options.

  1. Silent Notification : A silent push notification is pushed from the server, indicating that now is the time, you need to call the webservice and further do the necessary tasks. You will have around 30 seconds to complete the task. Now notice that during this it is not necessary that your app is opened, as this will be done in the background, without your app not opening.

    Follow this link here to configure your project with silent notification

  2. Location based (Geofencing / Location Change) : Well you manage your app by giving it a location, that whenever it enters/ exists / location is updated near to / on that particular location, the app even if terminated, will be launched in the background.

    applicationDidBeginLaunchingWithOptions will be called with a specific key notifying that this app was launched from a location change.

    Follow this link to configure your app accordingly. Now the caveat here is this wont depend on time, but rather a particular location or locations, whichever suits you.

  3. UILocalNotification or Push Notification : But in both cases, its no guarantee that user will interact with the notification banner and open the application in the first place.

Hence in the first option, you can do the work without the user interacting with the device (Device has to be connected to the internet) on Time based and Location based changes and in the second option User has to interact with the device (notification banner). Please choose the one best for your requirement.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!