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
- Start Xcode and have an iphone connected
- Add a breakpoint after the task is scheduled. In line one of
func scheduleBGProcessingTask
in swift - Start the app using the play button in Xcode
- A text input field will appear at the bottom of Xcode
- 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
Draft: !129 (closed)