SDK 11.0 Migration Guide for React Native
This page covers the migration steps from previous versions of the SDK to Instabug Version 11.0+ for React Native apps.
Start the SDK from JavaScript only
Users are now able to initialize the SDK completely from JavaScript rather than having to write the initialization code for Android in the Java/Kotlin files. Android initialization is now consistent with how you used to initialize the SDK for iOS by using the same API i.e. Instabug.start
.
Migrate the initialization code to JS
When migrating to the new initialization method, you'll need to follow the below steps:
-
Remove Instabug’s native Android initialization code from
android/app/src/main/java/<your_package>/MainApplication.java
-
Initialize Instabug in your JavaScript, depending on the platforms you use:
import Instabug from 'instabug-reactnative';
Instabug.start('APP_TOKEN', [Instabug.invocationEvent.floatingButton]);
import { Platform } from 'react-native';
import Instabug from 'instabug-reactnative';
if (Platform.OS === 'ios') {
Instabug.start('IOS_APP_TOKEN', [Instabug.invocationEvent.floatingButton]);
} else if (Platform.OS === 'android') {
Instabug.start('ANDROID_APP_TOKEN', [Instabug.invocationEvent.floatingButton]);
}
import { Platform } from 'react-native';
import Instabug from 'instabug-reactnative';
if (Platform.OS === 'ios') {
Instabug.start('APP_TOKEN', [Instabug.invocationEvent.floatingButton]);
}
- Use JavaScript APIs instead of the native Android builder methods.
Builder method (Native Android) | JavaScript API |
---|---|
Builder.setInvocationEvent("button") | Instabug.start("APP_TOKEN", Instabug.invocationEvent.floatingButton) For other invocation events, check out the docs here. |
Builder.setPrimaryColor("#1D82DC") | Instabug.setPrimaryColor("#1D82DC") |
Builder.setFloatingEdge("left") and Builder.setFloatingButtonOffsetFromTop(250) | BugReporting.setFloatingButtonEdge(Instabug.floatingButtonEdge.left, 250) |
Remove deprecated APIs
For the full list of the removed APIs and their alternatives (if applicable), please check the tables below.
Instabug
Removed | Alternative |
---|---|
startWithToken | start |
setAutoScreenRecordingEnabled | BugReporting.setAutoScreenRecordingEnabled |
setAutoScreenRecordingMaxDuration | BugReporting.setAutoScreenRecordingMaxDuration |
setCrashReportingEnabled | CrashReporting.setEnabled |
setDidSelectPromptOptionHandler | BugReporting.setDidSelectPromptOptionHandler |
getUnreadMessagesCount | Replies.getUnreadRepliesCount |
setPushNotificationsEnabled | Replies.setPushNotificationsEnabled |
setEmailFieldRequiredForActions | BugReporting.setOptions |
setFloatingButtonEdge | BugReporting.setFloatingButtonEdge |
setStringToKey | setString |
setEnabledAttachmentTypes | BugReporting.setEnabledAttachmentTypes |
identifyUserWithEmail | BugReporting.identifyUser |
logUserEventWithName | logUserEvent |
setChatNotificationEnabled | Replies.setInAppNotificationsEnabled |
setOnNewMessageHandler | Replies.setOnNewReplyReceivedHandler |
setViewHierarchyEnabled | BugReporting.setViewHierarchyEnabled |
setSurveysEnabled | Surveys.setEnabled |
setEnableInAppNotificationSound | Replies.setInAppNotificationSound |
reportJSException | CrashReporting.reportJSException |
setVideoRecordingFloatingButtonPosition | BugReporting.setVideoRecordingFloatingButtonPosition |
setShouldShowSurveysWelcomeScreen | Surveys.setShouldShowWelcomeScreen |
invocationOptions enum | BugReporting.option enum |
strings.startChats | - |
strings.chatsNoConversationsHeadlineText | - |
strings.chatsHeaderTitle | - |
Bug Reporting
Removed | Alternative |
---|---|
invocationOptions enum | option enum |
showWithOptions | show |
setInvocationOptions | setOptions |
Replies
Removed | Alternative |
---|---|
setOnNewReplyReceivedCallback | setOnNewReplyReceivedHandler |
Surveys
Removed | Alternative |
---|---|
onShowCallback | setOnShowHandler |
onDismissCallback | setOnDismissHandler |
Removed APIs not marked as Deprecated
The below APIs were removed as well but were not marked as deprecated previously.
Surveys.setThresholdForReshowingSurveyAfterDismiss
- Renamed
BugReporting.setAutoScreenRecordingMaxDuration
toBugReporting.setAutoScreenRecordingDurationIOS
to target iOS only as the native Android API has been removed from the native SDK. - Removed the string keys
surveysCustomThanksTitle
andsurveysCustomThanksSubtitle
Updated about 1 year ago