20190726 Background App Refresh Taskがやってきた

Kei Ito
July 26, 2019

20190726 Background App Refresh Taskがやってきた

Kei Ito

July 26, 2019

Annual Pro sale · Save $30

Have presentations of your own?

Share with private links, password protection, and more control over your work.

Transcript

19 slides
  1. λεΫͷ౤ೖ func applicationDidEnterBackground(_ application: UIApplication) { scheduleAppRefresh() } func scheduleAppRefresh()

    { let request = BGAppRefreshTaskRequest(identifier: "XXX") request.earliestBeginDate = Date(timeIntervalSinceNow: 15 * 60) do { try BGTaskScheduler.shared.submit(request) } catch { print("Could not schedule app refresh: \(error)") } }
  2. λεΫͷ࣮ߦ func handleAppRefresh(task: BGAppRefreshTask) { // ඞཁ͕͋Ε͹࠶౤ೖ scheduleAppRefresh() task.expirationHandler =

    { // ࣮ߦظݶ͕੾Εͨͱ͖ͷΩϟϯηϧॲཧ } // do something // λεΫ׬ྃ task.setTaskCompleted(success: true) }

More Decks by Kei Ito

Other Decks in Programming