![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
react-native-radar
Advanced tools
React Native module for Radar, the location platform for mobile apps
Radar is the location platform for mobile apps.
Install the package from npm:
npm install --save react-native-radar
If you are using create-react-app
, you must run npm run eject
to eject and expose native code. Or, if you are using Expo, you must run exp detach
to detach and expose native code.
Then, install the native dependencies:
react-native link react-native-radar
If you do not install the native dependencies, you will get an error at run time: NativeModules.RNRadar is undefined
Finally, before writing any JavaScript, you must integrate the Radar SDK with your iOS and Android apps by following the Configure project and Add SDK to project steps in the SDK documentation.
On iOS, you must add location usage descriptions and background modes to your Info.plist
, then add the SDK to your project, preferably using CocoaPods. Finally, initialize the SDK in application:didFinishLaunchingWithOptions:
in AppDelegate.m
, passing in your Radar publishable API key.
#import <RadarSDK/RadarSDK.h>
// ...
[Radar initializeWithPublishableKey:publishableKey];
On Android, you must add the Google Play Services library to your project, then add the SDK to your project, preferably using Gradle. Finally, initialize the SDK in onCreate()
in MainApplication.java
, passing in your Radar publishable API key:
import io.radar.sdk.Radar;
// ...
Radar.initialize(publishableKey);
To get a Radar publishable API key, sign up for a Radar account.
First, import the module:
import Radar from 'react-native-radar';
If you are using Places, you must set Facebook as your place data provider.
To set Facebook as your place data provider, call:
Radar.setPlacesProvider('facebook');
To disable Places later, call:
Radar.setPlacesProvider('none');
Learn more about Places.
Until you identify the user, Radar will automatically identify the user by device ID.
To identify the user when logged in, call:
Radar.setUserId(userId);
where userId
is a stable unique ID string for the user.
To set an optional description for the user, displayed in the dashboard, call:
Radar.setDescription(description);
where description
is a string.
You only need to call these functions once, as these settings will be persisted across app sessions.
Before tracking the user's location, the user must have granted location permissions for the app.
To determine the whether user has granted location permissions for the app, call:
Radar.getPermissionsStatus().then((status) => {
// do something with status
});
status
will be a string, one of:
GRANTED
DENIED
UNKNOWN
To request location permissions for the app, call:
Radar.requestPermissions(background);
where background
is a boolean indicating whether to request background location permissions or foreground location permissions. On Android, background
will be ignored.
Once you have initialized the SDK, you have identified the user, and the user has granted permissions, you can track the user's location.
To track the user's location in the foreground, call:
Radar.trackOnce().then((result) => {
// do something with result.location, result.events, result.user.geofences
}).catch((err) => {
// optionally, do something with err
});
err
will be a string, one of:
ERROR_PUBLISHABLE_KEY
: the SDK was not initializedERROR_PERMISSIONS
: the user has not granted location permissions for the appERROR_LOCATION
: location services were unavailable, or the location request timed outERROR_NETWORK
: the network was unavailable, or the network connection timed outERROR_UNAUTHORIZED
: the publishable API key is invalidERROR_SERVER
: an internal server error occurredERROR_UNKNOWN
: an unknown error occurredOnce you have initialized the SDK, you have identified the user, and the user has granted permissions, you can start tracking the user's location in the background.
To start tracking the user's location in the background, call:
Radar.startTracking();
To stop tracking the user's location in the background (e.g., when the user logs out), call:
Radar.stopTracking();
You only need to call these methods once, as these settings will be persisted across app sessions.
To listen for events, location updates, and errors, you can add event listeners:
Radar.on('events', (result) => {
// do something with result.events, result.user
});
Radar.on('location', (result) => {
// do something with result.location, result.user
});
Radar.on('error', (err) => {
// do something with err
});
Add event listeners outside of your component lifecycle (e.g., outside of componentDidMount
) if you want them to work when the app is in the background.
You can also remove event listeners:
Radar.off('events');
Radar.off('location');
Radar.off('error');
You can manually update the user's location by calling:
const location = {
latitude: 39.2904,
longitude: -76.6122,
accuracy: 65
};
Radar.updateLocation(location).then((result) => {
// do something with result.events, result.user.geofences
}).catch((err) => {
// optionally, do something with err
});
Have questions? We're here to help! Email us at support@radar.io.
FAQs
React Native module for Radar, the leading geofencing and location tracking platform
The npm package react-native-radar receives a total of 16,231 weekly downloads. As such, react-native-radar popularity was classified as popular.
We found that react-native-radar demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.