mirror of
https://github.com/status-im/instabug-reactnative.git
synced 2025-03-02 14:10:40 +00:00
🤝 Merge pull request #54 from Instabug/fix/fix_callback_invocations
Fix/fix callback invocations
This commit is contained in:
commit
bdad0e9475
@ -33,6 +33,7 @@ import com.instabug.reactlibrary.utils.ArrayUtil;
|
||||
import com.instabug.reactlibrary.utils.MapUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
@ -212,10 +213,11 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
|
||||
* @param tags
|
||||
*/
|
||||
@ReactMethod
|
||||
public void appendTags(String tags) {
|
||||
public void appendTags(ReadableArray tags) {
|
||||
try {
|
||||
String[] result = tags.split(",");
|
||||
mInstabug.addTags(result);
|
||||
Object[] objectArray = ArrayUtil.toArray(tags);
|
||||
String[] stringArray = Arrays.copyOf(objectArray, objectArray.length, String[].class);
|
||||
mInstabug.addTags(stringArray);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -909,7 +911,7 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
|
||||
Runnable preInvocationRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
preInvocationHandler.invoke();
|
||||
sendEvent(getReactApplicationContext(), "IBGpreInvocationHandler", null);
|
||||
}
|
||||
};
|
||||
mInstabug.setPreInvocation(preInvocationRunnable);
|
||||
@ -933,7 +935,7 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
|
||||
Runnable preSendingRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
preSendingHandler.invoke();
|
||||
sendEvent(getReactApplicationContext(), "IBGpreSendingHandler", null);
|
||||
}
|
||||
};
|
||||
mInstabug.setPreSendingRunnable(preSendingRunnable);
|
||||
@ -957,7 +959,10 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
|
||||
mInstabug.setOnSdkDismissedCallback(new OnSdkDismissedCallback() {
|
||||
@Override
|
||||
public void onSdkDismissed(DismissType issueState, Bug.Type bugType) {
|
||||
postInvocationHandler.invoke();
|
||||
WritableMap params = Arguments.createMap();
|
||||
params.putString("issueState", issueState.toString());
|
||||
params.putString("bugType", bugType.toString());
|
||||
sendEvent(getReactApplicationContext(), "IBGpostInvocationHandler", params);
|
||||
}
|
||||
});
|
||||
|
||||
@ -1022,7 +1027,7 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
|
||||
Runnable willShowSurveyRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
willShowSurveyHandler.invoke();
|
||||
sendEvent(getReactApplicationContext(), "IBGWillShowSurvey", null);
|
||||
}
|
||||
};
|
||||
mInstabug.setPreShowingSurveyRunnable(willShowSurveyRunnable);
|
||||
@ -1044,7 +1049,7 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
|
||||
Runnable didDismissSurveyRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
didDismissSurveyHandler.invoke();
|
||||
sendEvent(getReactApplicationContext(), "IBGDidDismissSurvey", null);
|
||||
}
|
||||
};
|
||||
mInstabug.setAfterShowingSurveyRunnable(didDismissSurveyRunnable);
|
||||
@ -1115,7 +1120,7 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
|
||||
Runnable onNewMessageRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
onNewMessageHandler.invoke();
|
||||
sendEvent(getReactApplicationContext(), "IBGonNewMessageHandler", null);
|
||||
}
|
||||
};
|
||||
mInstabug.setNewMessageHandler(onNewMessageRunnable);
|
||||
|
21
index.js
21
index.js
@ -95,7 +95,8 @@ module.exports = {
|
||||
'IBGpreSendingHandler',
|
||||
preSendingHandler
|
||||
);
|
||||
|
||||
} else {
|
||||
DeviceEventEmitter.addListener('IBGpreSendingHandler', preSendingHandler);
|
||||
}
|
||||
|
||||
Instabug.setPreSendingHandler(preSendingHandler);
|
||||
@ -115,6 +116,8 @@ module.exports = {
|
||||
'IBGpreInvocationHandler',
|
||||
preInvocationHandler
|
||||
);
|
||||
} else {
|
||||
DeviceEventEmitter.addListener('IBGpreInvocationHandler', preInvocationHandler);
|
||||
}
|
||||
|
||||
Instabug.setPreInvocationHandler(preInvocationHandler);
|
||||
@ -137,6 +140,10 @@ module.exports = {
|
||||
postInvocationHandler(payload['dismissType'], payload['reportType']);
|
||||
}
|
||||
);
|
||||
} else {
|
||||
DeviceEventEmitter.addListener('IBGpostInvocationHandler', function(payload) {
|
||||
postInvocationHandler(payload.issueState, payload.bugType);
|
||||
});
|
||||
}
|
||||
|
||||
Instabug.setPostInvocationHandler(postInvocationHandler);
|
||||
@ -316,7 +323,9 @@ module.exports = {
|
||||
* @param {color} primaryColor A color to set the UI elements of the SDK to.
|
||||
*/
|
||||
setPrimaryColor: function (primaryColor) {
|
||||
Instabug.setPrimaryColor(primaryColor);
|
||||
if(Platform.OS == "ios") {
|
||||
Instabug.setPrimaryColor(primaryColor);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -398,9 +407,11 @@ module.exports = {
|
||||
'IBGonNewMessageHandler',
|
||||
onNewMessageHandler
|
||||
);
|
||||
} else {
|
||||
DeviceEventEmitter.addListener('IBGonNewMessageHandler', onNewMessageHandler);
|
||||
}
|
||||
|
||||
Instabug.setOnNewMessageHandler(onNewMessgaeHandler);
|
||||
Instabug.setOnNewMessageHandler(onNewMessageHandler);
|
||||
|
||||
},
|
||||
|
||||
@ -680,6 +691,8 @@ module.exports = {
|
||||
'IBGWillShowSurvey',
|
||||
willShowSurveyHandler
|
||||
);
|
||||
} else {
|
||||
DeviceEventEmitter.addListener('IBGWillShowSurvey', willShowSurveyHandler);
|
||||
}
|
||||
|
||||
Instabug.setWillShowSurveyHandler(willShowSurveyHandler);
|
||||
@ -699,6 +712,8 @@ module.exports = {
|
||||
'IBGDidDismissSurvey',
|
||||
didDismissSurveyHandler
|
||||
);
|
||||
} else {
|
||||
DeviceEventEmitter.addListener('IBGDidDismissSurvey', didDismissSurveyHandler);
|
||||
}
|
||||
|
||||
Instabug.setDidDismissSurveyHandler(didDismissSurveyHandler);
|
||||
|
@ -23,7 +23,7 @@
|
||||
"homepage": "https://github.com/Instabug/instabug-reactnative#readme",
|
||||
"rnpm": {
|
||||
"android": {
|
||||
"packageInstance": "new RNInstabugReactnativePackage.Builder(\"YOUR_ANDROID_APPLICATION_TOKEN\",MainApplication.this)\n.setInvocationEvent(\"shake\")\n.setPrimaryColor(\"#1D82DC\")\n.setFloatingEdge(\"left\")\n.setFloatingButtonOffsetFromTop(250)\n.build()"
|
||||
"packageInstance": "\t\tnew RNInstabugReactnativePackage.Builder(\"YOUR_ANDROID_APPLICATION_TOKEN\",MainApplication.this)\n\t\t\t\t\t\t\t.setInvocationEvent(\"shake\")\n\t\t\t\t\t\t\t.setPrimaryColor(\"#1D82DC\")\n\t\t\t\t\t\t\t.setFloatingEdge(\"left\")\n\t\t\t\t\t\t\t.setFloatingButtonOffsetFromTop(250)\n\t\t\t\t\t\t\t.build()"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user