You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`react-native link react-native-exception-handler`
74
74
75
75
### Manual installation
76
76
77
-
78
77
#### iOS
79
78
80
79
1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]`
@@ -83,30 +82,32 @@ or
83
82
4. Run your project (`Cmd+R`)<
84
83
85
84
##### Using Cocoapods
85
+
86
86
1. add `pod 'ReactNativeExceptionHandler', :podspec => '../node_modules/react-native-exception-handler/ios/ReactNativeExceptionHandler.podspec'` to your Podfile
87
87
2. run `pod install`
88
88
89
89
#### Android
90
90
91
91
1. Open up `android/app/src/main/java/[...]/MainApplication.java`
92
-
- Add `import com.masteratul.exceptionhandler.ReactNativeExceptionHandlerPackage;` to the imports at the top of the file
93
-
- Add `new ReactNativeExceptionHandlerPackage()` to the list returned by the `getPackages()` method
92
+
93
+
- Add `import com.masteratul.exceptionhandler.ReactNativeExceptionHandlerPackage;` to the imports at the top of the file
94
+
- Add `new ReactNativeExceptionHandlerPackage()` to the list returned by the `getPackages()` method
95
+
94
96
2. Append the following lines to `android/settings.gradle`:
95
-
```
96
-
include ':react-native-exception-handler'
97
-
project(':react-native-exception-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-exception-handler/android')
98
-
```
97
+
```
98
+
include ':react-native-exception-handler'
99
+
project(':react-native-exception-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-exception-handler/android')
100
+
```
99
101
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
(NATIVE CODE HAS TO BE WRITTEN) *recommended that you do this in android studio*
223
+
(NATIVE CODE HAS TO BE WRITTEN) _recommended that you do this in android studio_
217
224
218
225
- In the `android/app/src/main/java/[...]/MainApplication.java`
219
226
@@ -238,12 +245,11 @@ public class MainApplication extends Application implements ReactApplication {
238
245
}
239
246
});//This will override the default behaviour of displaying the recover activity.
240
247
}
241
-
242
248
```
243
249
244
-
**ModifyingAndroidNativeException handler UI (CUSTOMACTIVITYAPPROACH (OLDAPPROACH).. LEAVING FOR BACKWARD COMPATIBILITY)**
250
+
**ModifyingAndroidNativeException handler UI (CUSTOMACTIVITYAPPROACH (OLDAPPROACH).. LEAVING FOR BACKWARD COMPATIBILITY)**
245
251
246
-
(NATIVE CODE HAS TO BE WRITTEN) *recommended that you do this in android studio*
252
+
(NATIVE CODE HAS TO BE WRITTEN) _recommended that you do this in android studio_
247
253
248
254
- Create an Empty Activity in the `android/app/src/main/java/[...]/`. For example lets say CustomErrorDialog.java
249
255
- Customize your activity to look and behave however you need it to be.
@@ -265,10 +271,9 @@ public class MainApplication extends Application implements ReactApplication {
265
271
....
266
272
ReactNativeExceptionHandlerModule.replaceErrorScreenActivityClass(YourCustomActivity.class); //This will replace the native error handler popup with your own custom activity.
267
273
}
268
-
269
274
```
270
275
271
-
**Modifying iOS Native Exception handler UI** (NATIVE CODE HAS TO BE WRITTEN) *recommended that you do this in XCode*
276
+
**Modifying iOS Native Exception handler UI** (NATIVE CODE HAS TO BE WRITTEN) _recommended that you do this in XCode_
272
277
273
278
Unlike Android, in the case of iOS, there is no way to restart the app if it has crashed. Also, during a **Native_Exceptions** the UI becomes quite unstable since the exception occured on the main UI thread. Hence, none of the click or press handlers would work either.
274
279
@@ -279,7 +284,6 @@ If you noticed the default native exception popup does exactly that. To customiz
279
284
- In XCode, open the file `AppDelegate.m`
280
285
281
286
```c
282
-
283
287
#import "AppDelegate.h"
284
288
285
289
#import <React/RCTBundleURLProvider.h>
@@ -337,7 +341,6 @@ If you noticed the default native exception popup does exactly that. To customiz
337
341
}
338
342
339
343
@end
340
-
341
344
```
342
345
343
346
What is this `[ReactNativeExceptionHandler releaseExceptionHold];`?
@@ -350,6 +353,7 @@ To close the app or to remove the UI lockup on exception, we need to call this m
350
353
351
354
Hence we set a timer of 4 secs and then call the method releaseExceptionHold to quit the app after
This is specifically occuring when you use [wix library](http://wix.github.io/react-native-navigation/) for navigation along with react-native-exception-handler. Whenever an error occurs, it will recreate the application above the crash screen.
462
468
463
-
464
469
**Fix:**
465
470
466
-
You need to set second parametera as *false* while calling _setNativeExceptionHandler_.
467
-
The second parameter is an android specific field which stands for forceQuitOnError.
468
-
When set to false it doesnt quit the app forcefully on error. In short :
471
+
You need to set second parametera as _false_while calling _setNativeExceptionHandler_.
472
+
The second parameter is an android specific field which stands for forceQuitOnError.
473
+
When set to false it doesnt quit the app forcefully on error. Inshort:
A lot of frameworks (especially analytics sdk's) implement global exception handlers. In order to keep these frameworks working while using react-native-exception-hanlder, you can pass a boolean value as third argument to `setNativeExceptionHandler(..., ..., true`) what will trigger the execution of the last global handler registered.
479
484
480
-
481
485
## CONTRIBUTORS
486
+
482
487
- [Atul R](https://github.com/master-atul)
483
488
- [Zeh Fernando](https://github.com/zeh)
484
489
- [Fred Chasen](https://github.com/fchasen)
@@ -494,6 +499,7 @@ A lot of frameworks (especially analytics sdk's) implement global exception hand
0 commit comments