Skip to content

Get Started

Preparations

Add Npm Registry

1
npm login --registry=https://telenav.jfrog.io/artifactory/api/npm/telenav-npm-releases/ --scope=@telenav

Add Npm Package

Run command to add package:

1
yarn add @telenav/react-native-drive-motion-bridge@<version>
or
1
npm install @telenav/react-native-drive-motion-bridge@<version>

Android Installation

Requires minimum SDK Android 6.0 (API level 23).

Add Build Script

Add lines to android/build.gradle

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
 ext {
    ...
    minSdkVersion = 23
 }
 allprojects {
    repositories {
      ...
      maven {
         url "https://telenav.jfrog.io/artifactory/telenav-maven-releases/"
         credentials {
           username '#REPO_USER_NAME#'
           password '#REPO_PASSWD#'
         }
       }
    }
}

Add Permissions to Support Background Mode

Add permissions to AndroidManifest.xml

1
2
3
4
...
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
...
Check the following React Native packages to simplify permissions request implementaiton: - https://github.com/zoontek/react-native-permissions - https://github.com/rasheedk/react-native-disable-battery-optimizations-android

Note

If battery optimization is enabled, event won't be uploaded and background mode won't be supported!

iOS Installation

Need CocoaPods, cocoapods-art plugin and correctly configured Podfile. If you don't have cocoapods-art installed, you need to run gem install cocoapods-art to install it.

Add CocoaPods Requirements

1
2
3
4
5
6
7
source 'https://cdn.cocoapods.org/'
...
platform :ios, '12.0'

plugin 'cocoapods-art', :sources => [
  'telenav-cocoapods'
]

Install / Update CocoaPods Repository

Run command

1
pod repo-art add telenav-cocoapods "https://telenav.jfrog.io/artifactory/api/pods/telenav-cocoapods"
or
1
pod repo-art update telenav-cocoapods
to update local cocoapods repository, as well as delete Podfile.lock file.

Install Dependencies

Run command pod install to install dependencies.

Add Usage Description to Support Background Mode

You must update Info.plist with a usage description for location and motion.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
...
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Do you allow this app to know your current location?</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Do you allow this app to always know your location?</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Do you allow this app to know your current location?</string>
<key>NSMotionUsageDescription</key>
<string>Do you allow this app to track you motion data?</string>
...
<key>UIBackgroundModes</key>
<array>
    <string>fetch</string>
    <string>location</string>
    <string>processing</string>
</array>
...

Troubleshooting

1. Error: undefined symbol: swift._arraybuffer._copycontents

** This issue can be fixed from the project side**:

  1. remove "$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)" from library search paths.
  2. add empty Swift file with bridging header (XCode will ask about this header when you create first Swift file).
  3. if build still fails, set "Always embed Swift standard libraries" to "Yes" (but it should be set automatically).