I'm trying to use Sentry.captureException in my React Native app, but it's not working properly.
I'm receiving the eventId, but there is no issues on Sentry website.
Here is the code:
const eventId = Sentry.captureException(new Error("Testing"));
console.log(eventId); /// ccfa8f3799524c8ea9e138fb792******
PS. Native errors are working fine, if I try throw('Testing') it works.
PS. Android only, iOS is working fine
RN: 0.63.3
#sentry/react-native: 2.0.0
You can use it like this:
Sentry.captureEvent({
event_id: <error_id>,
message: <message>,
extra: <data_in_json>,
});
Related
I am developing simple grid location based application in React Native using Uber H3. I installed H3 by
npm install h3-js. Then
I created a file to read H3Index from latitude and longitude.
import {geoToH3} from 'h3-js';
const getH3Index = () => {
const result = geoToH3(37.3615593, -122.0553238, 7);
console.log(result);
};
When I start to run my React Native application, app hangs on white screen(splash screen) and blocks the whole application. If I comment these lines, app works fine. If uncomment this line, both iOS and Android app is not working.
Any help would be much appreciated!
Please see https://github.com/uber/h3-js/issues/35
This is likely due to a document is not defined error. See the issue thread for several possible workarounds, including this fork which is intended for React Native.
I want to call react-native function from native module.
I have created one barcode-scanner plugins for my react-native app, barcode-scanner SDK is available in native IOS & Android so, i extract those native code and create one plugins(NPM) for react-native app.
Now my problems is, Once barcode-scanner scan a data and send to native IOS, how can i get those scanning data in my react-native app ?(I got scanned data in IOS native)
I want to call react-native app function once native module scanned a data and send those data in react-native
Please give example or proper document so i can try and implement.
Thanks in advance.
You'll find your answer well described here:
https://facebook.github.io/react-native/docs/communication-ios#passing-properties-from-native-to-react-native
I have used "RCTDeviceEventEmitter" & "NativeEventEmitter" and add listener for received event
more detail
Issue Description::
I am working on react native tracking application. Basically users check in from a certain place and they need to reach at the destination. Using this application we are finding out the path they are following. I need to get a geocodes from users check in location to destination to track the path he is following.
Now it builds a clean path in case of Android device, but having an issue with ios. For ios it takes a huge variation inside code.
I have tested this by traveling to same place using both devices(ios and android). For Android it's generates a exact latitude longitude values, but for ios there is a huge variation. Why this is happening. I have followed the official doc of react native for geolocation setup.
You can check this link:: https://facebook.github.io/react-native/docs/geolocation.html#ios
We are using react native geolocation service package, GitHub link
This is happening when I have updated react native version to 0.58
Code::
this.watchId = Geolocation.watchPosition((response) => {
this.currentWatchLocationTimeout = this.currentWatchLocationTimeout + WATCH_LOCATION_TIMEOUT;
currentPosition.lat = this.convertToDecimalPoints(response.coords.latitude);
currentPosition.lng = this.convertToDecimalPoints(response.coords.longitude);
//... additional code
}, (error) => {
this.onGeolocationErrorOccurCallback(error);
}, {
enableHighAccuracy: true,
distanceFilter: 5,
showLocationDialog: true
});
Additional Information ::
React Native: 0.58
react-native-geolocation-service: 2.0.0
platform: ios(only)
Best solution that works for me is changes inside react native geolocation files. You need to replace some lines of code. Go inside react native package,
react-native/Libraries/Geolocation/RCTLocationObserver.m
Then replace this line::
#define RCT_DEFAULT_LOCATION_ACCURACY kCLLocationAccuracyHundredMeters
with this::
#define RCT_DEFAULT_LOCATION_ACCURACY 0.0
After this replace this line::
.accuracy = [RCTConvert BOOL:options[#"enableHighAccuracy"]] ? kCLLocationAccuracyBest : RCT_DEFAULT_LOCATION_ACCURACY,
with this one::
.accuracy = RCT_DEFAULT_LOCATION_ACCURACY,
You need to directly search for these lines on above mentioned path.
I found this inside git commits, you can also check this link:: link
I'm building a React Native native module (aka 'bridge') for iOS and Android and need to log to the JS console in native code (Objective C and Java). This is done easily in iOS using RCTLog but I can't figure out how to do it in Java.
I tried Log.i but those messages aren't forwarded to Javascript.
The only thing I can think of at this point is to emit a JS event from the Java module and have a handler on the JS side just call console.log with the message but that's a pretty roundabout way of doing it.
I would expect to be able to do something like this.getReactApplicationContext().log("see me in the JS console") but no dice. Anyone know how to do this?
It looks like as of upcoming react native 0.63 we may be getting the equivalent of iOS's RCTLog in Android: https://github.com/facebook/react-native/commit/52b3105f652eca72892f200923e1687f1d995486
The files are in master: https://github.com/facebook/react-native/tree/master/ReactAndroid/src/main/java/com/facebook/react/util
public void logEvent(String text) {
System.out.print(String.format("logEvent: %s ", text));
}
or just
System.out.print("Hello");
Following the document, I am including a toast in my projects:
import {ToastAndroid} from react-native
ToastAndroid.showWithGravity('A toast with gravity',ToastAndroid.SHORT,ToastAndroid.TOP);
But I got an error:
However, if I replace it with another function, it works:
ToastAndroid.show('A toast without gravity',ToastAndroid.SHORT);
I am using React Native 0.30.0
Is it a bug or I made the wrong way to use it.
ToastAndroid.showWithGravity(...) was implemented in ReactNative 0.31.0, upgrade your RN version.
First implemented here: v0.31.0-stable branch.