Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b87bb39

Browse files
Merge pull request Instabug#24 from Instabug/hotfix/avoid-os-validation
Avoid os validation when using android only or ios only APIs
2 parents 6db4aa7 + 0adfcae commit b87bb39

File tree

1 file changed

+66
-42
lines changed

1 file changed

+66
-42
lines changed

index.js

Lines changed: 66 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ module.exports = {
2525
* the SDK's UI.
2626
*/
2727
startWithToken: function (token, invocationEvent) {
28-
Instabug.startWithToken(token, invocationEvent);
28+
if (Platform.OS === 'ios')
29+
Instabug.startWithToken(token, invocationEvent);
2930
},
3031

3132
/**
@@ -97,7 +98,8 @@ module.exports = {
9798
* to being enabled or disabled.
9899
*/
99100
setUserStepsEnabled: function (isUserStepsEnabled) {
100-
Instabug.setUserStepsEnabled(isUserStepsEnabled);
101+
if (Platform.OS === 'ios')
102+
Instabug.setUserStepsEnabled(isUserStepsEnabled);
101103
},
102104

103105
/**
@@ -113,13 +115,15 @@ module.exports = {
113115
* report.
114116
*/
115117
setPreSendingHandler: function (preSendingHandler) {
116-
Instabug.addListener('IBGpreSendingHandler');
117-
NativeAppEventEmitter.addListener(
118-
'IBGpreSendingHandler',
119-
preSendingHandler
120-
);
118+
if (Platform.OS === 'ios') {
119+
Instabug.addListener('IBGpreSendingHandler');
120+
NativeAppEventEmitter.addListener(
121+
'IBGpreSendingHandler',
122+
preSendingHandler
123+
);
121124

122-
Instabug.setPreSendingHandler(preSendingHandler);
125+
Instabug.setPreSendingHandler(preSendingHandler);
126+
}
123127
},
124128

125129
/**
@@ -136,13 +140,15 @@ module.exports = {
136140
* @param {preInvocationHandler} preInvocationHandler - A callback that gets executed before invoking the SDK
137141
*/
138142
setPreInvocationHandler: function (preInvocationHandler) {
139-
Instabug.addListener('IBGpreInvocationHandler');
140-
NativeAppEventEmitter.addListener(
141-
'IBGpreInvocationHandler',
142-
preInvocationHandler
143-
);
143+
if (Platform.OS === 'ios') {
144+
Instabug.addListener('IBGpreInvocationHandler');
145+
NativeAppEventEmitter.addListener(
146+
'IBGpreInvocationHandler',
147+
preInvocationHandler
148+
);
144149

145-
Instabug.setPreInvocationHandler(preInvocationHandler);
150+
Instabug.setPreInvocationHandler(preInvocationHandler);
151+
}
146152
},
147153

148154
/**
@@ -162,15 +168,17 @@ module.exports = {
162168
* dismissing the SDK.
163169
*/
164170
setPostInvocationHandler: function (postInvocationHandler) {
165-
Instabug.addListener('IBGpostInvocationHandler');
166-
NativeAppEventEmitter.addListener(
167-
'IBGpostInvocationHandler',
168-
function (payload) {
169-
postInvocationHandler(payload['dismissType'], payload['reportType']);
170-
}
171-
);
172-
173-
Instabug.setPostInvocationHandler(postInvocationHandler);
171+
if (Platform.OS === 'ios') {
172+
Instabug.addListener('IBGpostInvocationHandler');
173+
NativeAppEventEmitter.addListener(
174+
'IBGpostInvocationHandler',
175+
function (payload) {
176+
postInvocationHandler(payload['dismissType'], payload['reportType']);
177+
}
178+
);
179+
180+
Instabug.setPostInvocationHandler(postInvocationHandler);
181+
}
174182
},
175183

176184
/**
@@ -209,7 +217,9 @@ module.exports = {
209217
* bug reporting, while passing NO will disable it for both.
210218
*/
211219
setWillSkipScreenshotAnnotation: function (willSkipScreenshotAnnotation) {
212-
Instabug.setWillSkipScreenshotAnnotation(willSkipScreenshotAnnotation);
220+
if (Platform.OS === 'ios') {
221+
Instabug.setWillSkipScreenshotAnnotation(willSkipScreenshotAnnotation);
222+
}
213223
},
214224

215225
/**
@@ -247,7 +257,8 @@ module.exports = {
247257
* notifications are enabled or disabled.
248258
*/
249259
setPushNotificationsEnabled: function (isPushNotificationEnabled) {
250-
Instabug.setPushNotificationsEnabled(isPushNotificationEnabled);
260+
if (Platform.OS === 'ios')
261+
Instabug.setPushNotificationsEnabled(isPushNotificationEnabled);
251262
},
252263

253264
/**
@@ -258,7 +269,8 @@ module.exports = {
258269
* field is required or not.
259270
*/
260271
setEmailFieldRequired: function (isEmailFieldRequired) {
261-
Instabug.setEmailFieldRequired(isEmailFieldRequired);
272+
if (Platform.OS === 'ios')
273+
Instabug.setEmailFieldRequired(isEmailFieldRequired);
262274
},
263275

264276
/**
@@ -268,7 +280,8 @@ module.exports = {
268280
* field is required or not.
269281
*/
270282
setCommentFieldRequired: function (isCommentFieldRequired) {
271-
Instabug.setCommentFieldRequired(isCommentFieldRequired);
283+
if (Platform.OS === 'ios')
284+
Instabug.setCommentFieldRequired(isCommentFieldRequired);
272285
},
273286

274287
/**
@@ -279,7 +292,8 @@ module.exports = {
279292
* @param {number} iPadShakingThreshold Threshold for iPad.
280293
*/
281294
setShakingThresholdForIPhone: function (iPhoneShakingThreshold, iPadShakingThreshold) {
282-
Instabug.setShakingThresholdForIPhone(iPhoneShakingThreshold, iPadShakingThreshold);
295+
if (Platform.OS === 'ios')
296+
Instabug.setShakingThresholdForIPhone(iPhoneShakingThreshold, iPadShakingThreshold);
283297
},
284298

285299
/**
@@ -293,7 +307,8 @@ module.exports = {
293307
* floating button.
294308
*/
295309
setFloatingButtonEdge: function (floatingButtonEdge, offsetFromTop) {
296-
Instabug.setFloatingButtonEdge(floatingButtonEdge, offsetFromTop);
310+
if (Platform.OS === 'ios')
311+
Instabug.setFloatingButtonEdge(floatingButtonEdge, offsetFromTop);
297312
},
298313

299314
/**
@@ -318,7 +333,8 @@ module.exports = {
318333
* intro message is enabled or not.
319334
*/
320335
setIntroMessageEnabled: function (isIntroMessageEnabled) {
321-
Instabug.setIntroMessageEnabled(isIntroMessageEnabled);
336+
if (Platform.OS === 'ios')
337+
Instabug.setIntroMessageEnabled(isIntroMessageEnabled);
322338
},
323339

324340
/**
@@ -327,7 +343,8 @@ module.exports = {
327343
* @param colorTheme
328344
*/
329345
setColorTheme: function (colorTheme) {
330-
Instabug.setColorTheme(colorTheme);
346+
if (Platform.OS === 'ios')
347+
Instabug.setColorTheme(colorTheme);
331348
},
332349

333350
/**
@@ -347,7 +364,9 @@ module.exports = {
347364
* @param {string[]} tags An array of tags to append to current tags.
348365
*/
349366
appendTags: function (tags) {
350-
Instabug.appendTags(tags);
367+
if (Platform.OS === 'ios')
368+
Instabug.appendTags(tags);
369+
351370
},
352371

353372
/**
@@ -378,7 +397,8 @@ module.exports = {
378397
* @param {strings} key Key of string to override.
379398
*/
380399
setStringToKey: function (string, key) {
381-
Instabug.setString(string, key);
400+
if (Platform.OS === 'ios')
401+
Instabug.setString(string, key);
382402
},
383403

384404
/**
@@ -419,13 +439,15 @@ module.exports = {
419439
* executed when a new message is received.
420440
*/
421441
setOnNewMessageHandler: function (onNewMessageHandler) {
422-
Instabug.addListener('IBGonNewMessageHandler');
423-
NativeAppEventEmitter.addListener(
424-
'IBGonNewMessageHandler',
425-
onNewMessgaeHandler
426-
);
442+
if (Platform.OS === 'ios') {
443+
Instabug.addListener('IBGonNewMessageHandler');
444+
NativeAppEventEmitter.addListener(
445+
'IBGonNewMessageHandler',
446+
onNewMessgaeHandler
447+
);
427448

428-
Instabug.setOnNewMessageHandler(onNewMessgaeHandler);
449+
Instabug.setOnNewMessageHandler(onNewMessgaeHandler);
450+
}
429451
},
430452

431453
/**
@@ -441,7 +463,8 @@ module.exports = {
441463
* or disabled.
442464
*/
443465
setPromptOptions: function (isBugReportingEnabled, isFeedbackReportingEnabled, isChatEnabled) {
444-
Instabug.setPromptOptions(isBugReportingEnabled, isFeedbackReportingEnabled, isChatEnabled);
466+
if (Platform.OS === 'ios')
467+
Instabug.setPromptOptions(isBugReportingEnabled, isFeedbackReportingEnabled, isChatEnabled);
445468
},
446469

447470
/**
@@ -461,7 +484,8 @@ module.exports = {
461484
* argument isInstabugNotification
462485
*/
463486
isInstabugNotification: function (dict, isInstabugNotificationCallback) {
464-
Instabug.isInstabugNotification(dict, isInstabugNotificationCallback);
487+
if (Platform.OS === 'ios')
488+
Instabug.isInstabugNotification(dict, isInstabugNotificationCallback);
465489
},
466490

467491
/**
@@ -595,4 +619,4 @@ module.exports = {
595619
messageNotification: Instabug.messageNotification,
596620
messagesNotificationAndOthers: Instabug.messagesNotificationAndOthers
597621
}
598-
}
622+
};

0 commit comments

Comments
 (0)