├── android
├── src
│ └── main
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ └── com
│ │ └── kenny
│ │ └── instabug
│ │ ├── InstabugPackage.java
│ │ └── InstabugModule.java
├── .gitignore
├── README.md
└── build.gradle
├── ios
├── README.md
├── .gitignore
├── RCTInstabug
│ ├── RCTInstabug.h
│ └── RCTInstabug.m
└── RCTInstabug.xcodeproj
│ └── project.pbxproj
├── .gitignore
├── index.ios.js
├── .npmignore
├── .eslintrc.json
├── .travis.yml
├── LICENSE
├── package.json
├── example
├── index.ios.js
└── index.android.js
├── index.android.js
├── README_CHINESE.md
└── README.md
/android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/android/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 | *.iml
3 | .idea/
4 | gradle/
5 | local.properties
6 | gradlew
7 | gradlew.bat
--------------------------------------------------------------------------------
/ios/README.md:
--------------------------------------------------------------------------------
1 | ## iOS coming soon
2 |
3 | https://instabug.com/public/ios-api-reference/Classes/Instabug.html
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .idea/
3 |
4 | .DS_Store
5 | android/.DS_Store
6 | ios/.DS_Store
7 |
8 | build/
9 | node_modules/
--------------------------------------------------------------------------------
/android/README.md:
--------------------------------------------------------------------------------
1 | ## ReactInstabug
2 |
3 | https://instabug.com/public/android-api-reference/com/instabug/library/Instabug.html
--------------------------------------------------------------------------------
/ios/.gitignore:
--------------------------------------------------------------------------------
1 | project.xcworkspace/xcuserdata/
2 | RCTInstabug.xcodeproj/project.xcworkspace/
3 | RCTInstabug.xcodeproj/xcuserdata/
--------------------------------------------------------------------------------
/ios/RCTInstabug/RCTInstabug.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import "RCTBridgeModule.h"
3 |
4 | @interface RCTInstabug : NSObject
5 |
6 | @end
7 |
--------------------------------------------------------------------------------
/index.ios.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | import { NativeModules } from 'react-native';
4 |
5 | let { RCTInstabug } = NativeModules;
6 |
7 | module.exports = {
8 |
9 | };
10 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .idea/
3 | .DS_Store
4 |
5 | android/.DS_Store
6 | android/android.iml
7 | android/gradlew
8 | android/gradlew.bat
9 | android/local.properties
10 |
11 | ios/.DS_Store
12 | ios/RCTInstabug.xcodeproj/project.xcworkspace/
13 | ios/RCTInstabug.xcodeproj/xcuserdata/
14 |
15 | .travis
16 | .travis.yml
17 |
18 | build/
19 | node_modules/
20 |
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.1"
6 |
7 | defaultConfig {
8 | minSdkVersion 16
9 | targetSdkVersion 23
10 | versionCode 1
11 | versionName "1.0"
12 | ndk {
13 | abiFilters "armeabi-v7a", "x86"
14 | }
15 | }
16 | lintOptions {
17 | warning 'InvalidPackage'
18 | }
19 | }
20 |
21 | dependencies {
22 | compile 'com.facebook.react:react-native:+'
23 | compile 'com.instabug.library:instabug:2+'
24 | }
25 |
--------------------------------------------------------------------------------
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "env": {
3 | "browser": true,
4 | "es6": true
5 | },
6 | "extends": "eslint:recommended",
7 | "parserOptions": {
8 | "sourceType": "module"
9 | },
10 | "rules": {
11 | "indent": [
12 | "error",
13 | 4
14 | ],
15 | "linebreak-style": [
16 | "error",
17 | "unix"
18 | ],
19 | "quotes": [
20 | "error",
21 | "single"
22 | ],
23 | "semi": [
24 | "error",
25 | "always"
26 | ]
27 | }
28 | }
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 |
3 | sudo: true
4 |
5 | node_js:
6 | - "6.9.1"
7 |
8 | env:
9 | - CXX=g++-4.8
10 |
11 | before_cache:
12 | - rm -rf android/.gradle/caches
13 | - rm -rf node_modules
14 |
15 | cache:
16 | directories:
17 | - node_modules
18 | - android/.gradle/caches
19 | - android/.gradle/wrapper
20 |
21 | before_install:
22 | - npm install -g react-native-cli
23 | #- rm -rf InstagbugDemo
24 |
25 | notifications:
26 | email: false
27 |
28 | branches:
29 | only:
30 | - develop
31 |
32 | script:
33 | - react-native init InstagbugDemo
34 | - cd InstagbugDemo
35 | - npm install react-native-instabug --save
36 | # - react-native link
37 |
38 | after_script:
39 | - npm uninstall react-native-instabug --save
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 Kennytian
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/ios/RCTInstabug/RCTInstabug.m:
--------------------------------------------------------------------------------
1 | #import "RCTInstabug.h"
2 | #import "RCTConvert.h"
3 |
4 | @implementation RCTInstabug
5 |
6 | RCT_EXPORT_MODULE();
7 |
8 | RCT_EXPORT_METHOD(report:(NSString *)flag)
9 | {
10 | RCTLogInfo(@"You input result is %@", flag);
11 | }
12 |
13 | RCT_EXPORT_METHOD(addTags:(NSString *)tags)
14 | {
15 | RCTLogInfo(@"You input result is %@", tags);
16 | }
17 |
18 | RCT_EXPORT_METHOD(changeLocale:(NSString *)languageTag)
19 | {
20 | RCTLogInfo(@"You input result is %@", languageTag);
21 | }
22 |
23 | RCT_EXPORT_METHOD(setFileAttachment:(NSString *)fileUri fileNameWithExtension:(NSString *)fileNameWithExtension)
24 | {
25 | RCTLogInfo(@"You input result is %@ and %@", fileUri, fileNameWithExtension);
26 | }
27 |
28 | RCT_EXPORT_METHOD(setUserEmail:(NSString *)userEmail)
29 | {
30 | RCTLogInfo(@"You input result is %@", userEmail);
31 | }
32 |
33 | RCT_EXPORT_METHOD(setUsername:(NSString *)username)
34 | {
35 | RCTLogInfo(@"You input result is %@", username);
36 | }
37 |
38 | RCT_EXPORT_METHOD(setUserData:(NSString *)userData)
39 | {
40 | RCTLogInfo(@"You input result is %@", userData);
41 | }
42 |
43 | RCT_EXPORT_METHOD(showIntroMessage)
44 | {
45 | RCTLogInfo(@"showIntroMessage");
46 | }
47 |
48 | @end
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-native-instabug",
3 | "version": "3.0.1",
4 | "description": "React Native plugin for integrating the Instabug SDK",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "make test"
8 | },
9 | "repository": {
10 | "type": "git",
11 | "url": "git+https://github.com/Kennytian/react-native-instabug.git"
12 | },
13 | "keywords": [
14 | "react-native",
15 | "bug",
16 | "feedback",
17 | "reporting",
18 | "instabug",
19 | "sdk"
20 | ],
21 | "author": {
22 | "name": "Kenny Tian",
23 | "url": "https://github.com/Kennytian",
24 | "email": "kenny_tian@outlook.com"
25 | },
26 | "contributors": [
27 | {
28 | "name": "张艳",
29 | "url": "https://github.com/emmaplus",
30 | "email": "zy_sunday@163.com"
31 | },
32 | {
33 | "name": "Prithvi Sharma",
34 | "url": "https://github.com/prithsharma"
35 | }
36 | ],
37 | "license": "MIT",
38 | "bugs": {
39 | "url": "https://github.com/Kennytian/react-native-instabug/issues"
40 | },
41 | "homepage": "https://github.com/Kennytian/react-native-instabug#readme",
42 | "rnpm": {
43 | "android": {
44 | "packageInstance": "new InstabugPackage(${androidApplicationToken}, MainApplication.this)"
45 | },
46 | "params": [
47 | {
48 | "type": "input",
49 | "name": "androidApplicationToken",
50 | "message": "What is your Instabug application token for Android (hit to ignore)"
51 | }
52 | ],
53 | "commands": {
54 | "postlink": "node node_modules/react-native-instabug/scripts/postlink/run"
55 | }
56 | },
57 | "devDependencies": {
58 | "babel-eslint": "^7.1.0",
59 | "eslint": "^3.9.0",
60 | "eslint-config-airbnb": "^12.0.0",
61 | "eslint-plugin-import": "^1.16.0",
62 | "eslint-plugin-jsx-a11y": "^2.2.3",
63 | "eslint-plugin-react": "^6.4.1"
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/android/src/main/java/com/kenny/instabug/InstabugPackage.java:
--------------------------------------------------------------------------------
1 | package com.kenny.instabug;
2 |
3 | import android.app.Application;
4 |
5 | import com.facebook.react.ReactPackage;
6 | import com.facebook.react.bridge.JavaScriptModule;
7 | import com.facebook.react.bridge.NativeModule;
8 | import com.facebook.react.bridge.ReactApplicationContext;
9 | import com.facebook.react.uimanager.ViewManager;
10 | import com.instabug.library.IBGColorTheme;
11 | import com.instabug.library.Instabug;
12 |
13 | import java.util.ArrayList;
14 | import java.util.Collections;
15 | import java.util.List;
16 |
17 | public class InstabugPackage implements ReactPackage {
18 | private String mToken;
19 | private Application mApplication;
20 |
21 | private Instabug mInstagbug;
22 |
23 | public InstabugPackage(String token, Application application) {
24 | this.mToken = token;
25 | this.mApplication = application;
26 |
27 | mInstagbug = new Instabug.Builder(mApplication, mToken)
28 | .setDebugEnabled(true)
29 | .setEmailFieldRequired(false)
30 | .setFloatingButtonOffsetFromTop(400)
31 | .setColorTheme(IBGColorTheme.IBGColorThemeDark)
32 | .setShouldShowIntroDialog(false)
33 | .build();
34 | }
35 |
36 | @Override
37 | public List createNativeModules(ReactApplicationContext reactContext) {
38 | List modules = new ArrayList();
39 | modules.add(new InstabugModule(reactContext, this.mInstagbug));
40 | return modules;
41 | }
42 |
43 | @Override
44 | public List> createJSModules() {
45 | return Collections.emptyList();
46 | }
47 |
48 | @Override
49 | public List createViewManagers(ReactApplicationContext reactContext) {
50 | return Collections.emptyList();
51 | }
52 | }
--------------------------------------------------------------------------------
/example/index.ios.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Sample React Native App
3 | * https://github.com/facebook/react-native
4 | * @flow
5 | */
6 |
7 | import React, {Component} from 'react';
8 | import {
9 | AppRegistry,
10 | StyleSheet,
11 | Text,
12 | View,
13 | TouchableOpacity,
14 | } from 'react-native';
15 | //import Instabug from 'react-native-instabug';
16 |
17 | class MyProject extends Component {
18 | render() {
19 | return (
20 |
21 |
22 | Welcome to React Native!
23 |
24 |
25 | To get started, edit index.ios.js
26 |
27 |
28 | Shake or press menu button for dev menu
29 |
30 | this._testShowIntroMessage()}>
31 | Show intro message
32 |
33 | this._testInstabug()}>
34 | Click show me
35 |
36 |
37 | );
38 | }
39 |
40 | _testShowIntroMessage() {
41 | //Instabug.showIntroMessage();
42 | }
43 |
44 | _testInstabug() {
45 | //Instabug.setUserEmail('your@gmail.com');
46 | //Instabug.setUserData('This is your committed user data');
47 | //Instabug.setUsername('Your user name');
48 | //Instabug.addTags('react-native,bug,feedback,instabug');
49 | //Instabug.changeLocale('CHINESE');
50 | //Instabug.reportBug();
51 | }
52 | }
53 |
54 | const styles = StyleSheet.create({
55 | container: {
56 | flex: 1,
57 | justifyContent: 'center',
58 | alignItems: 'center',
59 | backgroundColor: '#F5FCFF',
60 | },
61 | welcome: {
62 | fontSize: 20,
63 | textAlign: 'center',
64 | margin: 10,
65 | },
66 | instructions: {
67 | textAlign: 'center',
68 | color: '#333333',
69 | marginBottom: 5,
70 | },
71 | });
72 |
73 | AppRegistry.registerComponent('MyProject', () => MyProject);
--------------------------------------------------------------------------------
/example/index.android.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Sample React Native App
3 | * https://github.com/facebook/react-native
4 | * @flow
5 | */
6 |
7 | import React, {Component} from 'react';
8 | import {
9 | AppRegistry,
10 | StyleSheet,
11 | Text,
12 | View,
13 | TouchableOpacity,
14 | } from 'react-native';
15 | import Instabug from 'react-native-instabug';
16 |
17 | class MyProject extends Component {
18 | render() {
19 | return (
20 |
21 |
22 | Welcome to React Native!
23 |
24 |
25 | To get started, edit index.android.js
26 |
27 |
28 | Double tap R on your keyboard to reload,{'\n'}
29 | Shake or press menu button for dev menu
30 |
31 | this._testShowIntroMessage()}>
32 | Show intro message
33 |
34 | this._testInstabug()}>
35 | Click show me
36 |
37 |
38 | );
39 | }
40 |
41 | _testShowIntroMessage() {
42 | Instabug.showIntroMessage();
43 | }
44 |
45 | _testInstabug() {
46 | Instabug.setUserEmail('your@gmail.com');
47 | Instabug.setUserData('This is your committed user data');
48 | Instabug.setUsername('Your user name');
49 | Instabug.addTags('react-native,bug,feedback,instabug');
50 | Instabug.changeLocale('CHINESE');
51 | Instabug.changeInvocationEvent('Shake');
52 | Instabug.reportBug();
53 | }
54 | }
55 |
56 | const styles = StyleSheet.create({
57 | container: {
58 | flex: 1,
59 | justifyContent: 'center',
60 | alignItems: 'center',
61 | backgroundColor: '#F5FCFF',
62 | },
63 | welcome: {
64 | fontSize: 20,
65 | textAlign: 'center',
66 | margin: 10,
67 | },
68 | instructions: {
69 | textAlign: 'center',
70 | color: '#333333',
71 | marginBottom: 5,
72 | },
73 | });
74 |
75 | AppRegistry.registerComponent('MyProject', () => MyProject);
--------------------------------------------------------------------------------
/index.android.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | import { NativeModules } from 'react-native';
4 |
5 | let { Instabug } = NativeModules;
6 |
7 | module.exports = {
8 |
9 | //can not work
10 | startWithToken: function (token) {
11 | Instabug.startWithToken(token);
12 | },
13 |
14 | /**
15 | * Dismisses any Instabug views that are currently being shown.
16 | */
17 | dismiss: function () {
18 | Instabug.dismiss();
19 | },
20 |
21 | /**
22 | * Show Instabug dialog so user can choose to report a bug, or submit feedback
23 | */
24 | invoke: function () {
25 | Instabug.report('');
26 | },
27 |
28 | reportFeedback: function () {
29 | Instabug.report('feedback');
30 | },
31 |
32 | reportBug: function () {
33 | Instabug.report('bug');
34 | },
35 |
36 | /**
37 | * Adds tag(s) to issues before sending them
38 | * @param tags NOTICE: multiple tags with comma(,) split
39 | */
40 | addTags: function (tags) {
41 | Instabug.addTags(tags);
42 | },
43 |
44 | /**
45 | * None -> IBGInvocationEventNone
46 | * TwoFingersSwipeLeft -> IBGInvocationEventTwoFingersSwipeLeft
47 | * FloatingButton -> IBGInvocationEventFloatingButton
48 | * Shake -> IBGInvocationEventShake
49 | * ScreenshotGesture -> IBGInvocationScreenshotGesture
50 | *
51 | Changes the event used to invoke Instabug SDK
52 | * @param eventTag
53 | */
54 | changeInvocationEvent: function (eventTag) {
55 | Instabug.changeInvocationEvent(eventTag);
56 | },
57 |
58 | /**
59 | [CHINA/CHINESE/PRC/SIMPLIFIED_CHINESE -> CHINESE]
60 | [TAIWAN/TRADITIONAL_CHINESE -> TAIWAN]
61 | [ENGLISH -> ENGLISH]
62 | [UK -> UK]
63 | [US -> US]
64 | * @param languageTag
65 | */
66 | changeLocale: function (languageTag) {
67 | Instabug.changeLocale(languageTag);
68 | },
69 |
70 | /**
71 | * The file at filePath will be uploaded along upcoming reports with the name fileNameWithExtension
72 | * @param fileUri
73 | * @param fileNameWithExtension
74 | */
75 | setFileAttachment: function (fileUri, fileNameWithExtension) {
76 | Instabug.setFileAttachment(fileUri, fileNameWithExtension);
77 | },
78 |
79 | /**
80 | * If your app already acquires the user's email address and you provide it to this method,
81 | * Instabug will pre-fill the user email in reports.
82 | * @param userEmail
83 | */
84 | setUserEmail: function (userEmail) {
85 | Instabug.setUserEmail(userEmail);
86 | },
87 |
88 | /**
89 | * Sets the user name that is used in the dashboard's contacts.
90 | * @param username
91 | */
92 | setUsername: function (username) {
93 | Instabug.setUsername(username);
94 | },
95 |
96 | /**
97 | * Adds specific user data that you need to be added to the reports
98 | * @param userData
99 | */
100 | setUserData: function (userData) {
101 | Instabug.setUserData(userData);
102 | },
103 |
104 | /**
105 | * Call this method to display the discovery dialog explaining the shake gesture or the two finger swipe gesture,
106 | * if you've enabled it i.e: This method is automatically called on first run of the application
107 | */
108 | showIntroMessage: function () {
109 | Instabug.showIntroMessage();
110 | },
111 | };
112 |
--------------------------------------------------------------------------------
/README_CHINESE.md:
--------------------------------------------------------------------------------
1 | ## 摇一摇报Bug(Instabug)之 React Native 版
2 |
3 | README: [English](https://github.com/Kennytian/react-native-instabug/) | [中文](https://github.com/Kennytian/react-native-instabug/blob/master/README_CHINESE.md)
4 |
5 | [](https://travis-ci.org/Kennytian/react-native-instabug.svg?branch=develop)
6 | [](https://npmjs.org/package/react-native-instabug "View this project on npm")
7 | [](https://npmjs.org/package/react-native-instabug "View this project on npm")
8 | [](http://standardjs.com/)
9 | [](https://github.com/Kennytian/react-native-instabug/issues)
10 | [](https://github.com/Kennytian/react-native-instabug/pulls)
11 |
12 |
13 | [The Simplest In-App Feedback and Bug Reportng for Mobile Apps! ](https://instabug.com/developers)
14 |
15 | 
16 |
17 | ### 安装 NPM 包
18 |
19 | `npm install --save react-native-instabug`
20 |
21 | ### 自动安装(多数情况下能成功安装并集成到项目中)
22 |
23 | `react-native link react-native-instabug`
24 |
25 | ### 手动安装
26 | #### Android
27 | 编辑 android/settings.gradle,加这两行:
28 |
29 | ```diff
30 | include ':app'
31 |
32 | + include ':react-native-instabug'
33 | + project(':react-native-instabug').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-instabug/android')
34 | ```
35 |
36 | 编辑 android/app/build.gradle,加这一行:
37 | ```diff
38 | dependencies {
39 | compile fileTree(dir: "libs", include: ["*.jar"])
40 | compile "com.android.support:appcompat-v7:23.0.1"
41 | compile "com.facebook.react:react-native:+" // From node_modules
42 | + compile project(':react-native-instabug')
43 | }
44 | ```
45 |
46 | 编辑 MainApplication.java (在 android/app/src/main/java/...目录里) ,像这样,一共有两处(只支持 RN 0.29 以上版本,抱歉):
47 | ```diff
48 | + import com.kenny.instabug.InstabugPackage;
49 | ...
50 | new MainReactPackage(),
51 | + new InstabugPackage("your_app_token_here", MainApplication.this)
52 | }
53 | ```
54 |
55 | #### iOS
56 | ```diff
57 | - 欢迎懂 iOS 的开发者加入, 和我们一起完成这个控件!
58 | ```
59 |
60 | 1. 打开 XCode, 切换至 project navigator, 右键点击 `Libraries` ➜ `Add Files to [your project's name]`
61 | 2. 进入 `node_modules` ➜ `react-native-instabug` 并且添加 `ios/RCTInstabug.xcodeproj`
62 | 3. 接着在 XCode 切换至 project navigator, 选择你的项目。 添加 `libRCTInstabug.a` 到你的项目中 ➜ `Build Phases` ➜ `Link Binary With Libraries`
63 | 4. 运行项目 (`cmd+R`)
64 |
65 | ### 调用方式
66 |
67 | Android 端可以有大量 function 可以使用了,请戳这儿 [index.android.js](https://github.com/Kennytian/react-native-instabug/blob/master/example/index.android.js#L41),欢迎提 PR 和 issue。
68 |
69 | ```js
70 | _testShowIntroMessage() {
71 | Instabug.showIntroMessage();
72 | }
73 |
74 | _testInstabug() {
75 | Instabug.setUserEmail('your@gmail.com');
76 | Instabug.setUserData('This is your committed user data');
77 | Instabug.setUsername('Your user name');
78 | Instabug.addTags('react-native,bug,feedback,instabug');
79 | Instabug.changeInvocationEvent('Shake');
80 | Instabug.reportBug();
81 | }
82 | ```
83 |
84 | ### 致谢
85 | * @prithsharma https://github.com/prithsharma
86 | * @emmaplus https://github.com/emmaplus
87 | * @delfrrr https://github.com/delfrrr
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## React Native plugin for the Instabug service
2 |
3 | README: [English](https://github.com/Kennytian/react-native-instabug/) | [中文](https://github.com/Kennytian/react-native-instabug/blob/master/README_CHINESE.md)
4 |
5 | [](https://travis-ci.org/Kennytian/react-native-instabug.svg?branch=develop)
6 | [](https://npmjs.org/package/react-native-instabug "View this project on npm")
7 | [](https://npmjs.org/package/react-native-instabug "View this project on npm")
8 | [](http://standardjs.com/)
9 | [](https://github.com/Kennytian/react-native-instabug/issues)
10 | [](https://github.com/Kennytian/react-native-instabug/pulls)
11 |
12 |
13 | [The Simplest In-App Feedback and Bug Reportng for Mobile Apps! ](https://instabug.com/developers)
14 |
15 | 
16 |
17 | ### Getting Started
18 |
19 | `npm install --save react-native-instabug`
20 |
21 | ### Mostly automatic installation
22 |
23 | `react-native link react-native-instabug`
24 |
25 | ### Manual installation
26 | #### Android
27 | Edit android/settings.gradle to look like this:
28 |
29 | ```diff
30 | include ':app'
31 |
32 | + include ':react-native-instabug'
33 | + project(':react-native-instabug').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-instabug/android')
34 | ```
35 |
36 | Edit android/app/build.gradle to look like this:
37 | ```diff
38 | dependencies {
39 | compile fileTree(dir: "libs", include: ["*.jar"])
40 | compile "com.android.support:appcompat-v7:23.0.1"
41 | compile "com.facebook.react:react-native:+" // From node_modules
42 | + compile project(':react-native-instabug')
43 | }
44 | ```
45 |
46 | only RN 0.29+ Edit your MainApplication.java (deep in android/app/src/main/java/...) to look like this (note two places to edit):
47 | ```diff
48 | + import com.kenny.instabug.InstabugPackage;
49 | ...
50 | new MainReactPackage(),
51 | + new InstabugPackage("your_app_token_here", MainApplication.this)
52 | }
53 | ```
54 |
55 | #### iOS
56 | ```diff
57 | - Welcome iOS developer join, write this component together!
58 | ```
59 |
60 | 1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]`
61 | 2. Go to `node_modules` ➜ `react-native-instabug` and add `ios/RCTInstabug.xcodeproj`
62 | 3. In XCode, in the project navigator, select your project. Add `libRCTInstabug.a` to your project's `Build Phases` ➜ `Link Binary With Libraries`
63 | 4. Run your project (`Cmd+R`)<
64 |
65 | ### Usage
66 |
67 | To see all available function take a look at [index.android.js](https://github.com/Kennytian/react-native-instabug/blob/master/example/index.android.js#L41)
68 |
69 | ```js
70 | _testShowIntroMessage() {
71 | Instabug.showIntroMessage();
72 | }
73 |
74 | _testInstabug() {
75 | Instabug.setUserEmail('your@gmail.com');
76 | Instabug.setUserData('This is your committed user data');
77 | Instabug.setUsername('Your user name');
78 | Instabug.addTags('react-native,bug,feedback,instabug');
79 | Instabug.changeInvocationEvent('Shake');
80 | Instabug.reportBug();
81 | }
82 | ```
83 | ### Credits
84 | * @prithsharma https://github.com/prithsharma
85 | * @emmaplus https://github.com/emmaplus
86 | * @delfrrr https://github.com/delfrrr
87 |
--------------------------------------------------------------------------------
/android/src/main/java/com/kenny/instabug/InstabugModule.java:
--------------------------------------------------------------------------------
1 | package com.kenny.instabug;
2 |
3 | import android.net.Uri;
4 |
5 | import com.facebook.react.bridge.ReactApplicationContext;
6 | import com.facebook.react.bridge.ReactContextBaseJavaModule;
7 |
8 | import com.facebook.react.bridge.ReactMethod;
9 | import com.instabug.library.IBGInvocationEvent;
10 | import com.instabug.library.IBGInvocationMode;
11 | import com.instabug.library.Instabug;
12 |
13 | import java.util.Locale;
14 |
15 |
16 | public class InstabugModule extends ReactContextBaseJavaModule {
17 | private Instabug mInstabug;
18 |
19 | public InstabugModule(ReactApplicationContext reactContext, Instabug instabug) {
20 | super(reactContext);
21 | this.mInstabug = instabug;
22 | }
23 |
24 | public String getName() {
25 | return "Instabug";
26 | }
27 |
28 | //can not work
29 | @ReactMethod
30 | public void startWithToken(String token) {
31 | try {
32 | //TODO
33 | } catch (Exception e) {
34 | e.printStackTrace();
35 | }
36 | }
37 |
38 | /**
39 | * Adds tag(s) to issues before sending them
40 | *
41 | * @param tags
42 | */
43 | @ReactMethod
44 | public void addTags(String tags) {
45 | try {
46 | String[] result = tags.split(",");
47 | mInstabug.resetTags(); //clear last commit tags
48 | mInstabug.addTags(result);
49 | } catch (Exception e) {
50 | e.printStackTrace();
51 | }
52 | }
53 |
54 | /**
55 | * Dismisses any Instabug views that are currently being shown.
56 | */
57 | @ReactMethod
58 | public void dismiss() {
59 | try {
60 | mInstabug.dismiss();
61 | } catch (Exception e) {
62 | e.printStackTrace();
63 | }
64 | }
65 |
66 | /**
67 | * Changes the event used to invoke Instabug SDK
68 | *
69 | * @param eventTag
70 | */
71 | @ReactMethod
72 | public void changeInvocationEvent(String eventTag) {
73 | try {
74 | switch (eventTag) {
75 | case "TwoFingersSwipeLeft":
76 | mInstabug.changeInvocationEvent(IBGInvocationEvent.IBGInvocationEventTwoFingersSwipeLeft);
77 | break;
78 | case "FloatingButton":
79 | mInstabug.changeInvocationEvent(IBGInvocationEvent.IBGInvocationEventFloatingButton);
80 | break;
81 | case "Shake":
82 | mInstabug.changeInvocationEvent(IBGInvocationEvent.IBGInvocationEventShake);
83 | break;
84 | case "ScreenshotGesture":
85 | mInstabug.changeInvocationEvent(IBGInvocationEvent.IBGInvocationScreenshotGesture);
86 | break;
87 | case "None":
88 | default:
89 | mInstabug.changeInvocationEvent(IBGInvocationEvent.IBGInvocationEventNone);
90 | break;
91 | }
92 |
93 | } catch (Exception e) {
94 | e.printStackTrace();
95 | }
96 | }
97 |
98 | /**
99 | * Change Locale of Instabug UI elements(defaults to English)
100 | *
101 | * @param languageTag
102 | */
103 | @ReactMethod
104 | public void changeLocale(String languageTag) {
105 | try {
106 | switch (languageTag) {
107 | case "CHINA":
108 | case "CHINESE":
109 | case "PRC":
110 | case "SIMPLIFIED_CHINESE":
111 | mInstabug.changeLocale(Locale.CHINESE);
112 | break;
113 | case "TAIWAN":
114 | case "TRADITIONAL_CHINESE":
115 | mInstabug.changeLocale(Locale.TAIWAN);
116 | break;
117 | case "ENGLISH":
118 | mInstabug.changeLocale(Locale.ENGLISH);
119 | break;
120 | case "ITALIAN":
121 | mInstabug.changeLocale(Locale.ITALIAN);
122 | break;
123 | case "RUSSIAN":
124 | mInstabug.changeLocale(new Locale("ru", "RU"));
125 | break;
126 | case "UK":
127 | mInstabug.changeLocale(Locale.UK);
128 | break;
129 | case "US":
130 | default:
131 | mInstabug.changeLocale(Locale.US);
132 | break;
133 | }
134 |
135 | } catch (Exception e) {
136 | e.printStackTrace();
137 | }
138 | }
139 |
140 |
141 | @ReactMethod
142 | public void report(String value) {
143 | IBGInvocationMode mode;
144 | switch (value) {
145 | case "bug":
146 | mode = IBGInvocationMode.IBGInvocationModeBugReporter;
147 | break;
148 | case "feedback":
149 | mode = IBGInvocationMode.IBGInvocationModeFeedbackSender;
150 | break;
151 | default:
152 | mode = IBGInvocationMode.IBGInvocationModeNA;
153 | break;
154 | }
155 |
156 | mInstabug.invoke(mode);
157 | }
158 |
159 | /**
160 | * The file at filePath will be uploaded along upcoming reports with the name fileNameWithExtension
161 | *
162 | * @param fileUri
163 | * @param fileNameWithExtension
164 | */
165 | @ReactMethod
166 | public void setFileAttachment(String fileUri, String fileNameWithExtension) {
167 | try {
168 | Uri uri = Uri.parse(fileUri);
169 | mInstabug.setFileAttachment(uri, fileNameWithExtension);
170 | } catch (Exception e) {
171 | e.printStackTrace();
172 | }
173 | }
174 |
175 | /**
176 | * If your app already acquires the user's email address and you provide it to this method,
177 | * Instabug will pre-fill the user email in reports.
178 | *
179 | * @param userEmail
180 | */
181 | @ReactMethod
182 | public void setUserEmail(String userEmail) {
183 | try {
184 | mInstabug.setUserEmail(userEmail);
185 | } catch (Exception e) {
186 | e.printStackTrace();
187 | }
188 | }
189 |
190 | /**
191 | * Sets the user name that is used in the dashboard's contacts.
192 | *
193 | * @param username
194 | */
195 | @ReactMethod
196 | public void setUsername(String username) {
197 | try {
198 | mInstabug.setUsername(username);
199 | } catch (Exception e) {
200 | e.printStackTrace();
201 | }
202 | }
203 |
204 | /**
205 | * Adds specific user data that you need to be added to the reports
206 | *
207 | * @param userData
208 | */
209 | @ReactMethod
210 | public void setUserData(String userData) {
211 | try {
212 | mInstabug.setUserData(userData);
213 | } catch (Exception e) {
214 | e.printStackTrace();
215 | }
216 | }
217 |
218 | /**
219 | * Call this method to display the discovery dialog explaining the shake gesture or the two
220 | * finger swipe gesture, if you've enabled it.
221 | * i.e: This method is automatically called on first run of the application
222 | */
223 | @ReactMethod
224 | public void showIntroMessage() {
225 | try {
226 | mInstabug.showIntroMessage();
227 | } catch (Exception e) {
228 | e.printStackTrace();
229 | }
230 | }
231 | }
--------------------------------------------------------------------------------
/ios/RCTInstabug.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | B5EA19F31DA156B9009F9814 /* RCTInstabug.h in Headers */ = {isa = PBXBuildFile; fileRef = B5EA19F21DA156B9009F9814 /* RCTInstabug.h */; };
11 | B5EA19F51DA156B9009F9814 /* RCTInstabug.m in Sources */ = {isa = PBXBuildFile; fileRef = B5EA19F41DA156B9009F9814 /* RCTInstabug.m */; };
12 | /* End PBXBuildFile section */
13 |
14 | /* Begin PBXFileReference section */
15 | B5EA19EF1DA156B9009F9814 /* libRCTInstabug.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTInstabug.a; sourceTree = BUILT_PRODUCTS_DIR; };
16 | B5EA19F21DA156B9009F9814 /* RCTInstabug.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RCTInstabug.h; sourceTree = ""; };
17 | B5EA19F41DA156B9009F9814 /* RCTInstabug.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RCTInstabug.m; sourceTree = ""; };
18 | /* End PBXFileReference section */
19 |
20 | /* Begin PBXFrameworksBuildPhase section */
21 | B5EA19EC1DA156B9009F9814 /* Frameworks */ = {
22 | isa = PBXFrameworksBuildPhase;
23 | buildActionMask = 2147483647;
24 | files = (
25 | );
26 | runOnlyForDeploymentPostprocessing = 0;
27 | };
28 | /* End PBXFrameworksBuildPhase section */
29 |
30 | /* Begin PBXGroup section */
31 | B5EA19E61DA156B9009F9814 = {
32 | isa = PBXGroup;
33 | children = (
34 | B5EA19F11DA156B9009F9814 /* RCTInstabug */,
35 | B5EA19F01DA156B9009F9814 /* Products */,
36 | );
37 | sourceTree = "";
38 | };
39 | B5EA19F01DA156B9009F9814 /* Products */ = {
40 | isa = PBXGroup;
41 | children = (
42 | B5EA19EF1DA156B9009F9814 /* libRCTInstabug.a */,
43 | );
44 | name = Products;
45 | sourceTree = "";
46 | };
47 | B5EA19F11DA156B9009F9814 /* RCTInstabug */ = {
48 | isa = PBXGroup;
49 | children = (
50 | B5EA19F21DA156B9009F9814 /* RCTInstabug.h */,
51 | B5EA19F41DA156B9009F9814 /* RCTInstabug.m */,
52 | );
53 | path = RCTInstabug;
54 | sourceTree = "";
55 | };
56 | /* End PBXGroup section */
57 |
58 | /* Begin PBXHeadersBuildPhase section */
59 | B5EA19ED1DA156B9009F9814 /* Headers */ = {
60 | isa = PBXHeadersBuildPhase;
61 | buildActionMask = 2147483647;
62 | files = (
63 | B5EA19F31DA156B9009F9814 /* RCTInstabug.h in Headers */,
64 | );
65 | runOnlyForDeploymentPostprocessing = 0;
66 | };
67 | /* End PBXHeadersBuildPhase section */
68 |
69 | /* Begin PBXNativeTarget section */
70 | B5EA19EE1DA156B9009F9814 /* RCTInstabug */ = {
71 | isa = PBXNativeTarget;
72 | buildConfigurationList = B5EA19F81DA156B9009F9814 /* Build configuration list for PBXNativeTarget "RCTInstabug" */;
73 | buildPhases = (
74 | B5EA19EB1DA156B9009F9814 /* Sources */,
75 | B5EA19EC1DA156B9009F9814 /* Frameworks */,
76 | B5EA19ED1DA156B9009F9814 /* Headers */,
77 | );
78 | buildRules = (
79 | );
80 | dependencies = (
81 | );
82 | name = RCTInstabug;
83 | productName = RCTInstabug;
84 | productReference = B5EA19EF1DA156B9009F9814 /* libRCTInstabug.a */;
85 | productType = "com.apple.product-type.library.static";
86 | };
87 | /* End PBXNativeTarget section */
88 |
89 | /* Begin PBXProject section */
90 | B5EA19E71DA156B9009F9814 /* Project object */ = {
91 | isa = PBXProject;
92 | attributes = {
93 | LastUpgradeCheck = 0720;
94 | ORGANIZATIONNAME = "react-native-instabug";
95 | TargetAttributes = {
96 | B5EA19EE1DA156B9009F9814 = {
97 | CreatedOnToolsVersion = 7.2.1;
98 | };
99 | };
100 | };
101 | buildConfigurationList = B5EA19EA1DA156B9009F9814 /* Build configuration list for PBXProject "RCTInstabug" */;
102 | compatibilityVersion = "Xcode 3.2";
103 | developmentRegion = English;
104 | hasScannedForEncodings = 0;
105 | knownRegions = (
106 | en,
107 | );
108 | mainGroup = B5EA19E61DA156B9009F9814;
109 | productRefGroup = B5EA19F01DA156B9009F9814 /* Products */;
110 | projectDirPath = "";
111 | projectRoot = "";
112 | targets = (
113 | B5EA19EE1DA156B9009F9814 /* RCTInstabug */,
114 | );
115 | };
116 | /* End PBXProject section */
117 |
118 | /* Begin PBXSourcesBuildPhase section */
119 | B5EA19EB1DA156B9009F9814 /* Sources */ = {
120 | isa = PBXSourcesBuildPhase;
121 | buildActionMask = 2147483647;
122 | files = (
123 | B5EA19F51DA156B9009F9814 /* RCTInstabug.m in Sources */,
124 | );
125 | runOnlyForDeploymentPostprocessing = 0;
126 | };
127 | /* End PBXSourcesBuildPhase section */
128 |
129 | /* Begin XCBuildConfiguration section */
130 | B5EA19F61DA156B9009F9814 /* Debug */ = {
131 | isa = XCBuildConfiguration;
132 | buildSettings = {
133 | ALWAYS_SEARCH_USER_PATHS = NO;
134 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
135 | CLANG_CXX_LIBRARY = "libc++";
136 | CLANG_ENABLE_MODULES = YES;
137 | CLANG_ENABLE_OBJC_ARC = YES;
138 | CLANG_WARN_BOOL_CONVERSION = YES;
139 | CLANG_WARN_CONSTANT_CONVERSION = YES;
140 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
141 | CLANG_WARN_EMPTY_BODY = YES;
142 | CLANG_WARN_ENUM_CONVERSION = YES;
143 | CLANG_WARN_INT_CONVERSION = YES;
144 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
145 | CLANG_WARN_UNREACHABLE_CODE = YES;
146 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
147 | CODE_SIGN_IDENTITY = "-";
148 | COPY_PHASE_STRIP = NO;
149 | DEBUG_INFORMATION_FORMAT = dwarf;
150 | ENABLE_STRICT_OBJC_MSGSEND = YES;
151 | ENABLE_TESTABILITY = YES;
152 | GCC_C_LANGUAGE_STANDARD = gnu99;
153 | GCC_DYNAMIC_NO_PIC = NO;
154 | GCC_NO_COMMON_BLOCKS = YES;
155 | GCC_OPTIMIZATION_LEVEL = 0;
156 | GCC_PREPROCESSOR_DEFINITIONS = (
157 | "DEBUG=1",
158 | "$(inherited)",
159 | );
160 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
161 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
162 | GCC_WARN_UNDECLARED_SELECTOR = YES;
163 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
164 | GCC_WARN_UNUSED_FUNCTION = YES;
165 | GCC_WARN_UNUSED_VARIABLE = YES;
166 | HEADER_SEARCH_PATHS = (
167 | "$(inherited)",
168 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
169 | "$(SRCROOT)/../../react-native/React/**",
170 | );
171 | IPHONEOS_DEPLOYMENT_TARGET = 7.0;
172 | LIBRARY_SEARCH_PATHS = "$(inherited)";
173 | MTL_ENABLE_DEBUG_INFO = YES;
174 | ONLY_ACTIVE_ARCH = YES;
175 | OTHER_LDFLAGS = (
176 | "-ObjC",
177 | "-lz",
178 | );
179 | SDKROOT = iphoneos;
180 | SKIP_INSTALL = YES;
181 | };
182 | name = Debug;
183 | };
184 | B5EA19F71DA156B9009F9814 /* Release */ = {
185 | isa = XCBuildConfiguration;
186 | buildSettings = {
187 | ALWAYS_SEARCH_USER_PATHS = NO;
188 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
189 | CLANG_CXX_LIBRARY = "libc++";
190 | CLANG_ENABLE_MODULES = YES;
191 | CLANG_ENABLE_OBJC_ARC = YES;
192 | CLANG_WARN_BOOL_CONVERSION = YES;
193 | CLANG_WARN_CONSTANT_CONVERSION = YES;
194 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
195 | CLANG_WARN_EMPTY_BODY = YES;
196 | CLANG_WARN_ENUM_CONVERSION = YES;
197 | CLANG_WARN_INT_CONVERSION = YES;
198 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
199 | CLANG_WARN_UNREACHABLE_CODE = YES;
200 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
201 | CODE_SIGN_IDENTITY = "-";
202 | COPY_PHASE_STRIP = NO;
203 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
204 | ENABLE_NS_ASSERTIONS = NO;
205 | ENABLE_STRICT_OBJC_MSGSEND = YES;
206 | GCC_C_LANGUAGE_STANDARD = gnu99;
207 | GCC_NO_COMMON_BLOCKS = YES;
208 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
209 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
210 | GCC_WARN_UNDECLARED_SELECTOR = YES;
211 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
212 | GCC_WARN_UNUSED_FUNCTION = YES;
213 | GCC_WARN_UNUSED_VARIABLE = YES;
214 | HEADER_SEARCH_PATHS = (
215 | "$(inherited)",
216 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
217 | "$(SRCROOT)/../../react-native/React/**",
218 | );
219 | IPHONEOS_DEPLOYMENT_TARGET = 7.0;
220 | LIBRARY_SEARCH_PATHS = "$(inherited)";
221 | MTL_ENABLE_DEBUG_INFO = NO;
222 | OTHER_LDFLAGS = (
223 | "-ObjC",
224 | "-lz",
225 | );
226 | SDKROOT = iphoneos;
227 | SKIP_INSTALL = YES;
228 | };
229 | name = Release;
230 | };
231 | B5EA19F91DA156B9009F9814 /* Debug */ = {
232 | isa = XCBuildConfiguration;
233 | buildSettings = {
234 | EXECUTABLE_PREFIX = lib;
235 | PRODUCT_NAME = "$(TARGET_NAME)";
236 | };
237 | name = Debug;
238 | };
239 | B5EA19FA1DA156B9009F9814 /* Release */ = {
240 | isa = XCBuildConfiguration;
241 | buildSettings = {
242 | EXECUTABLE_PREFIX = lib;
243 | PRODUCT_NAME = "$(TARGET_NAME)";
244 | };
245 | name = Release;
246 | };
247 | /* End XCBuildConfiguration section */
248 |
249 | /* Begin XCConfigurationList section */
250 | B5EA19EA1DA156B9009F9814 /* Build configuration list for PBXProject "RCTInstabug" */ = {
251 | isa = XCConfigurationList;
252 | buildConfigurations = (
253 | B5EA19F61DA156B9009F9814 /* Debug */,
254 | B5EA19F71DA156B9009F9814 /* Release */,
255 | );
256 | defaultConfigurationIsVisible = 0;
257 | defaultConfigurationName = Release;
258 | };
259 | B5EA19F81DA156B9009F9814 /* Build configuration list for PBXNativeTarget "RCTInstabug" */ = {
260 | isa = XCConfigurationList;
261 | buildConfigurations = (
262 | B5EA19F91DA156B9009F9814 /* Debug */,
263 | B5EA19FA1DA156B9009F9814 /* Release */,
264 | );
265 | defaultConfigurationIsVisible = 0;
266 | defaultConfigurationName = Release;
267 | };
268 | /* End XCConfigurationList section */
269 | };
270 | rootObject = B5EA19E71DA156B9009F9814 /* Project object */;
271 | }
272 |
--------------------------------------------------------------------------------