Background Fetch at Specific Time

后端 未结 4 1319
时光说笑
时光说笑 2021-02-13 02:36

I am looking for solution to get data in background mode even app is terminated. There are lots of tutorials and answers available for this questions, but my questions is differ

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-13 03:17

    This is something which is not documented anywhere. IMHO and experience with iOS, Apple must be recording user activities since the start of the iOS era. ScreenTime is a product of those recordings only that apple was able to create and visualize the data to present a user facing app that very beautifully restricts, manages and displays your activities. In WWDC 2018, it was even quoted that apple will even detect, if the user opens your app at let's say 9 PM daily before going to bed, iOS will allow every possible resource (battery, internet, processing time etc) to that app at 9 PM. But you need to understand your user activities before you do this. Let's take an example of:

    News App: A majority of users would check the news in the morning (If they are not instagram addicts). At this time even apple should be biased to open your app with background fetch. Unless of-course there is too much of a resource crunch

    A Game: Many games allow provide a restriction time by calling it "recharge" or "re-fill" the energy of a character before user can play another round. This is done so that the addicted person would buy gems to remove that restriction and hence monetize the idea. But if you know that the refill process is completed before 8:00 AM in the morning or user plays your game daily at 8:00 AM configure background fetch accordingly.

    Background fetch works with interval rather than specific time.

    // Fetch data once an hour.
       UIApplication.shared.setMinimumBackgroundFetchInterval(3600)
    

    Lastly why don't you try silent push notifications? Based on your question, I think silent notification is enough to wake your app after a push notification from the server, download some data and do your calculation and provide a local notification.

提交回复
热议问题