Skip to content

iOS+Android background processing for syncing chain state

WARNING: Simulators do not support background processing

Blockchain sync in the iOS foreground sync was too slow, and when the app went to the background the sync halted.

Therefore, NFTs could not be discovered upon receiving them and were not visible in iOS until the sync was complete.

The sync would require the app to stay in the foreground for a VERY long time.

FIX:

iOS background processing.

Background sync methods in MainViewController.kt that are called from swift

Use both app refresh and background processing

scheduleAppRefreshTask when the app enters the background

Run scheduleBGProcessingTask in init()

Run scheduleBGProcessingTask error handling

Trigger background processing task from Xcode

  1. Start Xcode and have an iphone connected
  2. Add a breakpoint after the task is scheduled. In line one of func scheduleBGProcessingTask in swift
  3. Start the app using the play button in Xcode
  4. A text input field will appear at the bottom of Xcode
  5. Enter the following command in the text field to trigger func handleBackgroundProcessing
e -l objc -- (void)[[BGTaskScheduler sharedScheduler] _simulateLaunchForTaskWithIdentifier:@"info.bitcoinunlimited.www.wally.backgroundProcessing"]

Alternatively, fire func handleBackgroundAppRefresh:

e -l objc -- (void)[[BGTaskScheduler sharedScheduler] _simulateLaunchForTaskWithIdentifier:@"info.bitcoinunlimited.www.wally.appRefresh"]

References:

https://www.peppe.app/how-to-use-backgroundtask-in-swiftui/

https://forums.developer.apple.com/forums/thread/744399

https://itnext.io/swift-ios-13-backgroundtasks-framework-background-app-refresh-in-4-steps-3da32e65bc3d

Draft: !129 (closed)

Edited by Jørgen Svennevik Notland

Merge request reports