Skip to content

Commit e8997da

Browse files
committed
🐛 Fix bug where callbacks could only get invoked once
1 parent 1fc518d commit e8997da

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@ public void setPreInvocationHandler(final Callback preInvocationHandler) {
909909
Runnable preInvocationRunnable = new Runnable() {
910910
@Override
911911
public void run() {
912-
preInvocationHandler.invoke();
912+
sendEvent(getReactApplicationContext(), "IBGpreInvocationHandler", null);
913913
}
914914
};
915915
mInstabug.setPreInvocation(preInvocationRunnable);
@@ -933,7 +933,7 @@ public void setPreSendingHandler(final Callback preSendingHandler) {
933933
Runnable preSendingRunnable = new Runnable() {
934934
@Override
935935
public void run() {
936-
preSendingHandler.invoke();
936+
sendEvent(getReactApplicationContext(), "IBGpreSendingHandler", null);
937937
}
938938
};
939939
mInstabug.setPreSendingRunnable(preSendingRunnable);
@@ -957,7 +957,10 @@ public void setPostInvocationHandler(final Callback postInvocationHandler) {
957957
mInstabug.setOnSdkDismissedCallback(new OnSdkDismissedCallback() {
958958
@Override
959959
public void onSdkDismissed(DismissType issueState, Bug.Type bugType) {
960-
postInvocationHandler.invoke();
960+
WritableMap params = Arguments.createMap();
961+
params.putString("issueState",issueState.toString());
962+
params.putString("bugType",bugType.toString());
963+
sendEvent(getReactApplicationContext(), "IBGpostInvocationHandler", params);
961964
}
962965
});
963966

@@ -1022,7 +1025,7 @@ public void setWillShowSurveyHandler(final Callback willShowSurveyHandler) {
10221025
Runnable willShowSurveyRunnable = new Runnable() {
10231026
@Override
10241027
public void run() {
1025-
willShowSurveyHandler.invoke();
1028+
sendEvent(getReactApplicationContext(), "IBGWillShowSurvey", null);
10261029
}
10271030
};
10281031
mInstabug.setPreShowingSurveyRunnable(willShowSurveyRunnable);
@@ -1044,7 +1047,7 @@ public void setDidDismissSurveyHandler(final Callback didDismissSurveyHandler) {
10441047
Runnable didDismissSurveyRunnable = new Runnable() {
10451048
@Override
10461049
public void run() {
1047-
didDismissSurveyHandler.invoke();
1050+
sendEvent(getReactApplicationContext(), "IBGDidDismissSurvey", null);
10481051
}
10491052
};
10501053
mInstabug.setAfterShowingSurveyRunnable(didDismissSurveyRunnable);
@@ -1115,7 +1118,7 @@ public void setOnNewMessageHandler(final Callback onNewMessageHandler) {
11151118
Runnable onNewMessageRunnable = new Runnable() {
11161119
@Override
11171120
public void run() {
1118-
onNewMessageHandler.invoke();
1121+
sendEvent(getReactApplicationContext(), "IBGonNewMessageHandler", null);
11191122
}
11201123
};
11211124
mInstabug.setNewMessageHandler(onNewMessageRunnable);

index.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ module.exports = {
9595
'IBGpreSendingHandler',
9696
preSendingHandler
9797
);
98-
98+
} else {
99+
DeviceEventEmitter.addListener('IBGpreSendingHandler', preSendingHandler);
99100
}
100101

101102
Instabug.setPreSendingHandler(preSendingHandler);
@@ -115,6 +116,8 @@ module.exports = {
115116
'IBGpreInvocationHandler',
116117
preInvocationHandler
117118
);
119+
} else {
120+
DeviceEventEmitter.addListener('IBGpreInvocationHandler', preInvocationHandler);
118121
}
119122

120123
Instabug.setPreInvocationHandler(preInvocationHandler);
@@ -137,6 +140,10 @@ module.exports = {
137140
postInvocationHandler(payload['dismissType'], payload['reportType']);
138141
}
139142
);
143+
} else {
144+
DeviceEventEmitter.addListener('IBGpostInvocationHandler', function(payload) {
145+
postInvocationHandler(payload.issueState, payload.bugType);
146+
});
140147
}
141148

142149
Instabug.setPostInvocationHandler(postInvocationHandler);
@@ -398,9 +405,11 @@ module.exports = {
398405
'IBGonNewMessageHandler',
399406
onNewMessageHandler
400407
);
408+
} else {
409+
DeviceEventEmitter.addListener('IBGonNewMessageHandler', onNewMessageHandler);
401410
}
402411

403-
Instabug.setOnNewMessageHandler(onNewMessgaeHandler);
412+
Instabug.setOnNewMessageHandler(onNewMessageHandler);
404413

405414
},
406415

@@ -680,6 +689,8 @@ module.exports = {
680689
'IBGWillShowSurvey',
681690
willShowSurveyHandler
682691
);
692+
} else {
693+
DeviceEventEmitter.addListener('IBGWillShowSurvey', willShowSurveyHandler);
683694
}
684695

685696
Instabug.setWillShowSurveyHandler(willShowSurveyHandler);
@@ -699,6 +710,8 @@ module.exports = {
699710
'IBGDidDismissSurvey',
700711
didDismissSurveyHandler
701712
);
713+
} else {
714+
DeviceEventEmitter.addListener('IBGDidDismissSurvey', didDismissSurveyHandler);
702715
}
703716

704717
Instabug.setDidDismissSurveyHandler(didDismissSurveyHandler);

0 commit comments

Comments
 (0)