Skip to content

Latest commit

 

History

History
61 lines (41 loc) · 2.39 KB

File metadata and controls

61 lines (41 loc) · 2.39 KB

react-native-background-fetch Example App

Installation

  1. 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

⚠️ iOS: Test on a real device. The new iOS 13 BGTaskScheduler API does not work on Simulators.

Simulating Events

iOS

🆕 BGTaskScheduler API for iOS 13+

  • ⚠️ 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 to BackgroundFetch.configure will receive the event.

Old BackgroundFetch API

  • 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.

Android

  • 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