Skip to content

Installation

Minimum Requirements:

  • React Native: 0.45.0+
  • Android minSdkVersion: 16+
  • iOS IPHONEOS_DEPLOYMENT_TARGET: 9.0+

To start using the SDK, add this plugin to your React Native project

$ yarn add react-native-nearit

and link it

$ react-native link react-native-nearit


Android

NearIT API Key

Add a new string resource to the Android resources to specify your API key

<resources>
    ...
    <string name="nearit_api_key" translatable="false">Your.API.Key</string>
    ...
</resources>

You can find your API key on NearIT web interface, under the "SDK Integration" section.

If you don't have a resources file, create a new secrets.xml file under your project android/app/src/main/res/values folder and add the previous line inside of it.

N.B: We suggests you to ignore this file from your versioning system.

Test devices

Go to NearIT web interface, navigate "Settings > Test devices" section of NearIT and follow the instructions to enable this feature. The procedure will make you update the AndroidManifest.xml of your project.

In the same section, you can send invite links to mail addresses. If users have the app installed, they can click the link on their smart-phone to be prompted with a request to enroll their device among the testers.


iOS

NearIT API Key

Create the NearIt.plist file at ios/<your app name>/NearIt.plist to specify your API Key

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>API Key</key>
        <string>Your.API.Key</string>
    </dict>
</plist>

You can find your API key on NearIT web interface, under the "SDK Integration" section.

N.B: We suggests you to ignore this file from your versioning system.

Test devices

Go to NearIT web interface, navigate to "Settings > Test devices" and follow instructions to enable this feature. The procedure will make you update your Info.plist file to include a CFBundleURLSchemes.

In the same section, you can send invite links to mail addresses. If users have the app installed, they can click the link on their smart-phone to be prompted with a request to enroll their device among the testers.

After the Info.plist update, you must override the AppDelegate method for url management:

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
    [[NITManager defaultManager] application:app openURL:url options:options];
}

Finally, you must add node_modules/react-native-nearit/ios/NearITSDK/NearITResources.bundle file to your Xcode project.


Usage

To interact with NearIT SDK from your React code use the NearItManager class exported by the react-native-nearit module

import NearIT from 'react-native-nearit'