Aminoid / react-native-activity-recognition

React Native wrapper for the Activity Recognition API.
GNU General Public License v2.0
93 stars 80 forks source link

Add methods for using mock data #5

Closed cooperka closed 6 years ago

cooperka commented 6 years ago

Motivation

Neither Android nor iOS has good support for mocking activity recognition (see this answer and this library to get an idea). It's very difficult to test a production app without some way of mocking these events.

Changes

⚠️ Note: This PR is currently based on https://github.com/Aminoid/react-native-activity-recognition/pull/4, so the diff is inaccurate. See here for the real diff. I can rebase after #4 is merged.

Example

const mockActivity = Platform.OS === 'ios'
  ? ActivityRecognition.IOS_AUTOMOTIVE
  : ActivityRecognition.ANDROID_IN_VEHICLE;

ActivityRecognition.startMocked(1000, mockActivity);
ActivityRecognition.stopMocked();
Aminoid commented 6 years ago

Thanks for the request @cooperka. Merged and is available in v3.2.0