Release v1.0.1

This commit is contained in:
Hossam Hassan 2016-11-02 15:12:42 +02:00
parent b216ced0db
commit f7dfdb9170
5 changed files with 141 additions and 124 deletions

View File

@ -7,40 +7,52 @@
## Installation
#### iOS
`$ npm install https://github.com/Instabug/instabug-reactnative --save`
`$ rnpm link instabug-reactnative`
`$ react-native link instabug-reactnative`
#### iOS Manual installation
1. Open your app `.xcodeproj` file
2. Add the following line to your "Podfile": `pod 'Instabug', '~> 6.0.0'`
3. run `pod install`
4. Run your project (`Cmd+R`)<
#### Android (Pending)
#### Android Manual installation
`$ npm install https://github.com/Instabug/instabug-reactnative --save`
`$ rnpm link instabug-reactnative`
1. Open up `android/app/src/main/java/[...]/MainActivity.java`
- Add `import com.instabug.reactlibrary.RNInstabugReactnativePackage;` to the imports at the top of the file
- Add `new RNInstabugReactnativePackage()` to the list returned by the `getPackages()` method
1. Open up `android/app/src/main/java/[...]/MainApplication.java`
- Add
```java
import com.instabug.reactlibrary.RNInstabugReactnativePackage;
```
to the imports at the top of the file
- Add
```java
new RNInstabugReactnativePackage("YOUR_ANDROID_APPLICATION_TOKEN",MainApplication.this,"INVOCATION_EVENT");
```
to the list returned by the `getPackages()` method
2. Append the following lines to `android/settings.gradle`:
```
```gradle
include ':instabug-reactnative'
project(':instabug-reactnative').projectDir = new File(rootProject.projectDir, '../node_modules/instabug-reactnative/android')
```
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
```
```gradle
compile project(':instabug-reactnative')
```
## Usage
```javascript
import Instabug from'instabug-reactnative';
## Usage
```javascript
import Instabug from'instabug-reactnative';
```
### iOS Example
```javascript
class testApp extends Component {
constructor() {
super();
@ -52,13 +64,52 @@ class testApp extends Component {
You can check the rest of the APIs here [Wiki](https://github.com/Instabug/instabug-reactnative/wiki).
### iOS
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
### Android Example
Usage
To initialize Instabug in your app, you only need to link instabug-reactnative correctly by overriding "YOUR_ANDROID_TOKEN" text by your android app token,
"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:
| 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|
## License
This software is released under <a href="https://opensource.org/licenses/mit-license.php">MIT License</a>.

View File

@ -22,13 +22,11 @@ import java.util.Map;
public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
private Instabug mInstabug;
private String mAndroidApplicationToken;
private Instabug.Builder mBuilder;
private Application androidApplication;
private InstabugInvocationEvent invocationEvent;
public RNInstabugReactnativeModule(ReactApplicationContext reactContext, Application androidApplication) {
public RNInstabugReactnativeModule(ReactApplicationContext reactContext,Instabug mInstabug) {
super(reactContext);
this.androidApplication = androidApplication;
this.mInstabug = mInstabug;
}
@Override
@ -36,23 +34,15 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
return "Instabug";
}
/**
* start Instabug with default opetions
* default Invocation event Floating button
* @param androidApplicationToken
/**
* invoke sdk manually
*
* @param tags
*/
@ReactMethod
public void startWithToken(String androidApplicationToken,InstabugInvocationEvent invocationEvent)
public void invoke()
{
this.mAndroidApplicationToken = androidApplicationToken;
mInstabug = new Instabug.Builder(androidApplication, mAndroidApplicationToken)
.setEmailFieldRequired(false)
.setFloatingButtonOffsetFromTop(400)
.setTheme(InstabugColorTheme.InstabugColorThemeLight)
.setInvocationEvent(invocationEvent)
.setIntroMessageEnabled(false)
.build();
mInstabug.invoke();
}
/**
@ -194,12 +184,6 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
@Override
public Map<String, Object> getConstants() {
final Map<String, Object> constants = new HashMap<>();
constants.put("invocationEventFloatingButton", InstabugInvocationEvent.FLOATING_BUTTON);
constants.put("invocationEventTwoFingersSwipeLeft", InstabugInvocationEvent.TWO_FINGER_SWIPE_LEFTt);
constants.put("invocationEventScreenshot", InstabugInvocationEvent.SCREENSHOT_GESTURE);
constants.put("invocationEventShake", InstabugInvocationEvent.SHAKE);
constants.put("invocationEventNone", InstabugInvocationEvent.NONE);
return constants;
}
}

View File

@ -14,18 +14,76 @@ import com.facebook.react.uimanager.ViewManager;
import com.facebook.react.bridge.JavaScriptModule;
import com.instabug.library.Instabug;
import com.instabug.library.InstabugColorTheme;
import com.instabug.library.invocation.InstabugInvocationEvent;
public class RNInstabugReactnativePackage implements ReactPackage {
Application androidApplication;
public RNInstabugReactnativePackage(Application application) {
private String mAndroidApplicationToken;
private Instabug mInstabug;
private Instabug.Builder mBuilder;
private InstabugInvocationEvent invocationEvent=InstabugInvocationEvent.FLOATING_BUTTON;
private InstabugColorTheme instabugColorTheme=InstabugColorTheme.InstabugColorThemeLight;
public RNInstabugReactnativePackage(Instabug instabug) {
this.mInstabug = instabug;
}
public RNInstabugReactnativePackage(String androidApplicationToken,Application application) {
this.androidApplication = application;
this.mAndroidApplicationToken = androidApplicationToken;
mInstabug = new Instabug.Builder(androidApplication, mAndroidApplicationToken)
.setEmailFieldRequired(false)
.setFloatingButtonOffsetFromTop(400)
.setTheme(this.instabugColorTheme)
.setInvocationEvent(this.invocationEvent)
.setIntroMessageEnabled(false)
.build();
}
public RNInstabugReactnativePackage(String androidApplicationToken,Application application,String invocationEventValue) {
if(invocationEventValue.equals("button")) {
this.invocationEvent=InstabugInvocationEvent.FLOATING_BUTTON;
} else if(invocationEventValue.equals("swipe")) {
this.invocationEvent=InstabugInvocationEvent.TWO_FINGER_SWIPE_LEFT;
} else if(invocationEventValue.equals("shake")) {
this.invocationEvent=InstabugInvocationEvent.SHAKE;
} else if(invocationEventValue.equals("screenshot")){
this.invocationEvent=InstabugInvocationEvent.SCREENSHOT_GESTURE;
} else if(invocationEventValue.equals("none")) {
this.invocationEvent=InstabugInvocationEvent.NONE;
} else {
this.invocationEvent=InstabugInvocationEvent.FLOATING_BUTTON;
}
this(androidApplicationToken,application);
}
public RNInstabugReactnativePackage(String androidApplicationToken,Application application,String invocationEventValue,String instabugColorThemeValue) {
if (instabugColorThemeValue.equals("light")) {
this.instabugColorTheme=InstabugColorTheme.InstabugColorThemeLight;
} else if (instabugColorThemeValue.equals("dark")) {
this.instabugColorTheme=InstabugColorTheme.InstabugColorThemeDark;
} else {
this.instabugColorTheme=InstabugColorTheme.InstabugColorThemeLight;
}
this(androidApplicationToken,application,invocationEventValue);
}
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>();
modules.add(new RNInstabugReactnativeModule(reactContext,androidApplication));
modules.add(new RNInstabugReactnativeModule(reactContext, this.mInstabug));
return modules;
}

View File

@ -1,76 +0,0 @@
import {NativeModules} from 'react-native';
let {Instabug} = NativeModules;
module.exports = {
reportFeedback: function () {
Instabug.report('feedback');
},
reportBug: function () {
Instabug.report('bug');
},
/**
* Adds tag(s) to issues before sending them
* @param tags NOTICE: multiple tags with comma(,) split
*/
addTags: function (tags) {
Instabug.addTags(tags);
},
/**
[CHINA/CHINESE/PRC/SIMPLIFIED_CHINESE -> CHINESE]
[TAIWAN/TRADITIONAL_CHINESE -> TAIWAN]
[ENGLISH -> ENGLISH]
[UK -> UK]
[US -> US]
* @param languageTag
*/
changeLocale: function (languageTag) {
Instabug.changeLocale(tags);
},
/**
* The file at filePath will be uploaded along upcoming reports with the name fileNameWithExtension
* @param fileUri
* @param fileNameWithExtension
*/
setFileAttachment: function (fileUri, fileNameWithExtension) {
Instabug.setFileAttachment(fileUri, fileNameWithExtension);
},
/**
* If your app already acquires the user's email address and you provide it to this method,
* Instabug will pre-fill the user email in reports.
* @param userEmail
*/
setUserEmail: function (userEmail) {
Instabug.setUserEmail(userEmail);
},
/**
* Sets the user name that is used in the dashboard's contacts.
* @param username
*/
setUsername: function (username) {
Instabug.setUsername(username);
},
/**
* Adds specific user data that you need to be added to the reports
* @param userData
*/
setUserData: function (userData) {
Instabug.setUserData(userData);
},
/**
* Call this method to display the discovery dialog explaining the shake gesture or the two finger swipe gesture,
* if you've enabled it i.e: This method is automatically called on first run of the application
*/
showIntroMessage: function () {
Instabug.showIntroMessage();
},
};

View File

@ -1,7 +1,7 @@
{
"name": "instabug-reactnative",
"version": "1.0.0",
"version": "1.0.1",
"description": "React Native plugin for integrating the Instabug SDK",
"main": "index.js",
"scripts": {
@ -27,7 +27,7 @@
"homepage": "https://github.com/Instabug/instabug-reactnative#readme",
"rnpm": {
"android": {
"packageInstance": "new RNInstabugReactnativePackage(MainApplication.this)"
"packageInstance": "new RNInstabugReactnativePackage("YOUR_ANDROID_APPLICATION_TOKEN",MainApplication.this,"button")"
}
}
}