instabug-reactnative/README.md

128 lines
4.3 KiB
Markdown
Raw Normal View History

2016-10-03 18:20:59 +00:00
2016-10-17 15:41:42 +00:00
# instabug-reactnative
## Dependencies
`react-native` version `>0.26`
2016-10-03 18:20:59 +00:00
2016-10-11 10:29:34 +00:00
## Installation
2016-10-03 18:20:59 +00:00
2016-10-04 09:41:36 +00:00
`$ npm install https://github.com/Instabug/instabug-reactnative --save`
2016-10-03 18:20:59 +00:00
2016-11-02 13:12:42 +00:00
`$ react-native link instabug-reactnative`
2017-01-20 18:52:04 +00:00
#### iOS installation
2016-10-03 18:20:59 +00:00
2016-10-09 12:50:04 +00:00
1. Open your app `.xcodeproj` file
2016-10-17 15:41:42 +00:00
2. Add the following line to your "Podfile": `pod 'Instabug', '~> 6.0.0'`
3. run `pod install`
4. Run your project (`Cmd+R`)<
2016-10-03 18:20:59 +00:00
2016-11-02 13:12:42 +00:00
#### Android Manual installation
1. Open up `android/app/src/main/java/[...]/MainApplication.java`
- Add
2016-11-02 13:22:35 +00:00
2016-11-02 13:12:42 +00:00
```java
import com.instabug.reactlibrary.RNInstabugReactnativePackage;
```
2016-11-02 13:22:35 +00:00
2016-11-02 13:12:42 +00:00
to the imports at the top of the file
- Add
2016-11-02 13:22:35 +00:00
2016-11-02 13:12:42 +00:00
```java
new RNInstabugReactnativePackage("YOUR_ANDROID_APPLICATION_TOKEN",MainApplication.this,"INVOCATION_EVENT");
```
2016-11-02 13:22:35 +00:00
2016-11-02 13:12:42 +00:00
to the list returned by the `getPackages()` method
2016-10-03 18:20:59 +00:00
2. Append the following lines to `android/settings.gradle`:
2016-11-02 13:22:35 +00:00
2016-11-02 13:12:42 +00:00
```gradle
2016-10-04 09:41:36 +00:00
include ':instabug-reactnative'
project(':instabug-reactnative').projectDir = new File(rootProject.projectDir, '../node_modules/instabug-reactnative/android')
2016-10-03 18:20:59 +00:00
```
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
2016-11-02 13:22:35 +00:00
2016-11-02 13:12:42 +00:00
```gradle
2016-10-04 09:41:36 +00:00
compile project(':instabug-reactnative')
2016-10-03 18:20:59 +00:00
```
2016-11-02 13:12:42 +00:00
## Usage
```javascript
import Instabug from'instabug-reactnative';
```
2016-10-03 18:20:59 +00:00
2016-11-02 13:12:42 +00:00
### iOS Example
```javascript
2016-10-09 12:50:04 +00:00
class testApp extends Component {
constructor() {
super();
2016-10-20 15:25:43 +00:00
Instabug.startWithToken('YOUR_TOKEN', Instabug.invocationEvent.floatingButton);
2016-10-09 12:50:04 +00:00
}
...
}
2016-10-03 18:20:59 +00:00
```
2016-10-17 16:03:04 +00:00
2016-10-20 15:27:47 +00:00
You can check the rest of the APIs here [Wiki](https://github.com/Instabug/instabug-reactnative/wiki).
2016-10-17 16:03:04 +00:00
If your app doesn't already access the microphone or photo library, you'll need to add the following 2 keys to your app's info.plist file:
NSMicrophoneUsageDescription
NSPhotoLibraryUsageDescription
2016-11-02 13:12:42 +00:00
### Android Example
Usage
2016-11-03 16:09:58 +00:00
To initialize Instabug in your app, you only need to link instabug-reactnative correctly by overwriting
2016-11-02 13:28:34 +00:00
"YOUR_ANDROID_TOKEN" text by your android app token,
2016-11-02 13:12:42 +00:00
"button" text by your desired invocation event,
"light" text by your desired color theme,
and can take a wide range of optional parameters for configuration.
1. Open up `android/app/src/main/java/[...]/MainApplication.java`
after linking the plugin, you should find the getPackages method looks like
```java
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new RNInstabugReactnativePackage("YOUR_ANDROID_TOKEN",MainApplication.this,"button","light")
);
}
```
The invocation event can be specified as one of the following values:
| value | native equivalent | description |
|:------------:|:-------------------------------------:|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
| 'shake' | InstabugInvocationEvent.SHAKE | Shaking the device while in any screen to show the feedback form. |
| 'button' | InstabugInvocationEvent.FLOATING_BUTTON | Shows a floating button on top of all views, when pressed it takes a screenshot. |
| 'screenshot' | InstabugInvocationEvent.SCREENSHOT_GESTURE | Taking a screenshot using the Home+Lock buttons while in any screen to show the feedback form, substituted with IBGInvocationEventShake on iOS 6.1.3 and earlier. |
| 'swipe' | InstabugInvocationEvent.TWO_FINGER_SWIPE_LEFT | Swiping two fingers left while in any screen to show the feedback form. |
| 'none' | InstabugInvocationEvent.NONE | No event will be registered to show the feedback form, you'll need to code your own and call the method invoke. |
The InstabugColorTheme can be specified as one of the following values:
2016-11-02 13:22:35 +00:00
2016-11-02 13:12:42 +00:00
| value | native equivalent | description |
|:------------:|:-------------------------------------:|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
| 'light'| InstabugColorTheme.InstabugColorThemeLight |light theme is color theme to use for the SDK's UI|
| 'dark'| InstabugColorTheme.InstabugColorThemeDark |Dark theme is color theme to use for the SDK's UI|
2016-10-04 09:41:36 +00:00
## License
This software is released under <a href="https://opensource.org/licenses/mit-license.php">MIT License</a>.
2017-01-20 18:52:04 +00:00
© 2016 Instabug. All rights reserved.