- Clone this repo
$ git clone <url>
$ cd example
$ yarn install
$ cd ios
$ pod install
# Edit the ios/FetchDemo.xcodeproj/project.pbxproj file and set both lines with DEVELOPMENT_TEAM to your own Team ID. This can be found at https://developer.apple.com/account under Membership.
$ npx react-native run-android
$ npx react-native run-ios
BGTaskScheduler
API does not work on Simulators.
⚠️ At the time of writing, the new task simulator does not yet work in Simulator; Only real devices.- See Apple docs Starting and Terminating Tasks During Development
- After running your app in XCode, Click the
[||]
button to initiate a Breakpoint. - In the console
(lldb)
, paste the following command (Note: use cursor up/down keys to cycle through previously run commands):
e -l objc -- (void)[[BGTaskScheduler sharedScheduler] _simulateLaunchForTaskWithIdentifier:@"com.transistorsoft.fetch"]
- Click the
[ > ]
button to continue. The task will execute and the Callback function provided toBackgroundFetch.configure
will receive the event.
- Simulate background fetch events in XCode using
Debug->Simulate Background Fetch
- iOS can take some hours or even days to start a consistently scheduling background-fetch events since iOS schedules fetch events based upon the user's patterns of activity. If Simulate Background Fetch works, your can be sure that everything is working fine. You just need to wait.
- Observe plugin logs in
$ adb logcat
:
$ adb logcat *:S ReactNative:V ReactNativeJS:V TSBackgroundFetch:V
- Simulate a background-fetch event on a device (insert <your.application.id>) (only works for sdk
21+
:
$ ./scripts/simulate-fetch