├── .gitattributes ├── .gitignore ├── .npmignore ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── android ├── README.md ├── build.gradle └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── homee │ │ └── mapboxnavigation │ │ ├── MapboxNavigationManager.kt │ │ ├── MapboxNavigationPackage.kt │ │ └── MapboxNavigationView.kt │ └── res │ ├── layout │ └── navigation_view.xml │ └── values │ └── styles.xml ├── dist ├── index.d.ts ├── index.js ├── typings.d.ts └── typings.js ├── example ├── .buckconfig ├── .eslintrc.js ├── .flowconfig ├── .gitignore ├── .prettierrc.js ├── .watchmanconfig ├── App.js ├── Gemfile ├── Gemfile.lock ├── NavigationComponent.js ├── __tests__ │ └── App-test.js ├── _bundle │ └── config ├── _ruby-version ├── android │ ├── app │ │ ├── _BUCK │ │ ├── build.gradle │ │ ├── build_defs.bzl │ │ ├── debug.keystore │ │ ├── proguard-rules.pro │ │ └── src │ │ │ ├── debug │ │ │ ├── AndroidManifest.xml │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── basicapp │ │ │ │ └── ReactNativeFlipper.java │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ └── com │ │ │ │ └── basicapp │ │ │ │ ├── MainActivity.java │ │ │ │ └── MainApplication.java │ │ │ └── res │ │ │ ├── drawable │ │ │ └── rn_edit_text_material.xml │ │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ └── values │ │ │ ├── strings.xml │ │ │ └── styles.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle ├── app.json ├── babel.config.js ├── index.js ├── ios │ ├── BasicApp-Bridging-Header.h │ ├── BasicApp.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── BasicApp.xcscheme │ ├── BasicApp.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── BasicApp │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Images.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ │ └── Contents.json │ │ ├── Info.plist │ │ ├── LaunchScreen.storyboard │ │ └── main.m │ ├── BasicAppTests │ │ ├── BasicAppTests.m │ │ └── Info.plist │ ├── BridgeHeader.swift │ ├── Podfile │ └── Podfile.lock ├── metro.config.js ├── package.json └── yarn.lock ├── img ├── bridging-header.png ├── build-setting-linking.png ├── build-setting-path.png └── ios-nav.png ├── ios ├── MapboxNavigation-Bridging-Header.h ├── MapboxNavigation.xcodeproj │ └── project.pbxproj ├── MapboxNavigation.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist ├── MapboxNavigationManager.m ├── MapboxNavigationManager.swift └── MapboxNavigationView.swift ├── package.json ├── react-native-mapbox-navigation.podspec ├── src ├── index.tsx └── typings.ts ├── tsconfig.json └── yarn.lock /.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # node.js 6 | # 7 | node_modules/ 8 | npm-debug.log 9 | yarn-error.log 10 | 11 | # Xcode 12 | # 13 | build/ 14 | *.pbxuser 15 | !default.pbxuser 16 | *.mode1v3 17 | !default.mode1v3 18 | *.mode2v3 19 | !default.mode2v3 20 | *.perspectivev3 21 | !default.perspectivev3 22 | xcuserdata 23 | *.xccheckout 24 | *.moved-aside 25 | DerivedData 26 | *.hmap 27 | *.ipa 28 | *.xcuserstate 29 | project.xcworkspace 30 | 31 | # Android/IntelliJ 32 | # 33 | build/ 34 | .idea 35 | .gradle 36 | local.properties 37 | *.iml 38 | 39 | # BUCK 40 | buck-out/ 41 | \.buckd/ 42 | *.keystore 43 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/homeeondemand/react-native-mapbox-navigation/d0f729ce8665020145be7024c50bc3867e21001d/.npmignore -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Contributing to this project should be as easy and transparent as possible. 4 | 5 | ## Workflow 6 | 7 | We use [GitHub Flow](https://guides.github.com/introduction/flow/), so all code changes happen through pull requests. 8 | 9 | 1. Fork the repository and create your branch from `master`. 10 | 2. If you've changed the functionality, update the documentation. 11 | 3. Issue that pull request! :tada: 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Homee 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # React Native Mapbox Navigation 2 | 3 | React Native Mapbox Navigation 4 | 5 | Smart Mapbox turn-by-turn routing based on real-time traffic for React Native. A navigation UI ready to drop into your React Native application. [Sample demo usage shown here for the HOMEE Pro iOS app in the screenshot](https://www.homee.com/) ➡️ 6 | 7 | ## Features 8 | 9 | - A full-fledged turn-by-turn navigation UI for iPhone, iPad, and CarPlay that’s ready to drop into your application 10 | - [Professionally designed map styles](https://www.mapbox.com/maps/) for daytime and nighttime driving 11 | - Worldwide driving, cycling, and walking directions powered by [open data](https://www.mapbox.com/about/open/) and user feedback 12 | - Traffic avoidance and proactive rerouting based on current conditions in [over 55 countries](https://docs.mapbox.com/help/how-mapbox-works/directions/#traffic-data) 13 | - Natural-sounding turn instructions powered by [Amazon Polly](https://aws.amazon.com/polly/) (no configuration needed) 14 | - Support for over two dozen languages 15 | 16 | ## Installation Requirements 17 | 18 | Before installing the SDK, you will need to gather the appropriate credentials. The SDK requires two pieces of sensitive information from your Mapbox account. If you don't have a Mapbox account: [sign up](https://account.mapbox.com/auth/signup/) and navigate to your [Account page](https://account.mapbox.com/). You'll need: 19 | 20 | - **A public access token**: From your account's [tokens page](https://account.mapbox.com/access-tokens/), you can either copy your _default public token_ or click the **Create a token** button to create a new public token. 21 | - **A secret access token with the `Downloads:Read` scope**. 22 | 23 | 1. From your account's [tokens page](https://account.mapbox.com/access-tokens/), click the **Create a token** button. 24 | 1. From the token creation page, give your token a name and make sure the box next to the `Downloads:Read` scope is checked. 25 | 1. Click the **Create token** button at the bottom of the page to create your token. 26 | 1. The token you've created is a _secret token_, which means you will only have one opportunity to copy it somewhere secure. 27 | 28 | ## Installation 29 | 30 | ``` 31 | npm install @homee/react-native-mapbox-navigation 32 | ``` 33 | 34 | Read the iOS specific instructions below before running `pod install`. 35 | 36 | --- 37 | 38 | ### iOS Specific Instructions 39 | 40 | Make sure your react native project has an Objective-C bridging header for swift. If you don't have a bridging header you can follow these steps here below in the dropdown. 41 | 42 |
43 | 44 | Create an Objective-C bridging header 45 | 46 | 47 | 1. From Xcode, go to:
48 | File → New → File… 49 | 1. Select Swift File 50 | 1. Name your file Dummy or whatever you want 51 | 1. In the Group dropdown, make sure to select the group folder for your app, not the project itself. 52 | 53 | After you create the Swift file, you should be prompted to choose if you want to configure an Objective-C Bridging Header. Select “Create Bridging Header”. 54 | 55 | ![bridging header](img/bridging-header.png) 56 | 57 | This file is usually named YourProject-Bridging-Header.h. Don’t change this name manually, because Xcode configures the project with this exact filename. 58 | 59 |
60 | 61 | There are a few build settings in Xcode that are necessary. Make sure to set `Don't Dead-strip Inits and Terms` to `YES` and `Dead Code Stripping` to `YES` for all projects/targets. 62 | 63 |
64 | 65 | Build Settings Screenshot 1 66 | 67 | 68 | ![build setting linking](img/build-setting-linking.png) 69 | 70 |
71 | 72 | You will also need to remove the entry `"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)"` from `Library Search Paths` if it is present for your project target - 73 | 74 |
75 | 76 | Build Settings Screenshot 2 77 | 78 | 79 | ![build setting path](img/build-setting-path.png) 80 | 81 |
82 | 83 | Place your public token in your Xcode project's `Info.plist` and add a `MBXAccessToken` key whose value is your public access token. 84 | 85 | NOTE: `MGLMapboxAccessToken` is deprecated, now you should use `MBXAccessToken` instead 86 | 87 | Add the `UIBackgroundModes` key to `Info.plist` with `audio` and `location` if it is not already present. This will allow your app to deliver audible instructions while it is in the background or the device is locked. 88 | 89 | ``` 90 | UIBackgroundModes 91 | 92 | audio 93 | location 94 | 95 | ``` 96 | 97 | Place your secret token in a `.netrc` file in your OS home directory that contains this: 98 | 99 | ``` 100 | machine api.mapbox.com 101 | login mapbox 102 | password 103 | ``` 104 | 105 | Add the following to your ios podfile - 106 | 107 | ```ruby 108 | pre_install do |installer| 109 | $RNMBNAV.pre_install(installer) 110 | # any other pre install hooks here 111 | end 112 | 113 | post_install do |installer| 114 | $RNMBNAV.post_install(installer) 115 | # any other post install hooks here 116 | end 117 | ``` 118 | 119 |
120 | podfile example 121 | 122 | ```ruby 123 | require_relative '../node_modules/react-native/scripts/react_native_pods' 124 | require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' 125 | 126 | platform :ios, '10.0' 127 | install! 'cocoapods', :disable_input_output_paths => true 128 | 129 | target 'AwesomeProject' do 130 | config = use_native_modules! 131 | 132 | use_react_native!(:path => config["reactNativePath"]) 133 | 134 | target 'AwesomeProjectTests' do 135 | inherit! :complete 136 | # Pods for testing 137 | end 138 | 139 | pre_install do |installer| 140 | $RNMBNAV.pre_install(installer) 141 | end 142 | 143 | # Enables Flipper. 144 | # 145 | # Note that if you have use_frameworks! enabled, Flipper will not work and 146 | # you should disable these next few lines. 147 | use_flipper! 148 | post_install do |installer| 149 | flipper_post_install(installer) 150 | $RNMBNAV.post_install(installer) 151 | end 152 | end 153 | 154 | target 'AwesomeProject-tvOS' do 155 | # Pods for AwesomeProject-tvOS 156 | 157 | target 'AwesomeProject-tvOSTests' do 158 | inherit! :search_paths 159 | # Pods for testing 160 | end 161 | end 162 | ``` 163 | 164 |
165 | 166 | Now you are ready to install the cocoapod: 167 | 168 | ``` 169 | cd ios && pod install 170 | ``` 171 | 172 | If you are experiencing a _"multiple commands produce"_ build error in your Xcode project then you will need to add this entry below to the top of your ios podfile: 173 | 174 | `install! 'cocoapods', :disable_input_output_paths => true` 175 | 176 | If you are having an issue with your archive not showing up in organizer after archiving then you will need to open `ios/Pods/Target Support Files/@react-native-mapbox-gl-mapbox-static/@react-native-mapbox-gl-mapbox-static-copy-dsyms.sh` and comment out lines 85 thru 89 - 177 | 178 |
179 | 180 | Lines 85 thru 89 181 | 182 | 183 | ```sh 184 | #install_dsym "${PODS_ROOT}/@react-native-mapbox-gl-mapbox-static/dynamic/MapboxMobileEvents.framework.dSYM" 185 | #install_bcsymbolmap "${PODS_ROOT}/@react-native-mapbox-gl-mapbox-static/dynamic/93C58D95-90B9-30C8-8F60-4BDE32FD7E8E.bcsymbolmap" 186 | #install_bcsymbolmap "${PODS_ROOT}/@react-native-mapbox-gl-mapbox-static/dynamic/BB87D8DD-493F-37AA-BD21-2BC609B8311B.bcsymbolmap" 187 | #install_bcsymbolmap "${PODS_ROOT}/@react-native-mapbox-gl-mapbox-static/dynamic/B184533A-B4A2-3D2F-AD72-A6C33D9914F4.bcsymbolmap" 188 | #install_bcsymbolmap "${PODS_ROOT}/@react-native-mapbox-gl-mapbox-static/dynamic/E2FE4B9E-73E5-34BF-B8B9-8FECEBE04D8D.bcsymbolmap" 189 | ``` 190 | 191 |
192 | 193 | For more information you can read the [docs provided by Mapbox](https://docs.mapbox.com/ios/navigation/overview/#configure-credentials). 194 | 195 | --- 196 | 197 | ### Android Specific Instructions 198 | 199 | Place your secret token in your android app's top level `gradle.properties` file: 200 | 201 | ``` 202 | MAPBOX_DOWNLOADS_TOKEN=SECRET_TOKEN_HERE 203 | ``` 204 | 205 | Open up your _project-level_ `build.gradle` file. Declare the Mapbox Downloads API's `releases/maven` endpoint in the `repositories` block. 206 | 207 | ```gradle 208 | allprojects { 209 | repositories { 210 | maven { 211 | url 'https://api.mapbox.com/downloads/v2/releases/maven' 212 | authentication { 213 | basic(BasicAuthentication) 214 | } 215 | credentials { 216 | // Do not change the username below. 217 | // This should always be `mapbox` (not your username). 218 | username = "mapbox" 219 | // Use the secret token you stored in gradle.properties as the password 220 | password = project.properties['MAPBOX_DOWNLOADS_TOKEN'] ?: "" 221 | } 222 | } 223 | } 224 | } 225 | ``` 226 | 227 | Place your public token in your project's `android/app/src/main/AndroidManifest.xml` 228 | 229 | ```xml 230 | 231 | 233 | ``` 234 | 235 | For more information you can read the [docs provided by Mapbox](https://docs.mapbox.com/android/navigation/overview/#configure-credentials). 236 | 237 | ## Usage 238 | 239 | ```jsx 240 | import * as React from "react"; 241 | import { StyleSheet, View } from "react-native"; 242 | import MapboxNavigation from "@homee/react-native-mapbox-navigation"; 243 | 244 | export const SomeComponent = () => { 245 | return ( 246 | 247 | { 253 | const { latitude, longitude } = event.nativeEvent; 254 | }} 255 | onRouteProgressChange={(event) => { 256 | const { 257 | distanceTraveled, 258 | durationRemaining, 259 | fractionTraveled, 260 | distanceRemaining, 261 | } = event.nativeEvent; 262 | }} 263 | onError={(event) => { 264 | const { message } = event.nativeEvent; 265 | }} 266 | onCancelNavigation={() => { 267 | // User tapped the "X" cancel button in the nav UI 268 | // or canceled via the OS system tray on android. 269 | // Do whatever you need to here. 270 | }} 271 | onArrive={() => { 272 | // Called when you arrive at the destination. 273 | }} 274 | /> 275 | 276 | ); 277 | }; 278 | 279 | const styles = StyleSheet.create({ 280 | container: { 281 | flex: 1, 282 | }, 283 | }); 284 | ``` 285 | 286 | ### `MapboxNavigation` Props 287 | 288 | #### `origin` (**Required**) 289 | 290 | Array that contains the longitude and latitude for the starting point.
291 | `[$longitude, $latitude]` 292 | 293 | #### `destination` (**Required**) 294 | 295 | Array that contains the longitude and latitude for the destination point.
296 | `[$longitude, $latitude]` 297 | 298 | #### `shouldSimulateRoute` 299 | 300 | Boolean that controls route simulation. Set this as `true` to auto navigate which is useful for testing or demo purposes. Defaults to `false`. 301 | 302 | #### `showsEndOfRouteFeedback` 303 | 304 | Boolean that controls showing the end of route feedback UI when the route controller arrives at the final destination. Defaults to `false`. Currently this prop is only available for iOS as the Android Mapbox SDK does not support drop-in UI for this functionality. Will need to implement this manually in Android. 305 | 306 | #### `mute` 307 | 308 | Boolean that toggles voice instructions. Defaults to `false`. 309 | 310 | #### `hideStatusView` 311 | 312 | Boolean that controls showing the `StatusView` (iOS only). This is the transparent black bar with the "Simulating Navigation" text shown in the above screenshot. Defaults to `false`. 313 | 314 | #### `onLocationChange` 315 | 316 | Function that is called frequently during route navigation. It receives `latitude` and `longitude` as parameters that represent the current location during navigation. 317 | 318 | #### `onRouteProgressChange` 319 | 320 | Function that is called frequently during route navigation. It receives `distanceTraveled`, `durationRemaining`, `fractionTraveled`, and `distanceRemaining` as parameters. 321 | 322 | #### `onError` 323 | 324 | Function that is called whenever an error occurs. It receives a `message` parameter that describes the error that occurred. 325 | 326 | #### `onCancelNavigation` 327 | 328 | Function that is called whenever a user cancels navigation. 329 | 330 | #### `onArrive` 331 | 332 | Function that is called when you arrive at the provided destination. 333 | 334 | ## Contributing 335 | 336 | Contributions are very welcome. Please check out the [contributing document](CONTRIBUTING.md). 337 | 338 | ## License 339 | 340 | The source code in this library is [MIT](LICENSE) licensed. The usage of this library will fall under Mapbox terms (this library downloads Mapbox SDKs and uses that closed source in conjunction with the open source code here). 341 | -------------------------------------------------------------------------------- /android/README.md: -------------------------------------------------------------------------------- 1 | README 2 | ====== 3 | 4 | If you want to publish the lib as a maven dependency, follow these steps before publishing a new version to npm: 5 | 6 | 1. Be sure to have the Android [SDK](https://developer.android.com/studio/index.html) and [NDK](https://developer.android.com/ndk/guides/index.html) installed 7 | 2. Be sure to have a `local.properties` file in this folder that points to the Android SDK and NDK 8 | ``` 9 | ndk.dir=/Users/{username}/Library/Android/sdk/ndk-bundle 10 | sdk.dir=/Users/{username}/Library/Android/sdk 11 | ``` 12 | 3. Delete the `maven` folder 13 | 4. Run `./gradlew installArchives` 14 | 5. Verify that latest set of generated files is in the maven folder with the correct version number 15 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | // android/build.gradle 2 | 3 | // based on: 4 | // 5 | // * https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle 6 | // original location: 7 | // - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/build.gradle 8 | // 9 | // * https://github.com/facebook/react-native/blob/0.60-stable/template/android/app/build.gradle 10 | // original location: 11 | // - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/app/build.gradle 12 | 13 | // https://www.cognizantsoftvision.com/blog/creating-an-android-native-module-for-react-native/ 14 | 15 | def DEFAULT_COMPILE_SDK_VERSION = 31 16 | def DEFAULT_BUILD_TOOLS_VERSION = '30.0.2' 17 | def DEFAULT_MIN_SDK_VERSION = 21 18 | def DEFAULT_TARGET_SDK_VERSION = 31 19 | 20 | def safeExtGet(prop, fallback) { 21 | rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback 22 | } 23 | 24 | apply plugin: 'com.android.library' 25 | apply plugin: 'kotlin-android' 26 | apply plugin: 'maven' 27 | 28 | buildscript { 29 | ext.kotlin_version = '1.5.21' 30 | // The Android Gradle plugin is only required when opening the android folder stand-alone. 31 | // This avoids unnecessary downloads and potential conflicts when the library is included as a 32 | // module dependency in an application project. 33 | // ref: https://docs.gradle.org/current/userguide/tutorial_using_tasks.html#sec:build_script_external_dependencies 34 | if (project == rootProject) { 35 | repositories { 36 | google() 37 | jcenter() 38 | } 39 | dependencies { 40 | classpath 'com.android.tools.build:gradle:4.2.2' 41 | } 42 | } 43 | 44 | repositories { 45 | mavenCentral() 46 | } 47 | 48 | dependencies { 49 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 50 | } 51 | } 52 | 53 | apply plugin: 'com.android.library' 54 | apply plugin: 'kotlin-android' 55 | apply plugin: 'maven' 56 | 57 | android { 58 | compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION) 59 | buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION) 60 | defaultConfig { 61 | minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION) 62 | targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION) 63 | versionCode 1 64 | versionName "1.0" 65 | } 66 | lintOptions { 67 | abortOnError false 68 | } 69 | compileOptions { 70 | sourceCompatibility JavaVersion.VERSION_1_8 71 | targetCompatibility JavaVersion.VERSION_1_8 72 | } 73 | kotlinOptions { 74 | jvmTarget = "1.8" 75 | } 76 | buildFeatures { 77 | viewBinding true 78 | } 79 | } 80 | 81 | repositories { 82 | // ref: https://www.baeldung.com/maven-local-repository 83 | mavenLocal() 84 | maven { 85 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 86 | url "$rootDir/../node_modules/react-native/android" 87 | } 88 | maven { 89 | // Android JSC is installed from npm 90 | url "$rootDir/../node_modules/jsc-android/dist" 91 | } 92 | google() 93 | jcenter() 94 | } 95 | 96 | dependencies { 97 | //noinspection GradleDynamicVersion 98 | implementation 'com.facebook.react:react-native:+' // From node_modules 99 | implementation "com.mapbox.navigation:android:2.1.1" 100 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 101 | implementation 'androidx.constraintlayout:constraintlayout:2.0.4' 102 | implementation 'androidx.cardview:cardview:1.0.0' 103 | } 104 | 105 | def configureReactNativePom(def pom) { 106 | def packageJson = new groovy.json.JsonSlurper().parseText(file('../package.json').text) 107 | 108 | pom.project { 109 | name packageJson.title 110 | artifactId packageJson.name 111 | version = packageJson.version 112 | group = "com.homee.mapboxnavigation" 113 | description packageJson.description 114 | url packageJson.repository.baseUrl 115 | 116 | licenses { 117 | license { 118 | name packageJson.license 119 | url packageJson.repository.baseUrl + '/blob/master/' + packageJson.licenseFilename 120 | distribution 'repo' 121 | } 122 | } 123 | } 124 | } 125 | 126 | afterEvaluate { project -> 127 | // some Gradle build hooks ref: 128 | // https://www.oreilly.com/library/view/gradle-beyond-the/9781449373801/ch03.html 129 | task androidJavadoc(type: Javadoc) { 130 | source = android.sourceSets.main.java.srcDirs 131 | classpath += files(android.bootClasspath) 132 | classpath += files(project.getConfigurations().getByName('compile').asList()) 133 | include '**/*.java' 134 | } 135 | 136 | task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) { 137 | from androidJavadoc.destinationDir 138 | } 139 | 140 | task androidSourcesJar(type: Jar) { 141 | from android.sourceSets.main.java.srcDirs 142 | include '**/*.java' 143 | } 144 | 145 | android.libraryVariants.all { variant -> 146 | def name = variant.name.capitalize() 147 | def javaCompileTask = variant.javaCompileProvider.get() 148 | 149 | task "jar${name}"(type: Jar, dependsOn: javaCompileTask) { 150 | from javaCompileTask.destinationDir 151 | } 152 | } 153 | 154 | artifacts { 155 | archives androidSourcesJar 156 | archives androidJavadocJar 157 | } 158 | 159 | task installArchives(type: Upload) { 160 | configuration = configurations.archives 161 | repositories.mavenDeployer { 162 | // Deploy to react-native-event-bridge/maven, ready to publish to npm 163 | repository url: "file://${projectDir}/../android/maven" 164 | configureReactNativePom pom 165 | } 166 | } 167 | } 168 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /android/src/main/java/com/homee/mapboxnavigation/MapboxNavigationManager.kt: -------------------------------------------------------------------------------- 1 | package com.homee.mapboxnavigation 2 | 3 | import android.content.pm.PackageManager 4 | import com.facebook.react.bridge.ReactApplicationContext 5 | import com.facebook.react.bridge.ReadableArray 6 | import com.facebook.react.common.MapBuilder 7 | import com.facebook.react.uimanager.SimpleViewManager 8 | import com.facebook.react.uimanager.ThemedReactContext 9 | import com.facebook.react.uimanager.annotations.ReactProp 10 | import com.mapbox.geojson.Point 11 | import com.mapbox.maps.ResourceOptionsManager 12 | import com.mapbox.maps.TileStoreUsageMode 13 | import javax.annotation.Nonnull 14 | 15 | class MapboxNavigationManager(var mCallerContext: ReactApplicationContext) : SimpleViewManager() { 16 | private var accessToken: String? = null 17 | 18 | init { 19 | mCallerContext.runOnUiQueueThread { 20 | try { 21 | val app = mCallerContext.packageManager.getApplicationInfo(mCallerContext.packageName, PackageManager.GET_META_DATA) 22 | val bundle = app.metaData 23 | val accessToken = bundle.getString("MAPBOX_ACCESS_TOKEN") 24 | this.accessToken = accessToken 25 | ResourceOptionsManager.getDefault(mCallerContext, accessToken).update { 26 | tileStoreUsageMode(TileStoreUsageMode.READ_ONLY) 27 | } 28 | } catch (e: PackageManager.NameNotFoundException) { 29 | e.printStackTrace() 30 | } 31 | } 32 | } 33 | 34 | override fun getName(): String { 35 | return "MapboxNavigation" 36 | } 37 | 38 | public override fun createViewInstance(@Nonnull reactContext: ThemedReactContext): MapboxNavigationView { 39 | return MapboxNavigationView(reactContext, this.accessToken) 40 | } 41 | 42 | override fun onDropViewInstance(view: MapboxNavigationView) { 43 | view.onDropViewInstance() 44 | super.onDropViewInstance(view) 45 | } 46 | 47 | override fun getExportedCustomDirectEventTypeConstants(): MutableMap>? { 48 | return MapBuilder.of>( 49 | "onLocationChange", MapBuilder.of("registrationName", "onLocationChange"), 50 | "onError", MapBuilder.of("registrationName", "onError"), 51 | "onCancelNavigation", MapBuilder.of("registrationName", "onCancelNavigation"), 52 | "onArrive", MapBuilder.of("registrationName", "onArrive"), 53 | "onRouteProgressChange", MapBuilder.of("registrationName", "onRouteProgressChange"), 54 | ) 55 | } 56 | 57 | @ReactProp(name = "origin") 58 | fun setOrigin(view: MapboxNavigationView, sources: ReadableArray?) { 59 | if (sources == null) { 60 | view.setOrigin(null) 61 | return 62 | } 63 | view.setOrigin(Point.fromLngLat(sources.getDouble(0), sources.getDouble(1))) 64 | } 65 | 66 | @ReactProp(name = "destination") 67 | fun setDestination(view: MapboxNavigationView, sources: ReadableArray?) { 68 | if (sources == null) { 69 | view.setDestination(null) 70 | return 71 | } 72 | view.setDestination(Point.fromLngLat(sources.getDouble(0), sources.getDouble(1))) 73 | } 74 | 75 | @ReactProp(name = "shouldSimulateRoute") 76 | fun setShouldSimulateRoute(view: MapboxNavigationView, shouldSimulateRoute: Boolean) { 77 | view.setShouldSimulateRoute(shouldSimulateRoute) 78 | } 79 | 80 | @ReactProp(name = "showsEndOfRouteFeedback") 81 | fun setShowsEndOfRouteFeedback(view: MapboxNavigationView, showsEndOfRouteFeedback: Boolean) { 82 | view.setShowsEndOfRouteFeedback(showsEndOfRouteFeedback) 83 | } 84 | 85 | @ReactProp(name = "mute") 86 | fun setMute(view: MapboxNavigationView, mute: Boolean) { 87 | view.setMute(mute) 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /android/src/main/java/com/homee/mapboxnavigation/MapboxNavigationPackage.kt: -------------------------------------------------------------------------------- 1 | package com.homee.mapboxnavigation 2 | 3 | import com.facebook.react.ReactPackage 4 | import com.facebook.react.bridge.NativeModule 5 | import com.facebook.react.bridge.ReactApplicationContext 6 | import com.facebook.react.uimanager.ViewManager 7 | import java.util.* 8 | 9 | class MapboxNavigationPackage : ReactPackage { 10 | override fun createNativeModules(reactContext: ReactApplicationContext): List { 11 | return emptyList() 12 | } 13 | 14 | override fun createViewManagers(reactContext: ReactApplicationContext): List> { 15 | return Arrays.asList>( 16 | MapboxNavigationManager(reactContext) 17 | ) 18 | } 19 | } -------------------------------------------------------------------------------- /android/src/main/java/com/homee/mapboxnavigation/MapboxNavigationView.kt: -------------------------------------------------------------------------------- 1 | package com.homee.mapboxnavigation 2 | 3 | import android.annotation.SuppressLint 4 | import android.content.res.Configuration 5 | import android.content.res.Resources 6 | import android.location.Location 7 | import android.location.LocationManager 8 | import android.view.LayoutInflater 9 | import android.view.View 10 | import android.widget.FrameLayout 11 | import android.widget.Toast 12 | import androidx.core.content.ContextCompat 13 | import com.facebook.react.bridge.Arguments 14 | import com.facebook.react.uimanager.ThemedReactContext 15 | import com.mapbox.api.directions.v5.models.DirectionsRoute 16 | import com.mapbox.api.directions.v5.models.RouteOptions 17 | import com.mapbox.bindgen.Expected 18 | import com.mapbox.geojson.Point 19 | import com.mapbox.maps.EdgeInsets 20 | import com.mapbox.maps.MapView 21 | import com.mapbox.maps.MapboxMap 22 | import com.mapbox.maps.Style 23 | import com.mapbox.maps.plugin.LocationPuck2D 24 | import com.mapbox.maps.plugin.animation.camera 25 | import com.mapbox.maps.plugin.locationcomponent.location 26 | import com.mapbox.navigation.base.TimeFormat 27 | import com.mapbox.navigation.base.extensions.applyDefaultNavigationOptions 28 | import com.mapbox.navigation.base.extensions.applyLanguageAndVoiceUnitOptions 29 | import com.mapbox.navigation.base.options.NavigationOptions 30 | import com.mapbox.navigation.base.route.RouterCallback 31 | import com.mapbox.navigation.base.route.RouterFailure 32 | import com.mapbox.navigation.base.route.RouterOrigin 33 | import com.mapbox.navigation.core.MapboxNavigation 34 | import com.mapbox.navigation.core.MapboxNavigationProvider 35 | import com.mapbox.navigation.core.directions.session.RoutesObserver 36 | import com.mapbox.navigation.core.formatter.MapboxDistanceFormatter 37 | import com.mapbox.navigation.core.replay.MapboxReplayer 38 | import com.mapbox.navigation.core.replay.ReplayLocationEngine 39 | import com.mapbox.navigation.core.replay.route.ReplayProgressObserver 40 | import com.mapbox.navigation.core.replay.route.ReplayRouteMapper 41 | import com.mapbox.navigation.core.trip.session.LocationMatcherResult 42 | import com.mapbox.navigation.core.trip.session.LocationObserver 43 | import com.mapbox.navigation.core.trip.session.RouteProgressObserver 44 | import com.mapbox.navigation.core.trip.session.VoiceInstructionsObserver 45 | import com.homee.mapboxnavigation.databinding.NavigationViewBinding 46 | import com.mapbox.api.directions.v5.DirectionsCriteria 47 | import com.mapbox.navigation.base.trip.model.RouteLegProgress 48 | import com.mapbox.navigation.base.trip.model.RouteProgress 49 | import com.mapbox.navigation.core.arrival.ArrivalObserver 50 | import com.mapbox.navigation.ui.base.util.MapboxNavigationConsumer 51 | import com.mapbox.navigation.ui.maneuver.api.MapboxManeuverApi 52 | import com.mapbox.navigation.ui.maneuver.view.MapboxManeuverView 53 | import com.mapbox.navigation.ui.maps.camera.NavigationCamera 54 | import com.mapbox.navigation.ui.maps.camera.data.MapboxNavigationViewportDataSource 55 | import com.mapbox.navigation.ui.maps.camera.lifecycle.NavigationBasicGesturesHandler 56 | import com.mapbox.navigation.ui.maps.camera.state.NavigationCameraState 57 | import com.mapbox.navigation.ui.maps.camera.transition.NavigationCameraTransitionOptions 58 | import com.mapbox.navigation.ui.maps.location.NavigationLocationProvider 59 | import com.mapbox.navigation.ui.maps.route.arrow.api.MapboxRouteArrowApi 60 | import com.mapbox.navigation.ui.maps.route.arrow.api.MapboxRouteArrowView 61 | import com.mapbox.navigation.ui.maps.route.arrow.model.RouteArrowOptions 62 | import com.mapbox.navigation.ui.maps.route.line.api.MapboxRouteLineApi 63 | import com.mapbox.navigation.ui.maps.route.line.api.MapboxRouteLineView 64 | import com.mapbox.navigation.ui.maps.route.line.model.MapboxRouteLineOptions 65 | import com.mapbox.navigation.ui.maps.route.line.model.RouteLine 66 | import com.mapbox.navigation.ui.tripprogress.api.MapboxTripProgressApi 67 | import com.mapbox.navigation.ui.tripprogress.model.DistanceRemainingFormatter 68 | import com.mapbox.navigation.ui.tripprogress.model.EstimatedTimeToArrivalFormatter 69 | import com.mapbox.navigation.ui.tripprogress.model.PercentDistanceTraveledFormatter 70 | import com.mapbox.navigation.ui.tripprogress.model.TimeRemainingFormatter 71 | import com.mapbox.navigation.ui.tripprogress.model.TripProgressUpdateFormatter 72 | import com.mapbox.navigation.ui.tripprogress.view.MapboxTripProgressView 73 | import com.mapbox.navigation.ui.voice.api.MapboxSpeechApi 74 | import com.mapbox.navigation.ui.voice.api.MapboxVoiceInstructionsPlayer 75 | import com.mapbox.navigation.ui.voice.model.SpeechAnnouncement 76 | import com.mapbox.navigation.ui.voice.model.SpeechError 77 | import com.mapbox.navigation.ui.voice.model.SpeechValue 78 | import com.mapbox.navigation.ui.voice.model.SpeechVolume 79 | import java.util.Locale 80 | import com.facebook.react.uimanager.events.RCTEventEmitter 81 | 82 | class MapboxNavigationView(private val context: ThemedReactContext, private val accessToken: String?) : 83 | FrameLayout(context.baseContext) { 84 | 85 | private companion object { 86 | private const val BUTTON_ANIMATION_DURATION = 1500L 87 | } 88 | 89 | private var origin: Point? = null 90 | private var destination: Point? = null 91 | private var shouldSimulateRoute = false 92 | private var showsEndOfRouteFeedback = false 93 | /** 94 | * Debug tool used to play, pause and seek route progress events that can be used to produce mocked location updates along the route. 95 | */ 96 | private val mapboxReplayer = MapboxReplayer() 97 | 98 | /** 99 | * Debug tool that mocks location updates with an input from the [mapboxReplayer]. 100 | */ 101 | private val replayLocationEngine = ReplayLocationEngine(mapboxReplayer) 102 | 103 | /** 104 | * Debug observer that makes sure the replayer has always an up-to-date information to generate mock updates. 105 | */ 106 | private val replayProgressObserver = ReplayProgressObserver(mapboxReplayer) 107 | 108 | /** 109 | * Bindings to the example layout. 110 | */ 111 | private var binding: NavigationViewBinding = 112 | NavigationViewBinding.inflate(LayoutInflater.from(context), this, true) 113 | 114 | /** 115 | * Mapbox Maps entry point obtained from the [MapView]. 116 | * You need to get a new reference to this object whenever the [MapView] is recreated. 117 | */ 118 | private lateinit var mapboxMap: MapboxMap 119 | 120 | /** 121 | * Mapbox Navigation entry point. There should only be one instance of this object for the app. 122 | * You can use [MapboxNavigationProvider] to help create and obtain that instance. 123 | */ 124 | private lateinit var mapboxNavigation: MapboxNavigation 125 | 126 | /** 127 | * Used to execute camera transitions based on the data generated by the [viewportDataSource]. 128 | * This includes transitions from route overview to route following and continuously updating the camera as the location changes. 129 | */ 130 | private lateinit var navigationCamera: NavigationCamera 131 | 132 | /** 133 | * Produces the camera frames based on the location and routing data for the [navigationCamera] to execute. 134 | */ 135 | private lateinit var viewportDataSource: MapboxNavigationViewportDataSource 136 | 137 | /* 138 | * Below are generated camera padding values to ensure that the route fits well on screen while 139 | * other elements are overlaid on top of the map (including instruction view, buttons, etc.) 140 | */ 141 | private val pixelDensity = Resources.getSystem().displayMetrics.density 142 | private val overviewPadding: EdgeInsets by lazy { 143 | EdgeInsets( 144 | 140.0 * pixelDensity, 145 | 40.0 * pixelDensity, 146 | 120.0 * pixelDensity, 147 | 40.0 * pixelDensity 148 | ) 149 | } 150 | private val landscapeOverviewPadding: EdgeInsets by lazy { 151 | EdgeInsets( 152 | 30.0 * pixelDensity, 153 | 380.0 * pixelDensity, 154 | 110.0 * pixelDensity, 155 | 20.0 * pixelDensity 156 | ) 157 | } 158 | private val followingPadding: EdgeInsets by lazy { 159 | EdgeInsets( 160 | 180.0 * pixelDensity, 161 | 40.0 * pixelDensity, 162 | 150.0 * pixelDensity, 163 | 40.0 * pixelDensity 164 | ) 165 | } 166 | private val landscapeFollowingPadding: EdgeInsets by lazy { 167 | EdgeInsets( 168 | 30.0 * pixelDensity, 169 | 380.0 * pixelDensity, 170 | 110.0 * pixelDensity, 171 | 40.0 * pixelDensity 172 | ) 173 | } 174 | 175 | /** 176 | * Generates updates for the [MapboxManeuverView] to display the upcoming maneuver instructions 177 | * and remaining distance to the maneuver point. 178 | */ 179 | private lateinit var maneuverApi: MapboxManeuverApi 180 | 181 | /** 182 | * Generates updates for the [MapboxTripProgressView] that include remaining time and distance to the destination. 183 | */ 184 | private lateinit var tripProgressApi: MapboxTripProgressApi 185 | 186 | /** 187 | * Generates updates for the [routeLineView] with the geometries and properties of the routes that should be drawn on the map. 188 | */ 189 | private lateinit var routeLineApi: MapboxRouteLineApi 190 | 191 | /** 192 | * Draws route lines on the map based on the data from the [routeLineApi] 193 | */ 194 | private lateinit var routeLineView: MapboxRouteLineView 195 | 196 | /** 197 | * Generates updates for the [routeArrowView] with the geometries and properties of maneuver arrows that should be drawn on the map. 198 | */ 199 | private val routeArrowApi: MapboxRouteArrowApi = MapboxRouteArrowApi() 200 | 201 | /** 202 | * Draws maneuver arrows on the map based on the data [routeArrowApi]. 203 | */ 204 | private lateinit var routeArrowView: MapboxRouteArrowView 205 | 206 | /** 207 | * Stores and updates the state of whether the voice instructions should be played as they come or muted. 208 | */ 209 | private var isVoiceInstructionsMuted = false 210 | set(value) { 211 | field = value 212 | if (value) { 213 | binding.soundButton.muteAndExtend(BUTTON_ANIMATION_DURATION) 214 | voiceInstructionsPlayer.volume(SpeechVolume(0f)) 215 | } else { 216 | binding.soundButton.unmuteAndExtend(BUTTON_ANIMATION_DURATION) 217 | voiceInstructionsPlayer.volume(SpeechVolume(1f)) 218 | } 219 | } 220 | 221 | /** 222 | * Extracts message that should be communicated to the driver about the upcoming maneuver. 223 | * When possible, downloads a synthesized audio file that can be played back to the driver. 224 | */ 225 | private lateinit var speechApi: MapboxSpeechApi 226 | 227 | /** 228 | * Plays the synthesized audio files with upcoming maneuver instructions 229 | * or uses an on-device Text-To-Speech engine to communicate the message to the driver. 230 | */ 231 | private lateinit var voiceInstructionsPlayer: MapboxVoiceInstructionsPlayer 232 | 233 | /** 234 | * Observes when a new voice instruction should be played. 235 | */ 236 | private val voiceInstructionsObserver = VoiceInstructionsObserver { voiceInstructions -> 237 | speechApi.generate(voiceInstructions, speechCallback) 238 | } 239 | 240 | /** 241 | * Based on whether the synthesized audio file is available, the callback plays the file 242 | * or uses the fall back which is played back using the on-device Text-To-Speech engine. 243 | */ 244 | private val speechCallback = 245 | MapboxNavigationConsumer> { expected -> 246 | expected.fold( 247 | { error -> 248 | // play the instruction via fallback text-to-speech engine 249 | voiceInstructionsPlayer.play( 250 | error.fallback, 251 | voiceInstructionsPlayerCallback 252 | ) 253 | }, 254 | { value -> 255 | // play the sound file from the external generator 256 | voiceInstructionsPlayer.play( 257 | value.announcement, 258 | voiceInstructionsPlayerCallback 259 | ) 260 | } 261 | ) 262 | } 263 | 264 | /** 265 | * When a synthesized audio file was downloaded, this callback cleans up the disk after it was played. 266 | */ 267 | private val voiceInstructionsPlayerCallback = 268 | MapboxNavigationConsumer { value -> 269 | // remove already consumed file to free-up space 270 | speechApi.clean(value) 271 | } 272 | 273 | /** 274 | * [NavigationLocationProvider] is a utility class that helps to provide location updates generated by the Navigation SDK 275 | * to the Maps SDK in order to update the user location indicator on the map. 276 | */ 277 | private val navigationLocationProvider = NavigationLocationProvider() 278 | 279 | /** 280 | * Gets notified with location updates. 281 | * 282 | * Exposes raw updates coming directly from the location services 283 | * and the updates enhanced by the Navigation SDK (cleaned up and matched to the road). 284 | */ 285 | private val locationObserver = object : LocationObserver { 286 | override fun onNewRawLocation(rawLocation: Location) { 287 | // not handled 288 | } 289 | 290 | override fun onNewLocationMatcherResult(locationMatcherResult: LocationMatcherResult) { 291 | val enhancedLocation = locationMatcherResult.enhancedLocation 292 | // update location puck's position on the map 293 | navigationLocationProvider.changePosition( 294 | location = enhancedLocation, 295 | keyPoints = locationMatcherResult.keyPoints, 296 | ) 297 | 298 | // update camera position to account for new location 299 | viewportDataSource.onLocationChanged(enhancedLocation) 300 | viewportDataSource.evaluate() 301 | 302 | val event = Arguments.createMap() 303 | event.putDouble("longitude", enhancedLocation.longitude) 304 | event.putDouble("latitude", enhancedLocation.latitude) 305 | context 306 | .getJSModule(RCTEventEmitter::class.java) 307 | .receiveEvent(id, "onLocationChange", event) 308 | } 309 | } 310 | 311 | /** 312 | * Gets notified with progress along the currently active route. 313 | */ 314 | private val routeProgressObserver = RouteProgressObserver { routeProgress -> 315 | // update the camera position to account for the progressed fragment of the route 316 | viewportDataSource.onRouteProgressChanged(routeProgress) 317 | viewportDataSource.evaluate() 318 | 319 | // draw the upcoming maneuver arrow on the map 320 | val style = mapboxMap.getStyle() 321 | if (style != null) { 322 | val maneuverArrowResult = routeArrowApi.addUpcomingManeuverArrow(routeProgress) 323 | routeArrowView.renderManeuverUpdate(style, maneuverArrowResult) 324 | } 325 | 326 | // update top banner with maneuver instructions 327 | val maneuvers = maneuverApi.getManeuvers(routeProgress) 328 | maneuvers.fold( 329 | { error -> 330 | Toast.makeText( 331 | context, 332 | error.errorMessage, 333 | Toast.LENGTH_SHORT 334 | ).show() 335 | }, 336 | { 337 | binding.maneuverView.visibility = View.VISIBLE 338 | binding.maneuverView.updatePrimaryManeuverTextAppearance(R.style.PrimaryManeuverTextAppearance) 339 | binding.maneuverView.updateSecondaryManeuverTextAppearance(R.style.ManeuverTextAppearance) 340 | binding.maneuverView.updateSubManeuverTextAppearance(R.style.ManeuverTextAppearance) 341 | binding.maneuverView.updateStepDistanceTextAppearance(R.style.StepDistanceRemainingAppearance) 342 | binding.maneuverView.renderManeuvers(maneuvers) 343 | } 344 | ) 345 | 346 | // update bottom trip progress summary 347 | binding.tripProgressView.render( 348 | tripProgressApi.getTripProgress(routeProgress) 349 | ) 350 | 351 | val event = Arguments.createMap() 352 | event.putDouble("distanceTraveled", routeProgress.distanceTraveled.toDouble()) 353 | event.putDouble("durationRemaining", routeProgress.durationRemaining.toDouble()) 354 | event.putDouble("fractionTraveled", routeProgress.fractionTraveled.toDouble()) 355 | event.putDouble("distanceRemaining", routeProgress.distanceRemaining.toDouble()) 356 | context 357 | .getJSModule(RCTEventEmitter::class.java) 358 | .receiveEvent(id, "onRouteProgressChange", event) 359 | } 360 | 361 | /** 362 | * Gets notified whenever the tracked routes change. 363 | * 364 | * A change can mean: 365 | * - routes get changed with [MapboxNavigation.setRoutes] 366 | * - routes annotations get refreshed (for example, congestion annotation that indicate the live traffic along the route) 367 | * - driver got off route and a reroute was executed 368 | */ 369 | private val routesObserver = RoutesObserver { routeUpdateResult -> 370 | if (routeUpdateResult.routes.isNotEmpty()) { 371 | // generate route geometries asynchronously and render them 372 | val routeLines = routeUpdateResult.routes.map { RouteLine(it, null) } 373 | 374 | routeLineApi.setRoutes( 375 | routeLines 376 | ) { value -> 377 | mapboxMap.getStyle()?.apply { 378 | routeLineView.renderRouteDrawData(this, value) 379 | } 380 | } 381 | 382 | // update the camera position to account for the new route 383 | viewportDataSource.onRouteChanged(routeUpdateResult.routes.first()) 384 | viewportDataSource.evaluate() 385 | } else { 386 | // remove the route line and route arrow from the map 387 | val style = mapboxMap.getStyle() 388 | if (style != null) { 389 | routeLineApi.clearRouteLine { value -> 390 | routeLineView.renderClearRouteLineValue( 391 | style, 392 | value 393 | ) 394 | } 395 | routeArrowView.render(style, routeArrowApi.clearArrows()) 396 | } 397 | 398 | // remove the route reference from camera position evaluations 399 | viewportDataSource.clearRouteData() 400 | viewportDataSource.evaluate() 401 | } 402 | } 403 | 404 | private val arrivalObserver = object : ArrivalObserver { 405 | 406 | override fun onWaypointArrival(routeProgress: RouteProgress) { 407 | // do something when the user arrives at a waypoint 408 | } 409 | 410 | override fun onNextRouteLegStart(routeLegProgress: RouteLegProgress) { 411 | // do something when the user starts a new leg 412 | } 413 | 414 | override fun onFinalDestinationArrival(routeProgress: RouteProgress) { 415 | val event = Arguments.createMap() 416 | event.putString("onArrive", "") 417 | context 418 | .getJSModule(RCTEventEmitter::class.java) 419 | .receiveEvent(id, "onRouteProgressChange", event) 420 | } 421 | } 422 | 423 | 424 | override fun onAttachedToWindow() { 425 | super.onAttachedToWindow() 426 | onCreate() 427 | } 428 | 429 | override fun requestLayout() { 430 | super.requestLayout() 431 | post(measureAndLayout) 432 | } 433 | 434 | private val measureAndLayout = Runnable { 435 | measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), 436 | MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY)) 437 | layout(left, top, right, bottom) 438 | } 439 | 440 | private fun setCameraPositionToOrigin() { 441 | val startingLocation = Location(LocationManager.GPS_PROVIDER) 442 | startingLocation.latitude = origin!!.latitude() 443 | startingLocation.longitude = origin!!.longitude() 444 | viewportDataSource.onLocationChanged(startingLocation) 445 | 446 | navigationCamera.requestNavigationCameraToFollowing( 447 | stateTransitionOptions = NavigationCameraTransitionOptions.Builder() 448 | .maxDuration(0) // instant transition 449 | .build() 450 | ) 451 | } 452 | 453 | @SuppressLint("MissingPermission") 454 | fun onCreate() { 455 | if (accessToken == null) { 456 | sendErrorToReact("Mapbox access token is not set") 457 | return 458 | } 459 | 460 | if (origin == null || destination == null) { 461 | sendErrorToReact("origin and destination are required") 462 | return 463 | } 464 | 465 | mapboxMap = binding.mapView.getMapboxMap() 466 | 467 | // initialize the location puck 468 | binding.mapView.location.apply { 469 | this.locationPuck = LocationPuck2D( 470 | bearingImage = ContextCompat.getDrawable( 471 | context, 472 | R.drawable.mapbox_navigation_puck_icon 473 | ) 474 | ) 475 | setLocationProvider(navigationLocationProvider) 476 | enabled = true 477 | } 478 | 479 | // initialize Mapbox Navigation 480 | mapboxNavigation = if (MapboxNavigationProvider.isCreated()) { 481 | MapboxNavigationProvider.retrieve() 482 | } else if (shouldSimulateRoute) { 483 | MapboxNavigationProvider.create( 484 | NavigationOptions.Builder(context) 485 | .accessToken(accessToken) 486 | .locationEngine(replayLocationEngine) 487 | .build() 488 | ) 489 | } else { 490 | MapboxNavigationProvider.create( 491 | NavigationOptions.Builder(context) 492 | .accessToken(accessToken) 493 | .build() 494 | ) 495 | } 496 | 497 | // initialize Navigation Camera 498 | viewportDataSource = MapboxNavigationViewportDataSource(mapboxMap) 499 | 500 | navigationCamera = NavigationCamera( 501 | mapboxMap, 502 | binding.mapView.camera, 503 | viewportDataSource 504 | ) 505 | // set the animations lifecycle listener to ensure the NavigationCamera stops 506 | // automatically following the user location when the map is interacted with 507 | binding.mapView.camera.addCameraAnimationsLifecycleListener( 508 | NavigationBasicGesturesHandler(navigationCamera) 509 | ) 510 | navigationCamera.registerNavigationCameraStateChangeObserver { navigationCameraState -> 511 | // shows/hide the recenter button depending on the camera state 512 | when (navigationCameraState) { 513 | NavigationCameraState.TRANSITION_TO_FOLLOWING, 514 | NavigationCameraState.FOLLOWING -> binding.recenter.visibility = View.INVISIBLE 515 | NavigationCameraState.TRANSITION_TO_OVERVIEW, 516 | NavigationCameraState.OVERVIEW, 517 | NavigationCameraState.IDLE -> binding.recenter.visibility = View.VISIBLE 518 | } 519 | } 520 | // set the padding values depending on screen orientation and visible view layout 521 | if (this.resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) { 522 | viewportDataSource.overviewPadding = landscapeOverviewPadding 523 | } else { 524 | viewportDataSource.overviewPadding = overviewPadding 525 | } 526 | if (this.resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) { 527 | viewportDataSource.followingPadding = landscapeFollowingPadding 528 | } else { 529 | viewportDataSource.followingPadding = followingPadding 530 | } 531 | 532 | // make sure to use the same DistanceFormatterOptions across different features 533 | val distanceFormatterOptions = mapboxNavigation.navigationOptions.distanceFormatterOptions 534 | 535 | // initialize maneuver api that feeds the data to the top banner maneuver view 536 | maneuverApi = MapboxManeuverApi( 537 | MapboxDistanceFormatter(distanceFormatterOptions) 538 | ) 539 | 540 | // initialize bottom progress view 541 | tripProgressApi = MapboxTripProgressApi( 542 | TripProgressUpdateFormatter.Builder(context) 543 | .distanceRemainingFormatter( 544 | DistanceRemainingFormatter(distanceFormatterOptions) 545 | ) 546 | .timeRemainingFormatter( 547 | TimeRemainingFormatter(context) 548 | ) 549 | .percentRouteTraveledFormatter( 550 | PercentDistanceTraveledFormatter() 551 | ) 552 | .estimatedTimeToArrivalFormatter( 553 | EstimatedTimeToArrivalFormatter(context, TimeFormat.NONE_SPECIFIED) 554 | ) 555 | .build() 556 | ) 557 | 558 | // initialize voice instructions api and the voice instruction player 559 | speechApi = MapboxSpeechApi( 560 | context, 561 | accessToken, 562 | Locale.US.language 563 | ) 564 | voiceInstructionsPlayer = MapboxVoiceInstructionsPlayer( 565 | context, 566 | accessToken, 567 | Locale.US.language 568 | ) 569 | 570 | // initialize route line, the withRouteLineBelowLayerId is specified to place 571 | // the route line below road labels layer on the map 572 | // the value of this option will depend on the style that you are using 573 | // and under which layer the route line should be placed on the map layers stack 574 | val mapboxRouteLineOptions = MapboxRouteLineOptions.Builder(context) 575 | .withRouteLineBelowLayerId("road-label") 576 | .build() 577 | routeLineApi = MapboxRouteLineApi(mapboxRouteLineOptions) 578 | routeLineView = MapboxRouteLineView(mapboxRouteLineOptions) 579 | 580 | // initialize maneuver arrow view to draw arrows on the map 581 | val routeArrowOptions = RouteArrowOptions.Builder(context).build() 582 | routeArrowView = MapboxRouteArrowView(routeArrowOptions) 583 | 584 | setCameraPositionToOrigin() 585 | // load map style 586 | mapboxMap.loadStyleUri( 587 | Style.MAPBOX_STREETS 588 | ) 589 | 590 | // initialize view interactions 591 | binding.stop.setOnClickListener { 592 | // clearRouteAndStopNavigation() // TODO: figure out how we want to address this since a user cannot reinitialize a route once it is canceled. 593 | val event = Arguments.createMap() 594 | event.putString("onCancelNavigation", "Navigation Closed") 595 | context 596 | .getJSModule(RCTEventEmitter::class.java) 597 | .receiveEvent(id, "onCancelNavigation", event) 598 | } 599 | binding.recenter.setOnClickListener { 600 | navigationCamera.requestNavigationCameraToFollowing() 601 | binding.routeOverview.showTextAndExtend(BUTTON_ANIMATION_DURATION) 602 | } 603 | binding.routeOverview.setOnClickListener { 604 | navigationCamera.requestNavigationCameraToOverview() 605 | binding.recenter.showTextAndExtend(BUTTON_ANIMATION_DURATION) 606 | } 607 | binding.soundButton.setOnClickListener { 608 | // mute/unmute voice instructions 609 | isVoiceInstructionsMuted = !isVoiceInstructionsMuted 610 | } 611 | 612 | // set initial sounds button state 613 | binding.soundButton.unmute() 614 | 615 | // start the trip session to being receiving location updates in free drive 616 | // and later when a route is set also receiving route progress updates 617 | mapboxNavigation.startTripSession() 618 | startRoute() 619 | } 620 | 621 | private fun startRoute() { 622 | // register event listeners 623 | mapboxNavigation.registerRoutesObserver(routesObserver) 624 | mapboxNavigation.registerArrivalObserver(arrivalObserver) 625 | mapboxNavigation.registerRouteProgressObserver(routeProgressObserver) 626 | mapboxNavigation.registerLocationObserver(locationObserver) 627 | mapboxNavigation.registerVoiceInstructionsObserver(voiceInstructionsObserver) 628 | mapboxNavigation.registerRouteProgressObserver(replayProgressObserver) 629 | 630 | this.origin?.let { this.destination?.let { it1 -> this.findRoute(it, it1) } } 631 | } 632 | 633 | override fun onDetachedFromWindow() { 634 | super.onDetachedFromWindow() 635 | mapboxNavigation.unregisterRoutesObserver(routesObserver) 636 | mapboxNavigation.unregisterRouteProgressObserver(routeProgressObserver) 637 | mapboxNavigation.unregisterLocationObserver(locationObserver) 638 | mapboxNavigation.unregisterVoiceInstructionsObserver(voiceInstructionsObserver) 639 | mapboxNavigation.unregisterRouteProgressObserver(replayProgressObserver) 640 | } 641 | 642 | private fun onDestroy() { 643 | MapboxNavigationProvider.destroy() 644 | mapboxReplayer.finish() 645 | maneuverApi.cancel() 646 | routeLineApi.cancel() 647 | routeLineView.cancel() 648 | speechApi.cancel() 649 | voiceInstructionsPlayer.shutdown() 650 | } 651 | 652 | private fun findRoute(origin: Point, destination: Point) { 653 | try { 654 | mapboxNavigation.requestRoutes( 655 | RouteOptions.builder() 656 | .applyDefaultNavigationOptions() 657 | .applyLanguageAndVoiceUnitOptions(context) 658 | .coordinatesList(listOf(origin, destination)) 659 | .profile(DirectionsCriteria.PROFILE_DRIVING) 660 | .steps(true) 661 | .build(), 662 | object : RouterCallback { 663 | override fun onRoutesReady( 664 | routes: List, 665 | routerOrigin: RouterOrigin 666 | ) { 667 | setRouteAndStartNavigation(routes) 668 | } 669 | 670 | override fun onFailure( 671 | reasons: List, 672 | routeOptions: RouteOptions 673 | ) { 674 | sendErrorToReact("Error finding route $reasons") 675 | } 676 | 677 | override fun onCanceled(routeOptions: RouteOptions, routerOrigin: RouterOrigin) { 678 | // no impl 679 | } 680 | } 681 | ) 682 | } catch (ex: Exception) { 683 | sendErrorToReact(ex.toString()) 684 | } 685 | 686 | } 687 | 688 | private fun sendErrorToReact(error: String?) { 689 | val event = Arguments.createMap() 690 | event.putString("error", error) 691 | context 692 | .getJSModule(RCTEventEmitter::class.java) 693 | .receiveEvent(id, "onError", event) 694 | } 695 | 696 | private fun setRouteAndStartNavigation(routes: List) { 697 | if (routes.isEmpty()) { 698 | sendErrorToReact("No route found") 699 | return; 700 | } 701 | // set routes, where the first route in the list is the primary route that 702 | // will be used for active guidance 703 | mapboxNavigation.setRoutes(routes) 704 | 705 | // start location simulation along the primary route 706 | if (shouldSimulateRoute) { 707 | startSimulation(routes.first()) 708 | } 709 | 710 | // show UI elements 711 | binding.soundButton.visibility = View.VISIBLE 712 | binding.routeOverview.visibility = View.VISIBLE 713 | binding.tripProgressCard.visibility = View.VISIBLE 714 | 715 | // move the camera to overview when new route is available 716 | navigationCamera.requestNavigationCameraToFollowing() 717 | } 718 | 719 | private fun clearRouteAndStopNavigation() { 720 | // clear 721 | mapboxNavigation.setRoutes(listOf()) 722 | 723 | // stop simulation 724 | mapboxReplayer.stop() 725 | 726 | // hide UI elements 727 | binding.soundButton.visibility = View.INVISIBLE 728 | binding.maneuverView.visibility = View.INVISIBLE 729 | binding.routeOverview.visibility = View.INVISIBLE 730 | binding.tripProgressCard.visibility = View.INVISIBLE 731 | } 732 | 733 | private fun startSimulation(route: DirectionsRoute) { 734 | mapboxReplayer.run { 735 | stop() 736 | clearEvents() 737 | val replayEvents = ReplayRouteMapper().mapDirectionsRouteGeometry(route) 738 | pushEvents(replayEvents) 739 | seekTo(replayEvents.first()) 740 | play() 741 | } 742 | } 743 | 744 | fun onDropViewInstance() { 745 | this.onDestroy() 746 | } 747 | 748 | fun setOrigin(origin: Point?) { 749 | this.origin = origin 750 | } 751 | 752 | fun setDestination(destination: Point?) { 753 | this.destination = destination 754 | } 755 | 756 | fun setShouldSimulateRoute(shouldSimulateRoute: Boolean) { 757 | this.shouldSimulateRoute = shouldSimulateRoute 758 | } 759 | 760 | fun setShowsEndOfRouteFeedback(showsEndOfRouteFeedback: Boolean) { 761 | this.showsEndOfRouteFeedback = showsEndOfRouteFeedback 762 | } 763 | 764 | fun setMute(mute: Boolean) { 765 | this.isVoiceInstructionsMuted = mute 766 | } 767 | } 768 | -------------------------------------------------------------------------------- /android/src/main/res/layout/navigation_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 15 | 16 | 26 | 27 | 33 | 34 | 42 | 43 | 44 | 53 | 54 | 63 | 64 | 73 | 74 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /android/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 11 | 15 | 16 | -------------------------------------------------------------------------------- /dist/index.d.ts: -------------------------------------------------------------------------------- 1 | import { IMapboxNavigationProps } from './typings'; 2 | declare const MapboxNavigation: (props: IMapboxNavigationProps) => any; 3 | export default MapboxNavigation; 4 | -------------------------------------------------------------------------------- /dist/index.js: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import { requireNativeComponent, StyleSheet } from 'react-native'; 3 | const MapboxNavigation = (props) => { 4 | return ; 5 | }; 6 | const RNMapboxNavigation = requireNativeComponent('MapboxNavigation', MapboxNavigation); 7 | const styles = StyleSheet.create({ 8 | container: { 9 | flex: 1, 10 | }, 11 | }); 12 | export default MapboxNavigation; 13 | -------------------------------------------------------------------------------- /dist/typings.d.ts: -------------------------------------------------------------------------------- 1 | /** @type {[number, number]} 2 | * Provide an array with longitude and latitude [$longitude, $latitude] 3 | */ 4 | declare type Coordinate = [number, number]; 5 | declare type OnLocationChangeEvent = { 6 | nativeEvent?: { 7 | latitude: number; 8 | longitude: number; 9 | }; 10 | }; 11 | declare type OnRouteProgressChangeEvent = { 12 | nativeEvent?: { 13 | distanceTraveled: number; 14 | durationRemaining: number; 15 | fractionTraveled: number; 16 | distanceRemaining: number; 17 | }; 18 | }; 19 | declare type OnErrorEvent = { 20 | nativeEvent?: { 21 | message?: string; 22 | }; 23 | }; 24 | export interface IMapboxNavigationProps { 25 | origin: Coordinate; 26 | destination: Coordinate; 27 | shouldSimulateRoute?: boolean; 28 | onLocationChange?: (event: OnLocationChangeEvent) => void; 29 | onRouteProgressChange?: (event: OnRouteProgressChangeEvent) => void; 30 | onError?: (event: OnErrorEvent) => void; 31 | onCancelNavigation?: () => void; 32 | onArrive?: () => void; 33 | showsEndOfRouteFeedback?: boolean; 34 | hideStatusView?: boolean; 35 | mute?: boolean; 36 | } 37 | export {}; 38 | -------------------------------------------------------------------------------- /dist/typings.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /example/.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /example/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | extends: '@react-native-community', 4 | }; 5 | -------------------------------------------------------------------------------- /example/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | ; We fork some components by platform 3 | .*/*[.]android.js 4 | 5 | ; Ignore "BUCK" generated dirs 6 | /\.buckd/ 7 | 8 | ; Ignore polyfills 9 | node_modules/react-native/Libraries/polyfills/.* 10 | 11 | ; Flow doesn't support platforms 12 | .*/Libraries/Utilities/LoadingView.js 13 | 14 | [untyped] 15 | .*/node_modules/@react-native-community/cli/.*/.* 16 | 17 | [include] 18 | 19 | [libs] 20 | node_modules/react-native/interface.js 21 | node_modules/react-native/flow/ 22 | 23 | [options] 24 | emoji=true 25 | 26 | exact_by_default=true 27 | 28 | format.bracket_spacing=false 29 | 30 | module.file_ext=.js 31 | module.file_ext=.json 32 | module.file_ext=.ios.js 33 | 34 | munge_underscores=true 35 | 36 | module.name_mapper='^react-native/\(.*\)$' -> '/node_modules/react-native/\1' 37 | module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '/node_modules/react-native/Libraries/Image/RelativeImageStub' 38 | 39 | suppress_type=$FlowIssue 40 | suppress_type=$FlowFixMe 41 | suppress_type=$FlowFixMeProps 42 | suppress_type=$FlowFixMeState 43 | 44 | [lints] 45 | sketchy-null-number=warn 46 | sketchy-null-mixed=warn 47 | sketchy-number=warn 48 | untyped-type-import=warn 49 | nonstrict-import=warn 50 | deprecated-type=warn 51 | unsafe-getters-setters=warn 52 | unnecessary-invariant=warn 53 | signature-verification-failure=warn 54 | 55 | [strict] 56 | deprecated-type 57 | nonstrict-import 58 | sketchy-null 59 | unclear-type 60 | unsafe-getters-setters 61 | untyped-import 62 | untyped-type-import 63 | 64 | [version] 65 | ^0.158.0 66 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | 24 | # Android/IntelliJ 25 | # 26 | build/ 27 | .idea 28 | .gradle 29 | local.properties 30 | *.iml 31 | *.hprof 32 | 33 | # node.js 34 | # 35 | node_modules/ 36 | npm-debug.log 37 | yarn-error.log 38 | 39 | # BUCK 40 | buck-out/ 41 | \.buckd/ 42 | *.keystore 43 | !debug.keystore 44 | 45 | # fastlane 46 | # 47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 48 | # screenshots whenever they are needed. 49 | # For more information about the recommended setup visit: 50 | # https://docs.fastlane.tools/best-practices/source-control/ 51 | 52 | */fastlane/report.xml 53 | */fastlane/Preview.html 54 | */fastlane/screenshots 55 | 56 | # Bundle artifact 57 | *.jsbundle 58 | 59 | # CocoaPods 60 | /ios/Pods/ 61 | -------------------------------------------------------------------------------- /example/.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | bracketSpacing: false, 3 | jsxBracketSameLine: true, 4 | singleQuote: true, 5 | trailingComma: 'all', 6 | arrowParens: 'avoid', 7 | }; 8 | -------------------------------------------------------------------------------- /example/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /example/App.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sample React Native App 3 | * https://github.com/facebook/react-native 4 | * 5 | * @format 6 | * @flow strict-local 7 | */ 8 | 9 | import React, {useEffect} from 'react'; 10 | import {SafeAreaView, useColorScheme} from 'react-native'; 11 | import {Colors} from 'react-native/Libraries/NewAppScreen'; 12 | import NavigationComponent from './NavigationComponent'; 13 | import {PermissionsAndroid} from 'react-native'; 14 | 15 | const App = () => { 16 | const isDarkMode = useColorScheme() === 'dark'; 17 | 18 | const backgroundStyle = { 19 | backgroundColor: isDarkMode ? Colors.darker : Colors.lighter, 20 | flex: 1, 21 | }; 22 | 23 | useEffect(() => { 24 | const requestLocationPermission = async () => { 25 | try { 26 | await PermissionsAndroid.request( 27 | PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION, 28 | { 29 | title: 'Example App', 30 | message: 'Example App access to your location ', 31 | }, 32 | ); 33 | } catch (err) { 34 | console.warn(err); 35 | } 36 | }; 37 | 38 | requestLocationPermission(); 39 | }, []); 40 | 41 | return ( 42 | 43 | 47 | 48 | ); 49 | }; 50 | 51 | export default App; 52 | -------------------------------------------------------------------------------- /example/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # You may use http://rbenv.org/ or https://rvm.io/ to install and use this version 4 | ruby '2.7.4' 5 | 6 | gem 'cocoapods', '~> 1.11', '>= 1.11.2' 7 | -------------------------------------------------------------------------------- /example/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | CFPropertyList (3.0.5) 5 | rexml 6 | activesupport (6.1.4.4) 7 | concurrent-ruby (~> 1.0, >= 1.0.2) 8 | i18n (>= 1.6, < 2) 9 | minitest (>= 5.1) 10 | tzinfo (~> 2.0) 11 | zeitwerk (~> 2.3) 12 | addressable (2.8.0) 13 | public_suffix (>= 2.0.2, < 5.0) 14 | algoliasearch (1.27.5) 15 | httpclient (~> 2.8, >= 2.8.3) 16 | json (>= 1.5.1) 17 | atomos (0.1.3) 18 | claide (1.1.0) 19 | cocoapods (1.11.2) 20 | addressable (~> 2.8) 21 | claide (>= 1.0.2, < 2.0) 22 | cocoapods-core (= 1.11.2) 23 | cocoapods-deintegrate (>= 1.0.3, < 2.0) 24 | cocoapods-downloader (>= 1.4.0, < 2.0) 25 | cocoapods-plugins (>= 1.0.0, < 2.0) 26 | cocoapods-search (>= 1.0.0, < 2.0) 27 | cocoapods-trunk (>= 1.4.0, < 2.0) 28 | cocoapods-try (>= 1.1.0, < 2.0) 29 | colored2 (~> 3.1) 30 | escape (~> 0.0.4) 31 | fourflusher (>= 2.3.0, < 3.0) 32 | gh_inspector (~> 1.0) 33 | molinillo (~> 0.8.0) 34 | nap (~> 1.0) 35 | ruby-macho (>= 1.0, < 3.0) 36 | xcodeproj (>= 1.21.0, < 2.0) 37 | cocoapods-core (1.11.2) 38 | activesupport (>= 5.0, < 7) 39 | addressable (~> 2.8) 40 | algoliasearch (~> 1.0) 41 | concurrent-ruby (~> 1.1) 42 | fuzzy_match (~> 2.0.4) 43 | nap (~> 1.0) 44 | netrc (~> 0.11) 45 | public_suffix (~> 4.0) 46 | typhoeus (~> 1.0) 47 | cocoapods-deintegrate (1.0.5) 48 | cocoapods-downloader (1.5.1) 49 | cocoapods-plugins (1.0.0) 50 | nap 51 | cocoapods-search (1.0.1) 52 | cocoapods-trunk (1.6.0) 53 | nap (>= 0.8, < 2.0) 54 | netrc (~> 0.11) 55 | cocoapods-try (1.2.0) 56 | colored2 (3.1.2) 57 | concurrent-ruby (1.1.9) 58 | escape (0.0.4) 59 | ethon (0.15.0) 60 | ffi (>= 1.15.0) 61 | ffi (1.15.5) 62 | fourflusher (2.3.1) 63 | fuzzy_match (2.0.4) 64 | gh_inspector (1.1.3) 65 | httpclient (2.8.3) 66 | i18n (1.8.11) 67 | concurrent-ruby (~> 1.0) 68 | json (2.6.1) 69 | minitest (5.15.0) 70 | molinillo (0.8.0) 71 | nanaimo (0.3.0) 72 | nap (1.1.0) 73 | netrc (0.11.0) 74 | public_suffix (4.0.6) 75 | rexml (3.2.5) 76 | ruby-macho (2.5.1) 77 | typhoeus (1.4.0) 78 | ethon (>= 0.9.0) 79 | tzinfo (2.0.4) 80 | concurrent-ruby (~> 1.0) 81 | xcodeproj (1.21.0) 82 | CFPropertyList (>= 2.3.3, < 4.0) 83 | atomos (~> 0.1.3) 84 | claide (>= 1.0.2, < 2.0) 85 | colored2 (~> 3.1) 86 | nanaimo (~> 0.3.0) 87 | rexml (~> 3.2.4) 88 | zeitwerk (2.5.3) 89 | 90 | PLATFORMS 91 | ruby 92 | 93 | DEPENDENCIES 94 | cocoapods (~> 1.11, >= 1.11.2) 95 | 96 | RUBY VERSION 97 | ruby 2.7.4p191 98 | 99 | BUNDLED WITH 100 | 2.2.27 101 | -------------------------------------------------------------------------------- /example/NavigationComponent.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable comma-dangle */ 2 | import React from 'react'; 3 | import {StyleSheet, View} from 'react-native'; 4 | import MapboxNavigation from '@homee/react-native-mapbox-navigation'; 5 | 6 | const Navigation = props => { 7 | const {origin, destination} = props; 8 | 9 | return ( 10 | 11 | 12 | { 20 | console.log('onLocationChange', event.nativeEvent); 21 | }} 22 | onRouteProgressChange={event => { 23 | console.log('onRouteProgressChange', event.nativeEvent); 24 | }} 25 | onError={event => { 26 | const {message} = event.nativeEvent; 27 | // eslint-disable-next-line no-alert 28 | alert(message); 29 | }} 30 | onArrive={() => { 31 | // eslint-disable-next-line no-alert 32 | alert('You have reached your destination'); 33 | }} 34 | onCancelNavigation={event => { 35 | alert('Cancelled navigation event'); 36 | }} 37 | /> 38 | 39 | 40 | ); 41 | }; 42 | 43 | const styles = StyleSheet.create({ 44 | container: { 45 | flex: 1, 46 | display: 'flex', 47 | flexDirection: 'column', 48 | justifyContent: 'space-between', 49 | height: '100%', 50 | }, 51 | mapContainer: { 52 | flex: 1, 53 | }, 54 | }); 55 | 56 | export default Navigation; 57 | -------------------------------------------------------------------------------- /example/__tests__/App-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @format 3 | */ 4 | 5 | import 'react-native'; 6 | import React from 'react'; 7 | import App from '../App'; 8 | 9 | // Note: test renderer must be required after react-native. 10 | import renderer from 'react-test-renderer'; 11 | 12 | it('renders correctly', () => { 13 | renderer.create(); 14 | }); 15 | -------------------------------------------------------------------------------- /example/_bundle/config: -------------------------------------------------------------------------------- 1 | BUNDLE_PATH: "vendor/bundle" 2 | BUNDLE_FORCE_RUBY_PLATFORM: 1 3 | -------------------------------------------------------------------------------- /example/_ruby-version: -------------------------------------------------------------------------------- 1 | 2.7.4 2 | -------------------------------------------------------------------------------- /example/android/app/_BUCK: -------------------------------------------------------------------------------- 1 | # To learn about Buck see [Docs](https://buckbuild.com/). 2 | # To run your application with Buck: 3 | # - install Buck 4 | # - `npm start` - to start the packager 5 | # - `cd android` 6 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` 7 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck 8 | # - `buck install -r android/app` - compile, install and run application 9 | # 10 | 11 | load(":build_defs.bzl", "create_aar_targets", "create_jar_targets") 12 | 13 | lib_deps = [] 14 | 15 | create_aar_targets(glob(["libs/*.aar"])) 16 | 17 | create_jar_targets(glob(["libs/*.jar"])) 18 | 19 | android_library( 20 | name = "all-libs", 21 | exported_deps = lib_deps, 22 | ) 23 | 24 | android_library( 25 | name = "app-code", 26 | srcs = glob([ 27 | "src/main/java/**/*.java", 28 | ]), 29 | deps = [ 30 | ":all-libs", 31 | ":build_config", 32 | ":res", 33 | ], 34 | ) 35 | 36 | android_build_config( 37 | name = "build_config", 38 | package = "com.basicapp", 39 | ) 40 | 41 | android_resource( 42 | name = "res", 43 | package = "com.basicapp", 44 | res = "src/main/res", 45 | ) 46 | 47 | android_binary( 48 | name = "app", 49 | keystore = "//android/keystores:debug", 50 | manifest = "src/main/AndroidManifest.xml", 51 | package_type = "debug", 52 | deps = [ 53 | ":app-code", 54 | ], 55 | ) 56 | -------------------------------------------------------------------------------- /example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "com.android.application" 2 | 3 | import com.android.build.OutputFile 4 | 5 | /** 6 | * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets 7 | * and bundleReleaseJsAndAssets). 8 | * These basically call `react-native bundle` with the correct arguments during the Android build 9 | * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the 10 | * bundle directly from the development server. Below you can see all the possible configurations 11 | * and their defaults. If you decide to add a configuration block, make sure to add it before the 12 | * `apply from: "../../node_modules/react-native/react.gradle"` line. 13 | * 14 | * project.ext.react = [ 15 | * // the name of the generated asset file containing your JS bundle 16 | * bundleAssetName: "index.android.bundle", 17 | * 18 | * // the entry file for bundle generation. If none specified and 19 | * // "index.android.js" exists, it will be used. Otherwise "index.js" is 20 | * // default. Can be overridden with ENTRY_FILE environment variable. 21 | * entryFile: "index.android.js", 22 | * 23 | * // https://reactnative.dev/docs/performance#enable-the-ram-format 24 | * bundleCommand: "ram-bundle", 25 | * 26 | * // whether to bundle JS and assets in debug mode 27 | * bundleInDebug: false, 28 | * 29 | * // whether to bundle JS and assets in release mode 30 | * bundleInRelease: true, 31 | * 32 | * // whether to bundle JS and assets in another build variant (if configured). 33 | * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants 34 | * // The configuration property can be in the following formats 35 | * // 'bundleIn${productFlavor}${buildType}' 36 | * // 'bundleIn${buildType}' 37 | * // bundleInFreeDebug: true, 38 | * // bundleInPaidRelease: true, 39 | * // bundleInBeta: true, 40 | * 41 | * // whether to disable dev mode in custom build variants (by default only disabled in release) 42 | * // for example: to disable dev mode in the staging build type (if configured) 43 | * devDisabledInStaging: true, 44 | * // The configuration property can be in the following formats 45 | * // 'devDisabledIn${productFlavor}${buildType}' 46 | * // 'devDisabledIn${buildType}' 47 | * 48 | * // the root of your project, i.e. where "package.json" lives 49 | * root: "../../", 50 | * 51 | * // where to put the JS bundle asset in debug mode 52 | * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", 53 | * 54 | * // where to put the JS bundle asset in release mode 55 | * jsBundleDirRelease: "$buildDir/intermediates/assets/release", 56 | * 57 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 58 | * // require('./image.png')), in debug mode 59 | * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", 60 | * 61 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 62 | * // require('./image.png')), in release mode 63 | * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", 64 | * 65 | * // by default the gradle tasks are skipped if none of the JS files or assets change; this means 66 | * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to 67 | * // date; if you have any other folders that you want to ignore for performance reasons (gradle 68 | * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ 69 | * // for example, you might want to remove it from here. 70 | * inputExcludes: ["android/**", "ios/**"], 71 | * 72 | * // override which node gets called and with what additional arguments 73 | * nodeExecutableAndArgs: ["node"], 74 | * 75 | * // supply additional arguments to the packager 76 | * extraPackagerArgs: [] 77 | * ] 78 | */ 79 | 80 | project.ext.react = [ 81 | enableHermes: false, // clean and rebuild if changing 82 | ] 83 | 84 | apply from: "../../node_modules/react-native/react.gradle" 85 | 86 | /** 87 | * Set this to true to create two separate APKs instead of one: 88 | * - An APK that only works on ARM devices 89 | * - An APK that only works on x86 devices 90 | * The advantage is the size of the APK is reduced by about 4MB. 91 | * Upload all the APKs to the Play Store and people will download 92 | * the correct one based on the CPU architecture of their device. 93 | */ 94 | def enableSeparateBuildPerCPUArchitecture = false 95 | 96 | /** 97 | * Run Proguard to shrink the Java bytecode in release builds. 98 | */ 99 | def enableProguardInReleaseBuilds = false 100 | 101 | /** 102 | * The preferred build flavor of JavaScriptCore. 103 | * 104 | * For example, to use the international variant, you can use: 105 | * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` 106 | * 107 | * The international variant includes ICU i18n library and necessary data 108 | * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that 109 | * give correct results when using with locales other than en-US. Note that 110 | * this variant is about 6MiB larger per architecture than default. 111 | */ 112 | def jscFlavor = 'org.webkit:android-jsc:+' 113 | 114 | /** 115 | * Whether to enable the Hermes VM. 116 | * 117 | * This should be set on project.ext.react and that value will be read here. If it is not set 118 | * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode 119 | * and the benefits of using Hermes will therefore be sharply reduced. 120 | */ 121 | def enableHermes = project.ext.react.get("enableHermes", false); 122 | 123 | /** 124 | * Architectures to build native code for in debug. 125 | */ 126 | def nativeArchitectures = project.getProperties().get("reactNativeDebugArchitectures") 127 | 128 | android { 129 | ndkVersion rootProject.ext.ndkVersion 130 | 131 | compileSdkVersion rootProject.ext.compileSdkVersion 132 | 133 | defaultConfig { 134 | applicationId "com.basicapp" 135 | minSdkVersion rootProject.ext.minSdkVersion 136 | targetSdkVersion rootProject.ext.targetSdkVersion 137 | versionCode 1 138 | versionName "1.0" 139 | } 140 | splits { 141 | abi { 142 | reset() 143 | enable enableSeparateBuildPerCPUArchitecture 144 | universalApk false // If true, also generate a universal APK 145 | include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" 146 | } 147 | } 148 | packagingOptions { 149 | pickFirst '**/*.so' 150 | } 151 | signingConfigs { 152 | debug { 153 | storeFile file('debug.keystore') 154 | storePassword 'android' 155 | keyAlias 'androiddebugkey' 156 | keyPassword 'android' 157 | } 158 | } 159 | buildTypes { 160 | debug { 161 | signingConfig signingConfigs.debug 162 | if (nativeArchitectures) { 163 | ndk { 164 | abiFilters nativeArchitectures.split(',') 165 | } 166 | } 167 | } 168 | release { 169 | // Caution! In production, you need to generate your own keystore file. 170 | // see https://reactnative.dev/docs/signed-apk-android. 171 | signingConfig signingConfigs.debug 172 | minifyEnabled enableProguardInReleaseBuilds 173 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 174 | } 175 | } 176 | 177 | // applicationVariants are e.g. debug, release 178 | applicationVariants.all { variant -> 179 | variant.outputs.each { output -> 180 | // For each separate APK per architecture, set a unique version code as described here: 181 | // https://developer.android.com/studio/build/configure-apk-splits.html 182 | // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc. 183 | def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] 184 | def abi = output.getFilter(OutputFile.ABI) 185 | if (abi != null) { // null for the universal-debug, universal-release variants 186 | output.versionCodeOverride = 187 | defaultConfig.versionCode * 1000 + versionCodes.get(abi) 188 | } 189 | 190 | } 191 | } 192 | } 193 | 194 | dependencies { 195 | implementation fileTree(dir: "libs", include: ["*.jar"]) 196 | //noinspection GradleDynamicVersion 197 | implementation "com.facebook.react:react-native:+" // From node_modules 198 | 199 | implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" 200 | 201 | debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") { 202 | exclude group:'com.facebook.fbjni' 203 | } 204 | 205 | debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { 206 | exclude group:'com.facebook.flipper' 207 | exclude group:'com.squareup.okhttp3', module:'okhttp' 208 | } 209 | 210 | debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") { 211 | exclude group:'com.facebook.flipper' 212 | } 213 | 214 | if (enableHermes) { 215 | def hermesPath = "../../node_modules/hermes-engine/android/"; 216 | debugImplementation files(hermesPath + "hermes-debug.aar") 217 | releaseImplementation files(hermesPath + "hermes-release.aar") 218 | } else { 219 | implementation jscFlavor 220 | } 221 | 222 | implementation project(':mapboxnavigation') 223 | } 224 | 225 | // Run this once to be able to run the application with BUCK 226 | // puts all compile dependencies into folder libs for BUCK to use 227 | task copyDownloadableDepsToLibs(type: Copy) { 228 | from configurations.implementation 229 | into 'libs' 230 | } 231 | 232 | apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) 233 | -------------------------------------------------------------------------------- /example/android/app/build_defs.bzl: -------------------------------------------------------------------------------- 1 | """Helper definitions to glob .aar and .jar targets""" 2 | 3 | def create_aar_targets(aarfiles): 4 | for aarfile in aarfiles: 5 | name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")] 6 | lib_deps.append(":" + name) 7 | android_prebuilt_aar( 8 | name = name, 9 | aar = aarfile, 10 | ) 11 | 12 | def create_jar_targets(jarfiles): 13 | for jarfile in jarfiles: 14 | name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")] 15 | lib_deps.append(":" + name) 16 | prebuilt_jar( 17 | name = name, 18 | binary_jar = jarfile, 19 | ) 20 | -------------------------------------------------------------------------------- /example/android/app/debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/homeeondemand/react-native-mapbox-navigation/d0f729ce8665020145be7024c50bc3867e21001d/example/android/app/debug.keystore -------------------------------------------------------------------------------- /example/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /example/android/app/src/debug/java/com/basicapp/ReactNativeFlipper.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * 4 | *

This source code is licensed under the MIT license found in the LICENSE file in the root 5 | * directory of this source tree. 6 | */ 7 | package com.basicapp; 8 | 9 | import android.content.Context; 10 | import com.facebook.flipper.android.AndroidFlipperClient; 11 | import com.facebook.flipper.android.utils.FlipperUtils; 12 | import com.facebook.flipper.core.FlipperClient; 13 | import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin; 14 | import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin; 15 | import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin; 16 | import com.facebook.flipper.plugins.inspector.DescriptorMapping; 17 | import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin; 18 | import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor; 19 | import com.facebook.flipper.plugins.network.NetworkFlipperPlugin; 20 | import com.facebook.flipper.plugins.react.ReactFlipperPlugin; 21 | import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin; 22 | import com.facebook.react.ReactInstanceManager; 23 | import com.facebook.react.bridge.ReactContext; 24 | import com.facebook.react.modules.network.NetworkingModule; 25 | import okhttp3.OkHttpClient; 26 | 27 | public class ReactNativeFlipper { 28 | public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { 29 | if (FlipperUtils.shouldEnableFlipper(context)) { 30 | final FlipperClient client = AndroidFlipperClient.getInstance(context); 31 | 32 | client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults())); 33 | client.addPlugin(new ReactFlipperPlugin()); 34 | client.addPlugin(new DatabasesFlipperPlugin(context)); 35 | client.addPlugin(new SharedPreferencesFlipperPlugin(context)); 36 | client.addPlugin(CrashReporterPlugin.getInstance()); 37 | 38 | NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin(); 39 | NetworkingModule.setCustomClientBuilder( 40 | new NetworkingModule.CustomClientBuilder() { 41 | @Override 42 | public void apply(OkHttpClient.Builder builder) { 43 | builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin)); 44 | } 45 | }); 46 | client.addPlugin(networkFlipperPlugin); 47 | client.start(); 48 | 49 | // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized 50 | // Hence we run if after all native modules have been initialized 51 | ReactContext reactContext = reactInstanceManager.getCurrentReactContext(); 52 | if (reactContext == null) { 53 | reactInstanceManager.addReactInstanceEventListener( 54 | new ReactInstanceManager.ReactInstanceEventListener() { 55 | @Override 56 | public void onReactContextInitialized(ReactContext reactContext) { 57 | reactInstanceManager.removeReactInstanceEventListener(this); 58 | reactContext.runOnNativeModulesQueueThread( 59 | new Runnable() { 60 | @Override 61 | public void run() { 62 | client.addPlugin(new FrescoFlipperPlugin()); 63 | } 64 | }); 65 | } 66 | }); 67 | } else { 68 | client.addPlugin(new FrescoFlipperPlugin()); 69 | } 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 16 | 22 | 23 | 24 | 25 | 26 | 27 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/basicapp/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.basicapp; 2 | 3 | import com.facebook.react.ReactActivity; 4 | 5 | public class MainActivity extends ReactActivity { 6 | 7 | /** 8 | * Returns the name of the main component registered from JavaScript. This is used to schedule 9 | * rendering of the component. 10 | */ 11 | @Override 12 | protected String getMainComponentName() { 13 | return "BasicApp"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/basicapp/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.basicapp; 2 | 3 | import android.app.Application; 4 | import android.content.Context; 5 | import com.facebook.react.PackageList; 6 | import com.facebook.react.ReactApplication; 7 | import com.facebook.react.ReactInstanceManager; 8 | import com.facebook.react.ReactNativeHost; 9 | import com.facebook.react.ReactPackage; 10 | import com.facebook.soloader.SoLoader; 11 | import java.lang.reflect.InvocationTargetException; 12 | import java.util.List; 13 | import com.homee.mapboxnavigation.MapboxNavigationPackage; 14 | 15 | public class MainApplication extends Application implements ReactApplication { 16 | 17 | private final ReactNativeHost mReactNativeHost = 18 | new ReactNativeHost(this) { 19 | @Override 20 | public boolean getUseDeveloperSupport() { 21 | return BuildConfig.DEBUG; 22 | } 23 | 24 | @Override 25 | protected List getPackages() { 26 | @SuppressWarnings("UnnecessaryLocalVariable") 27 | List packages = new PackageList(this).getPackages(); 28 | // Packages that cannot be autolinked yet can be added manually here, for example: 29 | packages.add(new MapboxNavigationPackage()); 30 | return packages; 31 | } 32 | 33 | @Override 34 | protected String getJSMainModuleName() { 35 | return "index"; 36 | } 37 | }; 38 | 39 | @Override 40 | public ReactNativeHost getReactNativeHost() { 41 | return mReactNativeHost; 42 | } 43 | 44 | @Override 45 | public void onCreate() { 46 | super.onCreate(); 47 | SoLoader.init(this, /* native exopackage */ false); 48 | initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); 49 | } 50 | 51 | /** 52 | * Loads Flipper in React Native templates. Call this in the onCreate method with something like 53 | * initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); 54 | * 55 | * @param context 56 | * @param reactInstanceManager 57 | */ 58 | private static void initializeFlipper( 59 | Context context, ReactInstanceManager reactInstanceManager) { 60 | if (BuildConfig.DEBUG) { 61 | try { 62 | /* 63 | We use reflection here to pick up the class that initializes Flipper, 64 | since Flipper library is not available in release mode 65 | */ 66 | Class aClass = Class.forName("com.basicapp.ReactNativeFlipper"); 67 | aClass 68 | .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class) 69 | .invoke(null, context, reactInstanceManager); 70 | } catch (ClassNotFoundException e) { 71 | e.printStackTrace(); 72 | } catch (NoSuchMethodException e) { 73 | e.printStackTrace(); 74 | } catch (IllegalAccessException e) { 75 | e.printStackTrace(); 76 | } catch (InvocationTargetException e) { 77 | e.printStackTrace(); 78 | } 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/rn_edit_text_material.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 21 | 22 | 23 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/homeeondemand/react-native-mapbox-navigation/d0f729ce8665020145be7024c50bc3867e21001d/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/homeeondemand/react-native-mapbox-navigation/d0f729ce8665020145be7024c50bc3867e21001d/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/homeeondemand/react-native-mapbox-navigation/d0f729ce8665020145be7024c50bc3867e21001d/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/homeeondemand/react-native-mapbox-navigation/d0f729ce8665020145be7024c50bc3867e21001d/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/homeeondemand/react-native-mapbox-navigation/d0f729ce8665020145be7024c50bc3867e21001d/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/homeeondemand/react-native-mapbox-navigation/d0f729ce8665020145be7024c50bc3867e21001d/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/homeeondemand/react-native-mapbox-navigation/d0f729ce8665020145be7024c50bc3867e21001d/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/homeeondemand/react-native-mapbox-navigation/d0f729ce8665020145be7024c50bc3867e21001d/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/homeeondemand/react-native-mapbox-navigation/d0f729ce8665020145be7024c50bc3867e21001d/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/homeeondemand/react-native-mapbox-navigation/d0f729ce8665020145be7024c50bc3867e21001d/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | BasicApp 3 | 4 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext { 5 | buildToolsVersion = "30.0.2" 6 | minSdkVersion = 21 7 | compileSdkVersion = 31 8 | targetSdkVersion = 31 9 | ndkVersion = "21.4.7075529" 10 | } 11 | repositories { 12 | google() 13 | mavenCentral() 14 | } 15 | dependencies { 16 | classpath("com.android.tools.build:gradle:4.2.2") 17 | // NOTE: Do not place your application dependencies here; they belong 18 | // in the individual module build.gradle files 19 | } 20 | } 21 | 22 | allprojects { 23 | repositories { 24 | maven { 25 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 26 | url("$rootDir/../node_modules/react-native/android") 27 | } 28 | maven { 29 | // Android JSC is installed from npm 30 | url("$rootDir/../node_modules/jsc-android/dist") 31 | } 32 | mavenCentral { 33 | // We don't want to fetch react-native from Maven Central as there are 34 | // older versions over there. 35 | content { 36 | excludeGroup "com.facebook.react" 37 | } 38 | } 39 | google() 40 | maven { url 'https://www.jitpack.io' } 41 | maven { 42 | url 'https://api.mapbox.com/downloads/v2/releases/maven' 43 | authentication { 44 | basic(BasicAuthentication) 45 | } 46 | credentials { 47 | // Do not change the username below. 48 | // This should always be `mapbox` (not your username). 49 | username = "mapbox" 50 | // Use the secret token you stored in gradle.properties as the password 51 | password = project.properties['MAPBOX_DOWNLOADS_TOKEN'] ?: "" 52 | } 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx1024m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | # AndroidX package structure to make it clearer which packages are bundled with the 21 | # Android operating system, and which are packaged with your app's APK 22 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 23 | android.useAndroidX=true 24 | # Automatically convert third-party libraries to use AndroidX 25 | android.enableJetifier=true 26 | 27 | # Version of flipper SDK to use with React Native 28 | FLIPPER_VERSION=0.99.0 29 | 30 | MAPBOX_DOWNLOADS_TOKEN= sk.eyJ1Ijoiam9yZ2VxdWV2ZWRveCIsImEiOiJja29ib3oycWIyN2Z3MnZvbmc0eGttOTI0In0.Wsd8kBSIh6RkhivVUWm3cw 31 | 32 | org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=4096m -XX:+HeapDumpOnOutOfMemoryError 33 | org.gradle.daemon=true 34 | org.gradle.parallel=true 35 | org.gradle.configureondemand=true. -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/homeeondemand/react-native-mapbox-navigation/d0f729ce8665020145be7024c50bc3867e21001d/example/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /example/android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /example/android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'BasicApp' 2 | apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) 3 | include ':app' 4 | 5 | include ':mapboxnavigation' 6 | project(':mapboxnavigation').projectDir = new File(rootProject.projectDir, '../../android') -------------------------------------------------------------------------------- /example/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "BasicApp", 3 | "displayName": "BasicApp" 4 | } -------------------------------------------------------------------------------- /example/babel.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Metro configuration for React Native 3 | * https://github.com/facebook/react-native 4 | * 5 | * @format 6 | */ 7 | 8 | const path = require('path'); 9 | const pak = require('../package.json'); 10 | 11 | module.exports = { 12 | presets: ['module:metro-react-native-babel-preset'], 13 | plugins: [ 14 | [ 15 | 'module-resolver', 16 | { 17 | extensions: ['.tsx', '.ts', '.js', '.json'], 18 | alias: { 19 | [pak.name]: path.join(__dirname, '..', pak.source), 20 | }, 21 | }, 22 | ], 23 | ], 24 | }; 25 | -------------------------------------------------------------------------------- /example/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @format 3 | */ 4 | 5 | import {AppRegistry} from 'react-native'; 6 | import App from './App'; 7 | import {name as appName} from './app.json'; 8 | 9 | AppRegistry.registerComponent(appName, () => App); 10 | -------------------------------------------------------------------------------- /example/ios/BasicApp-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | 5 | -------------------------------------------------------------------------------- /example/ios/BasicApp.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 54; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 00E356F31AD99517003FC87E /* BasicAppTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* BasicAppTests.m */; }; 11 | 13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; }; 12 | 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; }; 13 | 13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; 14 | 2E2D5B56C32B148E16436AAD /* libPods-BasicApp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = AA5E5B1A36C1EFD40B9FE59A /* libPods-BasicApp.a */; }; 15 | 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; }; 16 | CF01C0932798908E009932D0 /* BridgeHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = CF01C0922798908E009932D0 /* BridgeHeader.swift */; }; 17 | E1B8FFE0CC904B260DFE309F /* libPods-BasicApp-BasicAppTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D7DB328487C5F842F76563DF /* libPods-BasicApp-BasicAppTests.a */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXContainerItemProxy section */ 21 | 00E356F41AD99517003FC87E /* PBXContainerItemProxy */ = { 22 | isa = PBXContainerItemProxy; 23 | containerPortal = 83CBB9F71A601CBA00E9B192 /* Project object */; 24 | proxyType = 1; 25 | remoteGlobalIDString = 13B07F861A680F5B00A75B9A; 26 | remoteInfo = BasicApp; 27 | }; 28 | /* End PBXContainerItemProxy section */ 29 | 30 | /* Begin PBXFileReference section */ 31 | 00E356EE1AD99517003FC87E /* BasicAppTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = BasicAppTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 32 | 00E356F11AD99517003FC87E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 33 | 00E356F21AD99517003FC87E /* BasicAppTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BasicAppTests.m; sourceTree = ""; }; 34 | 13B07F961A680F5B00A75B9A /* BasicApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BasicApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; 35 | 13B07FAF1A68108700A75B9A /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = BasicApp/AppDelegate.h; sourceTree = ""; }; 36 | 13B07FB01A68108700A75B9A /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = BasicApp/AppDelegate.m; sourceTree = ""; }; 37 | 13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = BasicApp/Images.xcassets; sourceTree = ""; }; 38 | 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = BasicApp/Info.plist; sourceTree = ""; }; 39 | 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = BasicApp/main.m; sourceTree = ""; }; 40 | 30B618F11CA9F61F4A2BCC18 /* Pods-BasicApp-BasicAppTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BasicApp-BasicAppTests.release.xcconfig"; path = "Target Support Files/Pods-BasicApp-BasicAppTests/Pods-BasicApp-BasicAppTests.release.xcconfig"; sourceTree = ""; }; 41 | 3A03A3D0AA35DD00F816F6FD /* Pods-BasicApp-BasicAppTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BasicApp-BasicAppTests.debug.xcconfig"; path = "Target Support Files/Pods-BasicApp-BasicAppTests/Pods-BasicApp-BasicAppTests.debug.xcconfig"; sourceTree = ""; }; 42 | 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = BasicApp/LaunchScreen.storyboard; sourceTree = ""; }; 43 | A397D62B2A1AB4DE08565ACB /* Pods-BasicApp.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BasicApp.release.xcconfig"; path = "Target Support Files/Pods-BasicApp/Pods-BasicApp.release.xcconfig"; sourceTree = ""; }; 44 | AA5E5B1A36C1EFD40B9FE59A /* libPods-BasicApp.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-BasicApp.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 45 | CF01C0912798908E009932D0 /* BasicApp-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "BasicApp-Bridging-Header.h"; sourceTree = ""; }; 46 | CF01C0922798908E009932D0 /* BridgeHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BridgeHeader.swift; sourceTree = ""; }; 47 | D7DB328487C5F842F76563DF /* libPods-BasicApp-BasicAppTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-BasicApp-BasicAppTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 48 | DBAE69E2F4FE155BDFBF583F /* Pods-BasicApp.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BasicApp.debug.xcconfig"; path = "Target Support Files/Pods-BasicApp/Pods-BasicApp.debug.xcconfig"; sourceTree = ""; }; 49 | ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; }; 50 | /* End PBXFileReference section */ 51 | 52 | /* Begin PBXFrameworksBuildPhase section */ 53 | 00E356EB1AD99517003FC87E /* Frameworks */ = { 54 | isa = PBXFrameworksBuildPhase; 55 | buildActionMask = 2147483647; 56 | files = ( 57 | E1B8FFE0CC904B260DFE309F /* libPods-BasicApp-BasicAppTests.a in Frameworks */, 58 | ); 59 | runOnlyForDeploymentPostprocessing = 0; 60 | }; 61 | 13B07F8C1A680F5B00A75B9A /* Frameworks */ = { 62 | isa = PBXFrameworksBuildPhase; 63 | buildActionMask = 2147483647; 64 | files = ( 65 | 2E2D5B56C32B148E16436AAD /* libPods-BasicApp.a in Frameworks */, 66 | ); 67 | runOnlyForDeploymentPostprocessing = 0; 68 | }; 69 | /* End PBXFrameworksBuildPhase section */ 70 | 71 | /* Begin PBXGroup section */ 72 | 00E356EF1AD99517003FC87E /* BasicAppTests */ = { 73 | isa = PBXGroup; 74 | children = ( 75 | 00E356F21AD99517003FC87E /* BasicAppTests.m */, 76 | 00E356F01AD99517003FC87E /* Supporting Files */, 77 | ); 78 | path = BasicAppTests; 79 | sourceTree = ""; 80 | }; 81 | 00E356F01AD99517003FC87E /* Supporting Files */ = { 82 | isa = PBXGroup; 83 | children = ( 84 | 00E356F11AD99517003FC87E /* Info.plist */, 85 | ); 86 | name = "Supporting Files"; 87 | sourceTree = ""; 88 | }; 89 | 13B07FAE1A68108700A75B9A /* BasicApp */ = { 90 | isa = PBXGroup; 91 | children = ( 92 | CF01C0922798908E009932D0 /* BridgeHeader.swift */, 93 | 13B07FAF1A68108700A75B9A /* AppDelegate.h */, 94 | 13B07FB01A68108700A75B9A /* AppDelegate.m */, 95 | 13B07FB51A68108700A75B9A /* Images.xcassets */, 96 | 13B07FB61A68108700A75B9A /* Info.plist */, 97 | 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */, 98 | 13B07FB71A68108700A75B9A /* main.m */, 99 | CF01C0912798908E009932D0 /* BasicApp-Bridging-Header.h */, 100 | ); 101 | name = BasicApp; 102 | sourceTree = ""; 103 | }; 104 | 2D16E6871FA4F8E400B85C8A /* Frameworks */ = { 105 | isa = PBXGroup; 106 | children = ( 107 | ED297162215061F000B7C4FE /* JavaScriptCore.framework */, 108 | AA5E5B1A36C1EFD40B9FE59A /* libPods-BasicApp.a */, 109 | D7DB328487C5F842F76563DF /* libPods-BasicApp-BasicAppTests.a */, 110 | ); 111 | name = Frameworks; 112 | sourceTree = ""; 113 | }; 114 | 5CE79C194613E77BC4EA413A /* Pods */ = { 115 | isa = PBXGroup; 116 | children = ( 117 | DBAE69E2F4FE155BDFBF583F /* Pods-BasicApp.debug.xcconfig */, 118 | A397D62B2A1AB4DE08565ACB /* Pods-BasicApp.release.xcconfig */, 119 | 3A03A3D0AA35DD00F816F6FD /* Pods-BasicApp-BasicAppTests.debug.xcconfig */, 120 | 30B618F11CA9F61F4A2BCC18 /* Pods-BasicApp-BasicAppTests.release.xcconfig */, 121 | ); 122 | path = Pods; 123 | sourceTree = ""; 124 | }; 125 | 832341AE1AAA6A7D00B99B32 /* Libraries */ = { 126 | isa = PBXGroup; 127 | children = ( 128 | ); 129 | name = Libraries; 130 | sourceTree = ""; 131 | }; 132 | 83CBB9F61A601CBA00E9B192 = { 133 | isa = PBXGroup; 134 | children = ( 135 | 13B07FAE1A68108700A75B9A /* BasicApp */, 136 | 832341AE1AAA6A7D00B99B32 /* Libraries */, 137 | 00E356EF1AD99517003FC87E /* BasicAppTests */, 138 | 83CBBA001A601CBA00E9B192 /* Products */, 139 | 2D16E6871FA4F8E400B85C8A /* Frameworks */, 140 | 5CE79C194613E77BC4EA413A /* Pods */, 141 | ); 142 | indentWidth = 2; 143 | sourceTree = ""; 144 | tabWidth = 2; 145 | usesTabs = 0; 146 | }; 147 | 83CBBA001A601CBA00E9B192 /* Products */ = { 148 | isa = PBXGroup; 149 | children = ( 150 | 13B07F961A680F5B00A75B9A /* BasicApp.app */, 151 | 00E356EE1AD99517003FC87E /* BasicAppTests.xctest */, 152 | ); 153 | name = Products; 154 | sourceTree = ""; 155 | }; 156 | /* End PBXGroup section */ 157 | 158 | /* Begin PBXNativeTarget section */ 159 | 00E356ED1AD99517003FC87E /* BasicAppTests */ = { 160 | isa = PBXNativeTarget; 161 | buildConfigurationList = 00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "BasicAppTests" */; 162 | buildPhases = ( 163 | 8B7EE21C792A719595021F29 /* [CP] Check Pods Manifest.lock */, 164 | 00E356EA1AD99517003FC87E /* Sources */, 165 | 00E356EB1AD99517003FC87E /* Frameworks */, 166 | 00E356EC1AD99517003FC87E /* Resources */, 167 | 843EDEA405B56501C429ED84 /* [CP] Embed Pods Frameworks */, 168 | 84065F8AF2681FA8400F0F0C /* [CP] Copy Pods Resources */, 169 | ); 170 | buildRules = ( 171 | ); 172 | dependencies = ( 173 | 00E356F51AD99517003FC87E /* PBXTargetDependency */, 174 | ); 175 | name = BasicAppTests; 176 | productName = BasicAppTests; 177 | productReference = 00E356EE1AD99517003FC87E /* BasicAppTests.xctest */; 178 | productType = "com.apple.product-type.bundle.unit-test"; 179 | }; 180 | 13B07F861A680F5B00A75B9A /* BasicApp */ = { 181 | isa = PBXNativeTarget; 182 | buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "BasicApp" */; 183 | buildPhases = ( 184 | 9143125BD2F166E7D3FCEBD8 /* [CP] Check Pods Manifest.lock */, 185 | FD10A7F022414F080027D42C /* Start Packager */, 186 | 13B07F871A680F5B00A75B9A /* Sources */, 187 | 13B07F8C1A680F5B00A75B9A /* Frameworks */, 188 | 13B07F8E1A680F5B00A75B9A /* Resources */, 189 | 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */, 190 | 238C272505EC18894F147C47 /* [CP] Embed Pods Frameworks */, 191 | 2BC7CE56A6A153AA9DF05333 /* [CP] Copy Pods Resources */, 192 | ); 193 | buildRules = ( 194 | ); 195 | dependencies = ( 196 | ); 197 | name = BasicApp; 198 | productName = BasicApp; 199 | productReference = 13B07F961A680F5B00A75B9A /* BasicApp.app */; 200 | productType = "com.apple.product-type.application"; 201 | }; 202 | /* End PBXNativeTarget section */ 203 | 204 | /* Begin PBXProject section */ 205 | 83CBB9F71A601CBA00E9B192 /* Project object */ = { 206 | isa = PBXProject; 207 | attributes = { 208 | LastUpgradeCheck = 1210; 209 | TargetAttributes = { 210 | 00E356ED1AD99517003FC87E = { 211 | CreatedOnToolsVersion = 6.2; 212 | TestTargetID = 13B07F861A680F5B00A75B9A; 213 | }; 214 | 13B07F861A680F5B00A75B9A = { 215 | LastSwiftMigration = 1250; 216 | }; 217 | }; 218 | }; 219 | buildConfigurationList = 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "BasicApp" */; 220 | compatibilityVersion = "Xcode 12.0"; 221 | developmentRegion = en; 222 | hasScannedForEncodings = 0; 223 | knownRegions = ( 224 | en, 225 | Base, 226 | ); 227 | mainGroup = 83CBB9F61A601CBA00E9B192; 228 | productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */; 229 | projectDirPath = ""; 230 | projectRoot = ""; 231 | targets = ( 232 | 13B07F861A680F5B00A75B9A /* BasicApp */, 233 | 00E356ED1AD99517003FC87E /* BasicAppTests */, 234 | ); 235 | }; 236 | /* End PBXProject section */ 237 | 238 | /* Begin PBXResourcesBuildPhase section */ 239 | 00E356EC1AD99517003FC87E /* Resources */ = { 240 | isa = PBXResourcesBuildPhase; 241 | buildActionMask = 2147483647; 242 | files = ( 243 | ); 244 | runOnlyForDeploymentPostprocessing = 0; 245 | }; 246 | 13B07F8E1A680F5B00A75B9A /* Resources */ = { 247 | isa = PBXResourcesBuildPhase; 248 | buildActionMask = 2147483647; 249 | files = ( 250 | 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */, 251 | 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */, 252 | ); 253 | runOnlyForDeploymentPostprocessing = 0; 254 | }; 255 | /* End PBXResourcesBuildPhase section */ 256 | 257 | /* Begin PBXShellScriptBuildPhase section */ 258 | 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */ = { 259 | isa = PBXShellScriptBuildPhase; 260 | buildActionMask = 2147483647; 261 | files = ( 262 | ); 263 | inputPaths = ( 264 | ); 265 | name = "Bundle React Native code and images"; 266 | outputPaths = ( 267 | ); 268 | runOnlyForDeploymentPostprocessing = 0; 269 | shellPath = /bin/sh; 270 | shellScript = "set -e\n\nexport NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh\n"; 271 | }; 272 | 238C272505EC18894F147C47 /* [CP] Embed Pods Frameworks */ = { 273 | isa = PBXShellScriptBuildPhase; 274 | buildActionMask = 2147483647; 275 | files = ( 276 | ); 277 | inputFileListPaths = ( 278 | ); 279 | name = "[CP] Embed Pods Frameworks"; 280 | outputFileListPaths = ( 281 | ); 282 | runOnlyForDeploymentPostprocessing = 0; 283 | shellPath = /bin/sh; 284 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-BasicApp/Pods-BasicApp-frameworks.sh\"\n"; 285 | showEnvVarsInLog = 0; 286 | }; 287 | 2BC7CE56A6A153AA9DF05333 /* [CP] Copy Pods Resources */ = { 288 | isa = PBXShellScriptBuildPhase; 289 | buildActionMask = 2147483647; 290 | files = ( 291 | ); 292 | inputFileListPaths = ( 293 | ); 294 | name = "[CP] Copy Pods Resources"; 295 | outputFileListPaths = ( 296 | ); 297 | runOnlyForDeploymentPostprocessing = 0; 298 | shellPath = /bin/sh; 299 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-BasicApp/Pods-BasicApp-resources.sh\"\n"; 300 | showEnvVarsInLog = 0; 301 | }; 302 | 84065F8AF2681FA8400F0F0C /* [CP] Copy Pods Resources */ = { 303 | isa = PBXShellScriptBuildPhase; 304 | buildActionMask = 2147483647; 305 | files = ( 306 | ); 307 | inputFileListPaths = ( 308 | ); 309 | name = "[CP] Copy Pods Resources"; 310 | outputFileListPaths = ( 311 | ); 312 | runOnlyForDeploymentPostprocessing = 0; 313 | shellPath = /bin/sh; 314 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-BasicApp-BasicAppTests/Pods-BasicApp-BasicAppTests-resources.sh\"\n"; 315 | showEnvVarsInLog = 0; 316 | }; 317 | 843EDEA405B56501C429ED84 /* [CP] Embed Pods Frameworks */ = { 318 | isa = PBXShellScriptBuildPhase; 319 | buildActionMask = 2147483647; 320 | files = ( 321 | ); 322 | inputFileListPaths = ( 323 | ); 324 | name = "[CP] Embed Pods Frameworks"; 325 | outputFileListPaths = ( 326 | ); 327 | runOnlyForDeploymentPostprocessing = 0; 328 | shellPath = /bin/sh; 329 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-BasicApp-BasicAppTests/Pods-BasicApp-BasicAppTests-frameworks.sh\"\n"; 330 | showEnvVarsInLog = 0; 331 | }; 332 | 8B7EE21C792A719595021F29 /* [CP] Check Pods Manifest.lock */ = { 333 | isa = PBXShellScriptBuildPhase; 334 | buildActionMask = 2147483647; 335 | files = ( 336 | ); 337 | inputFileListPaths = ( 338 | ); 339 | inputPaths = ( 340 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 341 | "${PODS_ROOT}/Manifest.lock", 342 | ); 343 | name = "[CP] Check Pods Manifest.lock"; 344 | outputFileListPaths = ( 345 | ); 346 | outputPaths = ( 347 | "$(DERIVED_FILE_DIR)/Pods-BasicApp-BasicAppTests-checkManifestLockResult.txt", 348 | ); 349 | runOnlyForDeploymentPostprocessing = 0; 350 | shellPath = /bin/sh; 351 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 352 | showEnvVarsInLog = 0; 353 | }; 354 | 9143125BD2F166E7D3FCEBD8 /* [CP] Check Pods Manifest.lock */ = { 355 | isa = PBXShellScriptBuildPhase; 356 | buildActionMask = 2147483647; 357 | files = ( 358 | ); 359 | inputFileListPaths = ( 360 | ); 361 | inputPaths = ( 362 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 363 | "${PODS_ROOT}/Manifest.lock", 364 | ); 365 | name = "[CP] Check Pods Manifest.lock"; 366 | outputFileListPaths = ( 367 | ); 368 | outputPaths = ( 369 | "$(DERIVED_FILE_DIR)/Pods-BasicApp-checkManifestLockResult.txt", 370 | ); 371 | runOnlyForDeploymentPostprocessing = 0; 372 | shellPath = /bin/sh; 373 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 374 | showEnvVarsInLog = 0; 375 | }; 376 | FD10A7F022414F080027D42C /* Start Packager */ = { 377 | isa = PBXShellScriptBuildPhase; 378 | buildActionMask = 2147483647; 379 | files = ( 380 | ); 381 | inputFileListPaths = ( 382 | ); 383 | inputPaths = ( 384 | ); 385 | name = "Start Packager"; 386 | outputFileListPaths = ( 387 | ); 388 | outputPaths = ( 389 | ); 390 | runOnlyForDeploymentPostprocessing = 0; 391 | shellPath = /bin/sh; 392 | shellScript = "export RCT_METRO_PORT=\"${RCT_METRO_PORT:=8081}\"\necho \"export RCT_METRO_PORT=${RCT_METRO_PORT}\" > \"${SRCROOT}/../node_modules/react-native/scripts/.packager.env\"\nif [ -z \"${RCT_NO_LAUNCH_PACKAGER+xxx}\" ] ; then\n if nc -w 5 -z localhost ${RCT_METRO_PORT} ; then\n if ! curl -s \"http://localhost:${RCT_METRO_PORT}/status\" | grep -q \"packager-status:running\" ; then\n echo \"Port ${RCT_METRO_PORT} already in use, packager is either not running or not running correctly\"\n exit 2\n fi\n else\n open \"$SRCROOT/../node_modules/react-native/scripts/launchPackager.command\" || echo \"Can't start packager automatically\"\n fi\nfi\n"; 393 | showEnvVarsInLog = 0; 394 | }; 395 | /* End PBXShellScriptBuildPhase section */ 396 | 397 | /* Begin PBXSourcesBuildPhase section */ 398 | 00E356EA1AD99517003FC87E /* Sources */ = { 399 | isa = PBXSourcesBuildPhase; 400 | buildActionMask = 2147483647; 401 | files = ( 402 | 00E356F31AD99517003FC87E /* BasicAppTests.m in Sources */, 403 | ); 404 | runOnlyForDeploymentPostprocessing = 0; 405 | }; 406 | 13B07F871A680F5B00A75B9A /* Sources */ = { 407 | isa = PBXSourcesBuildPhase; 408 | buildActionMask = 2147483647; 409 | files = ( 410 | CF01C0932798908E009932D0 /* BridgeHeader.swift in Sources */, 411 | 13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */, 412 | 13B07FC11A68108700A75B9A /* main.m in Sources */, 413 | ); 414 | runOnlyForDeploymentPostprocessing = 0; 415 | }; 416 | /* End PBXSourcesBuildPhase section */ 417 | 418 | /* Begin PBXTargetDependency section */ 419 | 00E356F51AD99517003FC87E /* PBXTargetDependency */ = { 420 | isa = PBXTargetDependency; 421 | target = 13B07F861A680F5B00A75B9A /* BasicApp */; 422 | targetProxy = 00E356F41AD99517003FC87E /* PBXContainerItemProxy */; 423 | }; 424 | /* End PBXTargetDependency section */ 425 | 426 | /* Begin XCBuildConfiguration section */ 427 | 00E356F61AD99517003FC87E /* Debug */ = { 428 | isa = XCBuildConfiguration; 429 | baseConfigurationReference = 3A03A3D0AA35DD00F816F6FD /* Pods-BasicApp-BasicAppTests.debug.xcconfig */; 430 | buildSettings = { 431 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 432 | BUNDLE_LOADER = "$(TEST_HOST)"; 433 | GCC_PREPROCESSOR_DEFINITIONS = ( 434 | "DEBUG=1", 435 | "$(inherited)", 436 | ); 437 | INFOPLIST_FILE = BasicAppTests/Info.plist; 438 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 439 | LD_RUNPATH_SEARCH_PATHS = ( 440 | "$(inherited)", 441 | "@executable_path/Frameworks", 442 | "@loader_path/Frameworks", 443 | ); 444 | OTHER_LDFLAGS = ( 445 | "-ObjC", 446 | "-lc++", 447 | "$(inherited)", 448 | ); 449 | PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)"; 450 | PRODUCT_NAME = "$(TARGET_NAME)"; 451 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/BasicApp.app/BasicApp"; 452 | }; 453 | name = Debug; 454 | }; 455 | 00E356F71AD99517003FC87E /* Release */ = { 456 | isa = XCBuildConfiguration; 457 | baseConfigurationReference = 30B618F11CA9F61F4A2BCC18 /* Pods-BasicApp-BasicAppTests.release.xcconfig */; 458 | buildSettings = { 459 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 460 | BUNDLE_LOADER = "$(TEST_HOST)"; 461 | COPY_PHASE_STRIP = NO; 462 | INFOPLIST_FILE = BasicAppTests/Info.plist; 463 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 464 | LD_RUNPATH_SEARCH_PATHS = ( 465 | "$(inherited)", 466 | "@executable_path/Frameworks", 467 | "@loader_path/Frameworks", 468 | ); 469 | OTHER_LDFLAGS = ( 470 | "-ObjC", 471 | "-lc++", 472 | "$(inherited)", 473 | ); 474 | PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)"; 475 | PRODUCT_NAME = "$(TARGET_NAME)"; 476 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/BasicApp.app/BasicApp"; 477 | }; 478 | name = Release; 479 | }; 480 | 13B07F941A680F5B00A75B9A /* Debug */ = { 481 | isa = XCBuildConfiguration; 482 | baseConfigurationReference = DBAE69E2F4FE155BDFBF583F /* Pods-BasicApp.debug.xcconfig */; 483 | buildSettings = { 484 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 485 | CLANG_ENABLE_MODULES = YES; 486 | CURRENT_PROJECT_VERSION = 1; 487 | ENABLE_BITCODE = NO; 488 | INFOPLIST_FILE = BasicApp/Info.plist; 489 | LD_RUNPATH_SEARCH_PATHS = ( 490 | "$(inherited)", 491 | "@executable_path/Frameworks", 492 | ); 493 | OTHER_LDFLAGS = ( 494 | "$(inherited)", 495 | "-ObjC", 496 | "-lc++", 497 | ); 498 | PRESERVE_DEAD_CODE_INITS_AND_TERMS = NO; 499 | PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)"; 500 | PRODUCT_NAME = BasicApp; 501 | SWIFT_OBJC_BRIDGING_HEADER = "BasicApp-Bridging-Header.h"; 502 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 503 | SWIFT_VERSION = 5.0; 504 | VERSIONING_SYSTEM = "apple-generic"; 505 | }; 506 | name = Debug; 507 | }; 508 | 13B07F951A680F5B00A75B9A /* Release */ = { 509 | isa = XCBuildConfiguration; 510 | baseConfigurationReference = A397D62B2A1AB4DE08565ACB /* Pods-BasicApp.release.xcconfig */; 511 | buildSettings = { 512 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 513 | CLANG_ENABLE_MODULES = YES; 514 | CURRENT_PROJECT_VERSION = 1; 515 | INFOPLIST_FILE = BasicApp/Info.plist; 516 | LD_RUNPATH_SEARCH_PATHS = ( 517 | "$(inherited)", 518 | "@executable_path/Frameworks", 519 | ); 520 | OTHER_LDFLAGS = ( 521 | "$(inherited)", 522 | "-ObjC", 523 | "-lc++", 524 | ); 525 | PRESERVE_DEAD_CODE_INITS_AND_TERMS = NO; 526 | PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)"; 527 | PRODUCT_NAME = BasicApp; 528 | SWIFT_OBJC_BRIDGING_HEADER = "BasicApp-Bridging-Header.h"; 529 | SWIFT_VERSION = 5.0; 530 | VERSIONING_SYSTEM = "apple-generic"; 531 | }; 532 | name = Release; 533 | }; 534 | 83CBBA201A601CBA00E9B192 /* Debug */ = { 535 | isa = XCBuildConfiguration; 536 | buildSettings = { 537 | ALWAYS_SEARCH_USER_PATHS = NO; 538 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 539 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 540 | CLANG_CXX_LIBRARY = "libc++"; 541 | CLANG_ENABLE_MODULES = YES; 542 | CLANG_ENABLE_OBJC_ARC = YES; 543 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 544 | CLANG_WARN_BOOL_CONVERSION = YES; 545 | CLANG_WARN_COMMA = YES; 546 | CLANG_WARN_CONSTANT_CONVERSION = YES; 547 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 548 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 549 | CLANG_WARN_EMPTY_BODY = YES; 550 | CLANG_WARN_ENUM_CONVERSION = YES; 551 | CLANG_WARN_INFINITE_RECURSION = YES; 552 | CLANG_WARN_INT_CONVERSION = YES; 553 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 554 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 555 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 556 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 557 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 558 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 559 | CLANG_WARN_STRICT_PROTOTYPES = YES; 560 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 561 | CLANG_WARN_UNREACHABLE_CODE = YES; 562 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 563 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 564 | COPY_PHASE_STRIP = NO; 565 | ENABLE_STRICT_OBJC_MSGSEND = YES; 566 | ENABLE_TESTABILITY = YES; 567 | "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "arm64 "; 568 | GCC_C_LANGUAGE_STANDARD = gnu99; 569 | GCC_DYNAMIC_NO_PIC = NO; 570 | GCC_NO_COMMON_BLOCKS = YES; 571 | GCC_OPTIMIZATION_LEVEL = 0; 572 | GCC_PREPROCESSOR_DEFINITIONS = ( 573 | "DEBUG=1", 574 | "$(inherited)", 575 | ); 576 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 577 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 578 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 579 | GCC_WARN_UNDECLARED_SELECTOR = YES; 580 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 581 | GCC_WARN_UNUSED_FUNCTION = YES; 582 | GCC_WARN_UNUSED_VARIABLE = YES; 583 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 584 | LD_RUNPATH_SEARCH_PATHS = ( 585 | /usr/lib/swift, 586 | "$(inherited)", 587 | ); 588 | LIBRARY_SEARCH_PATHS = ( 589 | "\"$(SDKROOT)/usr/lib/swift\"", 590 | "\"$(inherited)\"", 591 | ); 592 | MTL_ENABLE_DEBUG_INFO = YES; 593 | ONLY_ACTIVE_ARCH = YES; 594 | PRESERVE_DEAD_CODE_INITS_AND_TERMS = YES; 595 | SDKROOT = iphoneos; 596 | }; 597 | name = Debug; 598 | }; 599 | 83CBBA211A601CBA00E9B192 /* Release */ = { 600 | isa = XCBuildConfiguration; 601 | buildSettings = { 602 | ALWAYS_SEARCH_USER_PATHS = NO; 603 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 604 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 605 | CLANG_CXX_LIBRARY = "libc++"; 606 | CLANG_ENABLE_MODULES = YES; 607 | CLANG_ENABLE_OBJC_ARC = YES; 608 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 609 | CLANG_WARN_BOOL_CONVERSION = YES; 610 | CLANG_WARN_COMMA = YES; 611 | CLANG_WARN_CONSTANT_CONVERSION = YES; 612 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 613 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 614 | CLANG_WARN_EMPTY_BODY = YES; 615 | CLANG_WARN_ENUM_CONVERSION = YES; 616 | CLANG_WARN_INFINITE_RECURSION = YES; 617 | CLANG_WARN_INT_CONVERSION = YES; 618 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 619 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 620 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 621 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 622 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 623 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 624 | CLANG_WARN_STRICT_PROTOTYPES = YES; 625 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 626 | CLANG_WARN_UNREACHABLE_CODE = YES; 627 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 628 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 629 | COPY_PHASE_STRIP = YES; 630 | ENABLE_NS_ASSERTIONS = NO; 631 | ENABLE_STRICT_OBJC_MSGSEND = YES; 632 | "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "arm64 "; 633 | GCC_C_LANGUAGE_STANDARD = gnu99; 634 | GCC_NO_COMMON_BLOCKS = YES; 635 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 636 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 637 | GCC_WARN_UNDECLARED_SELECTOR = YES; 638 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 639 | GCC_WARN_UNUSED_FUNCTION = YES; 640 | GCC_WARN_UNUSED_VARIABLE = YES; 641 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 642 | LD_RUNPATH_SEARCH_PATHS = ( 643 | /usr/lib/swift, 644 | "$(inherited)", 645 | ); 646 | LIBRARY_SEARCH_PATHS = ( 647 | "\"$(SDKROOT)/usr/lib/swift\"", 648 | "\"$(inherited)\"", 649 | ); 650 | MTL_ENABLE_DEBUG_INFO = NO; 651 | PRESERVE_DEAD_CODE_INITS_AND_TERMS = YES; 652 | SDKROOT = iphoneos; 653 | VALIDATE_PRODUCT = YES; 654 | }; 655 | name = Release; 656 | }; 657 | /* End XCBuildConfiguration section */ 658 | 659 | /* Begin XCConfigurationList section */ 660 | 00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "BasicAppTests" */ = { 661 | isa = XCConfigurationList; 662 | buildConfigurations = ( 663 | 00E356F61AD99517003FC87E /* Debug */, 664 | 00E356F71AD99517003FC87E /* Release */, 665 | ); 666 | defaultConfigurationIsVisible = 0; 667 | defaultConfigurationName = Release; 668 | }; 669 | 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "BasicApp" */ = { 670 | isa = XCConfigurationList; 671 | buildConfigurations = ( 672 | 13B07F941A680F5B00A75B9A /* Debug */, 673 | 13B07F951A680F5B00A75B9A /* Release */, 674 | ); 675 | defaultConfigurationIsVisible = 0; 676 | defaultConfigurationName = Release; 677 | }; 678 | 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "BasicApp" */ = { 679 | isa = XCConfigurationList; 680 | buildConfigurations = ( 681 | 83CBBA201A601CBA00E9B192 /* Debug */, 682 | 83CBBA211A601CBA00E9B192 /* Release */, 683 | ); 684 | defaultConfigurationIsVisible = 0; 685 | defaultConfigurationName = Release; 686 | }; 687 | /* End XCConfigurationList section */ 688 | }; 689 | rootObject = 83CBB9F71A601CBA00E9B192 /* Project object */; 690 | } 691 | -------------------------------------------------------------------------------- /example/ios/BasicApp.xcodeproj/xcshareddata/xcschemes/BasicApp.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 53 | 55 | 61 | 62 | 63 | 64 | 70 | 72 | 78 | 79 | 80 | 81 | 83 | 84 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /example/ios/BasicApp.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/ios/BasicApp.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/BasicApp/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : UIResponder 5 | 6 | @property (nonatomic, strong) UIWindow *window; 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /example/ios/BasicApp/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "AppDelegate.h" 2 | 3 | #import 4 | #import 5 | #import 6 | 7 | #ifdef FB_SONARKIT_ENABLED 8 | #import 9 | #import 10 | #import 11 | #import 12 | #import 13 | #import 14 | 15 | static void InitializeFlipper(UIApplication *application) { 16 | FlipperClient *client = [FlipperClient sharedClient]; 17 | SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults]; 18 | [client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]]; 19 | [client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]]; 20 | [client addPlugin:[FlipperKitReactPlugin new]]; 21 | [client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]]; 22 | [client start]; 23 | } 24 | #endif 25 | 26 | @implementation AppDelegate 27 | 28 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 29 | { 30 | #ifdef FB_SONARKIT_ENABLED 31 | InitializeFlipper(application); 32 | #endif 33 | 34 | RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; 35 | RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge 36 | moduleName:@"BasicApp" 37 | initialProperties:nil]; 38 | 39 | if (@available(iOS 13.0, *)) { 40 | rootView.backgroundColor = [UIColor systemBackgroundColor]; 41 | } else { 42 | rootView.backgroundColor = [UIColor whiteColor]; 43 | } 44 | 45 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 46 | UIViewController *rootViewController = [UIViewController new]; 47 | rootViewController.view = rootView; 48 | self.window.rootViewController = rootViewController; 49 | [self.window makeKeyAndVisible]; 50 | return YES; 51 | } 52 | 53 | - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge 54 | { 55 | #if DEBUG 56 | return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; 57 | #else 58 | return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; 59 | #endif 60 | } 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /example/ios/BasicApp/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /example/ios/BasicApp/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /example/ios/BasicApp/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | BasicApp 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSRequiresIPhoneOS 26 | 27 | NSAppTransportSecurity 28 | 29 | NSExceptionDomains 30 | 31 | localhost 32 | 33 | NSExceptionAllowsInsecureHTTPLoads 34 | 35 | 36 | 37 | 38 | NSLocationWhenInUseUsageDescription 39 | 40 | UIBackgroundModes 41 | 42 | audio 43 | fetch 44 | location 45 | processing 46 | 47 | UILaunchStoryboardName 48 | LaunchScreen 49 | UIRequiredDeviceCapabilities 50 | 51 | armv7 52 | 53 | UISupportedInterfaceOrientations 54 | 55 | UIInterfaceOrientationPortrait 56 | UIInterfaceOrientationLandscapeLeft 57 | UIInterfaceOrientationLandscapeRight 58 | 59 | UIViewControllerBasedStatusBarAppearance 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /example/ios/BasicApp/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 24 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /example/ios/BasicApp/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "AppDelegate.h" 4 | 5 | int main(int argc, char * argv[]) { 6 | @autoreleasepool { 7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /example/ios/BasicAppTests/BasicAppTests.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | #import 5 | #import 6 | 7 | #define TIMEOUT_SECONDS 600 8 | #define TEXT_TO_LOOK_FOR @"Welcome to React" 9 | 10 | @interface BasicAppTests : XCTestCase 11 | 12 | @end 13 | 14 | @implementation BasicAppTests 15 | 16 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test 17 | { 18 | if (test(view)) { 19 | return YES; 20 | } 21 | for (UIView *subview in [view subviews]) { 22 | if ([self findSubviewInView:subview matching:test]) { 23 | return YES; 24 | } 25 | } 26 | return NO; 27 | } 28 | 29 | - (void)testRendersWelcomeScreen 30 | { 31 | UIViewController *vc = [[[RCTSharedApplication() delegate] window] rootViewController]; 32 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; 33 | BOOL foundElement = NO; 34 | 35 | __block NSString *redboxError = nil; 36 | #ifdef DEBUG 37 | RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { 38 | if (level >= RCTLogLevelError) { 39 | redboxError = message; 40 | } 41 | }); 42 | #endif 43 | 44 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) { 45 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 46 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 47 | 48 | foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) { 49 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) { 50 | return YES; 51 | } 52 | return NO; 53 | }]; 54 | } 55 | 56 | #ifdef DEBUG 57 | RCTSetLogFunction(RCTDefaultLogFunction); 58 | #endif 59 | 60 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError); 61 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS); 62 | } 63 | 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /example/ios/BasicAppTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /example/ios/BridgeHeader.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BridgeHeader.swift 3 | // BasicApp 4 | // 5 | // Created by Jorge Quevedo on 1/19/22. 6 | // 7 | 8 | import Foundation 9 | -------------------------------------------------------------------------------- /example/ios/Podfile: -------------------------------------------------------------------------------- 1 | require_relative '../node_modules/react-native/scripts/react_native_pods' 2 | require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' 3 | 4 | platform :ios, '11.0' 5 | install! 'cocoapods', :disable_input_output_paths => true 6 | 7 | target 'BasicApp' do 8 | config = use_native_modules! 9 | pod 'react-native-mapbox-navigation', :path => '../../', :inhibit_warnings => false 10 | $ReactNativeMapboxGLIOSVersion = '~> 8.5.0' 11 | 12 | use_react_native!( 13 | :path => config[:reactNativePath], 14 | # to enable hermes on iOS, change `false` to `true` and then install pods 15 | :hermes_enabled => false 16 | ) 17 | 18 | pre_install do |installer| 19 | $RNMBNAV.pre_install(installer) 20 | end 21 | 22 | target 'BasicAppTests' do 23 | inherit! :complete 24 | # Pods for testing 25 | end 26 | 27 | # Enables Flipper. 28 | # 29 | # Note that if you have use_frameworks! enabled, Flipper will not work and 30 | # you should disable the next line. 31 | # use_flipper!() 32 | 33 | post_install do |installer| 34 | react_native_post_install(installer) 35 | __apply_Xcode_12_5_M1_post_install_workaround(installer) 36 | installer.pods_project.targets.each do |t| 37 | t.build_configurations.each do |bc| 38 | bc.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0' 39 | end 40 | end 41 | # $RNMBNAV.post_install(installer) 42 | $RNMBNAV.pre_install(installer) 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /example/ios/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - boost (1.76.0) 3 | - DoubleConversion (1.1.6) 4 | - FBLazyVector (0.66.4) 5 | - FBReactNativeSpec (0.66.4): 6 | - RCT-Folly (= 2021.06.28.00-v2) 7 | - RCTRequired (= 0.66.4) 8 | - RCTTypeSafety (= 0.66.4) 9 | - React-Core (= 0.66.4) 10 | - React-jsi (= 0.66.4) 11 | - ReactCommon/turbomodule/core (= 0.66.4) 12 | - fmt (6.2.1) 13 | - glog (0.3.5) 14 | - MapboxCommon (20.1.2) 15 | - MapboxCoreMaps (10.1.1): 16 | - MapboxCommon (~> 20.1) 17 | - MapboxCoreNavigation (2.1.1): 18 | - MapboxDirections (~> 2.1) 19 | - MapboxMobileEvents (~> 1.0) 20 | - MapboxNavigationNative (~> 80.0) 21 | - MapboxDirections (2.2.0): 22 | - Polyline (~> 5.0) 23 | - Turf (~> 2.0) 24 | - MapboxMaps (10.1.2): 25 | - MapboxCommon (= 20.1.2) 26 | - MapboxCoreMaps (= 10.1.1) 27 | - MapboxMobileEvents (= 1.0.6) 28 | - Turf (~> 2.0) 29 | - MapboxMobileEvents (1.0.6) 30 | - MapboxNavigation (2.1.1): 31 | - MapboxCoreNavigation (= 2.1.1) 32 | - MapboxMaps (< 11.0.0, >= 10.1.1) 33 | - MapboxMobileEvents (~> 1.0) 34 | - MapboxSpeech (~> 2.0) 35 | - Solar-dev (~> 3.0) 36 | - MapboxNavigationNative (80.0.2): 37 | - MapboxCommon (~> 20.1) 38 | - MapboxSpeech (2.0.0) 39 | - Polyline (5.0.2) 40 | - RCT-Folly (2021.06.28.00-v2): 41 | - boost 42 | - DoubleConversion 43 | - fmt (~> 6.2.1) 44 | - glog 45 | - RCT-Folly/Default (= 2021.06.28.00-v2) 46 | - RCT-Folly/Default (2021.06.28.00-v2): 47 | - boost 48 | - DoubleConversion 49 | - fmt (~> 6.2.1) 50 | - glog 51 | - RCTRequired (0.66.4) 52 | - RCTTypeSafety (0.66.4): 53 | - FBLazyVector (= 0.66.4) 54 | - RCT-Folly (= 2021.06.28.00-v2) 55 | - RCTRequired (= 0.66.4) 56 | - React-Core (= 0.66.4) 57 | - React (0.66.4): 58 | - React-Core (= 0.66.4) 59 | - React-Core/DevSupport (= 0.66.4) 60 | - React-Core/RCTWebSocket (= 0.66.4) 61 | - React-RCTActionSheet (= 0.66.4) 62 | - React-RCTAnimation (= 0.66.4) 63 | - React-RCTBlob (= 0.66.4) 64 | - React-RCTImage (= 0.66.4) 65 | - React-RCTLinking (= 0.66.4) 66 | - React-RCTNetwork (= 0.66.4) 67 | - React-RCTSettings (= 0.66.4) 68 | - React-RCTText (= 0.66.4) 69 | - React-RCTVibration (= 0.66.4) 70 | - React-callinvoker (0.66.4) 71 | - React-Core (0.66.4): 72 | - glog 73 | - RCT-Folly (= 2021.06.28.00-v2) 74 | - React-Core/Default (= 0.66.4) 75 | - React-cxxreact (= 0.66.4) 76 | - React-jsi (= 0.66.4) 77 | - React-jsiexecutor (= 0.66.4) 78 | - React-perflogger (= 0.66.4) 79 | - Yoga 80 | - React-Core/CoreModulesHeaders (0.66.4): 81 | - glog 82 | - RCT-Folly (= 2021.06.28.00-v2) 83 | - React-Core/Default 84 | - React-cxxreact (= 0.66.4) 85 | - React-jsi (= 0.66.4) 86 | - React-jsiexecutor (= 0.66.4) 87 | - React-perflogger (= 0.66.4) 88 | - Yoga 89 | - React-Core/Default (0.66.4): 90 | - glog 91 | - RCT-Folly (= 2021.06.28.00-v2) 92 | - React-cxxreact (= 0.66.4) 93 | - React-jsi (= 0.66.4) 94 | - React-jsiexecutor (= 0.66.4) 95 | - React-perflogger (= 0.66.4) 96 | - Yoga 97 | - React-Core/DevSupport (0.66.4): 98 | - glog 99 | - RCT-Folly (= 2021.06.28.00-v2) 100 | - React-Core/Default (= 0.66.4) 101 | - React-Core/RCTWebSocket (= 0.66.4) 102 | - React-cxxreact (= 0.66.4) 103 | - React-jsi (= 0.66.4) 104 | - React-jsiexecutor (= 0.66.4) 105 | - React-jsinspector (= 0.66.4) 106 | - React-perflogger (= 0.66.4) 107 | - Yoga 108 | - React-Core/RCTActionSheetHeaders (0.66.4): 109 | - glog 110 | - RCT-Folly (= 2021.06.28.00-v2) 111 | - React-Core/Default 112 | - React-cxxreact (= 0.66.4) 113 | - React-jsi (= 0.66.4) 114 | - React-jsiexecutor (= 0.66.4) 115 | - React-perflogger (= 0.66.4) 116 | - Yoga 117 | - React-Core/RCTAnimationHeaders (0.66.4): 118 | - glog 119 | - RCT-Folly (= 2021.06.28.00-v2) 120 | - React-Core/Default 121 | - React-cxxreact (= 0.66.4) 122 | - React-jsi (= 0.66.4) 123 | - React-jsiexecutor (= 0.66.4) 124 | - React-perflogger (= 0.66.4) 125 | - Yoga 126 | - React-Core/RCTBlobHeaders (0.66.4): 127 | - glog 128 | - RCT-Folly (= 2021.06.28.00-v2) 129 | - React-Core/Default 130 | - React-cxxreact (= 0.66.4) 131 | - React-jsi (= 0.66.4) 132 | - React-jsiexecutor (= 0.66.4) 133 | - React-perflogger (= 0.66.4) 134 | - Yoga 135 | - React-Core/RCTImageHeaders (0.66.4): 136 | - glog 137 | - RCT-Folly (= 2021.06.28.00-v2) 138 | - React-Core/Default 139 | - React-cxxreact (= 0.66.4) 140 | - React-jsi (= 0.66.4) 141 | - React-jsiexecutor (= 0.66.4) 142 | - React-perflogger (= 0.66.4) 143 | - Yoga 144 | - React-Core/RCTLinkingHeaders (0.66.4): 145 | - glog 146 | - RCT-Folly (= 2021.06.28.00-v2) 147 | - React-Core/Default 148 | - React-cxxreact (= 0.66.4) 149 | - React-jsi (= 0.66.4) 150 | - React-jsiexecutor (= 0.66.4) 151 | - React-perflogger (= 0.66.4) 152 | - Yoga 153 | - React-Core/RCTNetworkHeaders (0.66.4): 154 | - glog 155 | - RCT-Folly (= 2021.06.28.00-v2) 156 | - React-Core/Default 157 | - React-cxxreact (= 0.66.4) 158 | - React-jsi (= 0.66.4) 159 | - React-jsiexecutor (= 0.66.4) 160 | - React-perflogger (= 0.66.4) 161 | - Yoga 162 | - React-Core/RCTSettingsHeaders (0.66.4): 163 | - glog 164 | - RCT-Folly (= 2021.06.28.00-v2) 165 | - React-Core/Default 166 | - React-cxxreact (= 0.66.4) 167 | - React-jsi (= 0.66.4) 168 | - React-jsiexecutor (= 0.66.4) 169 | - React-perflogger (= 0.66.4) 170 | - Yoga 171 | - React-Core/RCTTextHeaders (0.66.4): 172 | - glog 173 | - RCT-Folly (= 2021.06.28.00-v2) 174 | - React-Core/Default 175 | - React-cxxreact (= 0.66.4) 176 | - React-jsi (= 0.66.4) 177 | - React-jsiexecutor (= 0.66.4) 178 | - React-perflogger (= 0.66.4) 179 | - Yoga 180 | - React-Core/RCTVibrationHeaders (0.66.4): 181 | - glog 182 | - RCT-Folly (= 2021.06.28.00-v2) 183 | - React-Core/Default 184 | - React-cxxreact (= 0.66.4) 185 | - React-jsi (= 0.66.4) 186 | - React-jsiexecutor (= 0.66.4) 187 | - React-perflogger (= 0.66.4) 188 | - Yoga 189 | - React-Core/RCTWebSocket (0.66.4): 190 | - glog 191 | - RCT-Folly (= 2021.06.28.00-v2) 192 | - React-Core/Default (= 0.66.4) 193 | - React-cxxreact (= 0.66.4) 194 | - React-jsi (= 0.66.4) 195 | - React-jsiexecutor (= 0.66.4) 196 | - React-perflogger (= 0.66.4) 197 | - Yoga 198 | - React-CoreModules (0.66.4): 199 | - FBReactNativeSpec (= 0.66.4) 200 | - RCT-Folly (= 2021.06.28.00-v2) 201 | - RCTTypeSafety (= 0.66.4) 202 | - React-Core/CoreModulesHeaders (= 0.66.4) 203 | - React-jsi (= 0.66.4) 204 | - React-RCTImage (= 0.66.4) 205 | - ReactCommon/turbomodule/core (= 0.66.4) 206 | - React-cxxreact (0.66.4): 207 | - boost (= 1.76.0) 208 | - DoubleConversion 209 | - glog 210 | - RCT-Folly (= 2021.06.28.00-v2) 211 | - React-callinvoker (= 0.66.4) 212 | - React-jsi (= 0.66.4) 213 | - React-jsinspector (= 0.66.4) 214 | - React-logger (= 0.66.4) 215 | - React-perflogger (= 0.66.4) 216 | - React-runtimeexecutor (= 0.66.4) 217 | - React-jsi (0.66.4): 218 | - boost (= 1.76.0) 219 | - DoubleConversion 220 | - glog 221 | - RCT-Folly (= 2021.06.28.00-v2) 222 | - React-jsi/Default (= 0.66.4) 223 | - React-jsi/Default (0.66.4): 224 | - boost (= 1.76.0) 225 | - DoubleConversion 226 | - glog 227 | - RCT-Folly (= 2021.06.28.00-v2) 228 | - React-jsiexecutor (0.66.4): 229 | - DoubleConversion 230 | - glog 231 | - RCT-Folly (= 2021.06.28.00-v2) 232 | - React-cxxreact (= 0.66.4) 233 | - React-jsi (= 0.66.4) 234 | - React-perflogger (= 0.66.4) 235 | - React-jsinspector (0.66.4) 236 | - React-logger (0.66.4): 237 | - glog 238 | - react-native-mapbox-navigation (1.1.0): 239 | - MapboxNavigation (~> 2.1.0) 240 | - React-Core 241 | - React-perflogger (0.66.4) 242 | - React-RCTActionSheet (0.66.4): 243 | - React-Core/RCTActionSheetHeaders (= 0.66.4) 244 | - React-RCTAnimation (0.66.4): 245 | - FBReactNativeSpec (= 0.66.4) 246 | - RCT-Folly (= 2021.06.28.00-v2) 247 | - RCTTypeSafety (= 0.66.4) 248 | - React-Core/RCTAnimationHeaders (= 0.66.4) 249 | - React-jsi (= 0.66.4) 250 | - ReactCommon/turbomodule/core (= 0.66.4) 251 | - React-RCTBlob (0.66.4): 252 | - FBReactNativeSpec (= 0.66.4) 253 | - RCT-Folly (= 2021.06.28.00-v2) 254 | - React-Core/RCTBlobHeaders (= 0.66.4) 255 | - React-Core/RCTWebSocket (= 0.66.4) 256 | - React-jsi (= 0.66.4) 257 | - React-RCTNetwork (= 0.66.4) 258 | - ReactCommon/turbomodule/core (= 0.66.4) 259 | - React-RCTImage (0.66.4): 260 | - FBReactNativeSpec (= 0.66.4) 261 | - RCT-Folly (= 2021.06.28.00-v2) 262 | - RCTTypeSafety (= 0.66.4) 263 | - React-Core/RCTImageHeaders (= 0.66.4) 264 | - React-jsi (= 0.66.4) 265 | - React-RCTNetwork (= 0.66.4) 266 | - ReactCommon/turbomodule/core (= 0.66.4) 267 | - React-RCTLinking (0.66.4): 268 | - FBReactNativeSpec (= 0.66.4) 269 | - React-Core/RCTLinkingHeaders (= 0.66.4) 270 | - React-jsi (= 0.66.4) 271 | - ReactCommon/turbomodule/core (= 0.66.4) 272 | - React-RCTNetwork (0.66.4): 273 | - FBReactNativeSpec (= 0.66.4) 274 | - RCT-Folly (= 2021.06.28.00-v2) 275 | - RCTTypeSafety (= 0.66.4) 276 | - React-Core/RCTNetworkHeaders (= 0.66.4) 277 | - React-jsi (= 0.66.4) 278 | - ReactCommon/turbomodule/core (= 0.66.4) 279 | - React-RCTSettings (0.66.4): 280 | - FBReactNativeSpec (= 0.66.4) 281 | - RCT-Folly (= 2021.06.28.00-v2) 282 | - RCTTypeSafety (= 0.66.4) 283 | - React-Core/RCTSettingsHeaders (= 0.66.4) 284 | - React-jsi (= 0.66.4) 285 | - ReactCommon/turbomodule/core (= 0.66.4) 286 | - React-RCTText (0.66.4): 287 | - React-Core/RCTTextHeaders (= 0.66.4) 288 | - React-RCTVibration (0.66.4): 289 | - FBReactNativeSpec (= 0.66.4) 290 | - RCT-Folly (= 2021.06.28.00-v2) 291 | - React-Core/RCTVibrationHeaders (= 0.66.4) 292 | - React-jsi (= 0.66.4) 293 | - ReactCommon/turbomodule/core (= 0.66.4) 294 | - React-runtimeexecutor (0.66.4): 295 | - React-jsi (= 0.66.4) 296 | - ReactCommon/turbomodule/core (0.66.4): 297 | - DoubleConversion 298 | - glog 299 | - RCT-Folly (= 2021.06.28.00-v2) 300 | - React-callinvoker (= 0.66.4) 301 | - React-Core (= 0.66.4) 302 | - React-cxxreact (= 0.66.4) 303 | - React-jsi (= 0.66.4) 304 | - React-logger (= 0.66.4) 305 | - React-perflogger (= 0.66.4) 306 | - Solar-dev (3.0.1) 307 | - Turf (2.2.0) 308 | - Yoga (1.14.0) 309 | 310 | DEPENDENCIES: 311 | - boost (from `../node_modules/react-native/third-party-podspecs/boost.podspec`) 312 | - DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`) 313 | - FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`) 314 | - FBReactNativeSpec (from `../node_modules/react-native/React/FBReactNativeSpec`) 315 | - glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`) 316 | - RCT-Folly (from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`) 317 | - RCTRequired (from `../node_modules/react-native/Libraries/RCTRequired`) 318 | - RCTTypeSafety (from `../node_modules/react-native/Libraries/TypeSafety`) 319 | - React (from `../node_modules/react-native/`) 320 | - React-callinvoker (from `../node_modules/react-native/ReactCommon/callinvoker`) 321 | - React-Core (from `../node_modules/react-native/`) 322 | - React-Core/DevSupport (from `../node_modules/react-native/`) 323 | - React-Core/RCTWebSocket (from `../node_modules/react-native/`) 324 | - React-CoreModules (from `../node_modules/react-native/React/CoreModules`) 325 | - React-cxxreact (from `../node_modules/react-native/ReactCommon/cxxreact`) 326 | - React-jsi (from `../node_modules/react-native/ReactCommon/jsi`) 327 | - React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`) 328 | - React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`) 329 | - React-logger (from `../node_modules/react-native/ReactCommon/logger`) 330 | - react-native-mapbox-navigation (from `../../`) 331 | - React-perflogger (from `../node_modules/react-native/ReactCommon/reactperflogger`) 332 | - React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`) 333 | - React-RCTAnimation (from `../node_modules/react-native/Libraries/NativeAnimation`) 334 | - React-RCTBlob (from `../node_modules/react-native/Libraries/Blob`) 335 | - React-RCTImage (from `../node_modules/react-native/Libraries/Image`) 336 | - React-RCTLinking (from `../node_modules/react-native/Libraries/LinkingIOS`) 337 | - React-RCTNetwork (from `../node_modules/react-native/Libraries/Network`) 338 | - React-RCTSettings (from `../node_modules/react-native/Libraries/Settings`) 339 | - React-RCTText (from `../node_modules/react-native/Libraries/Text`) 340 | - React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`) 341 | - React-runtimeexecutor (from `../node_modules/react-native/ReactCommon/runtimeexecutor`) 342 | - ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`) 343 | - Yoga (from `../node_modules/react-native/ReactCommon/yoga`) 344 | 345 | SPEC REPOS: 346 | trunk: 347 | - fmt 348 | - MapboxCommon 349 | - MapboxCoreMaps 350 | - MapboxCoreNavigation 351 | - MapboxDirections 352 | - MapboxMaps 353 | - MapboxMobileEvents 354 | - MapboxNavigation 355 | - MapboxNavigationNative 356 | - MapboxSpeech 357 | - Polyline 358 | - Solar-dev 359 | - Turf 360 | 361 | EXTERNAL SOURCES: 362 | boost: 363 | :podspec: "../node_modules/react-native/third-party-podspecs/boost.podspec" 364 | DoubleConversion: 365 | :podspec: "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec" 366 | FBLazyVector: 367 | :path: "../node_modules/react-native/Libraries/FBLazyVector" 368 | FBReactNativeSpec: 369 | :path: "../node_modules/react-native/React/FBReactNativeSpec" 370 | glog: 371 | :podspec: "../node_modules/react-native/third-party-podspecs/glog.podspec" 372 | RCT-Folly: 373 | :podspec: "../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec" 374 | RCTRequired: 375 | :path: "../node_modules/react-native/Libraries/RCTRequired" 376 | RCTTypeSafety: 377 | :path: "../node_modules/react-native/Libraries/TypeSafety" 378 | React: 379 | :path: "../node_modules/react-native/" 380 | React-callinvoker: 381 | :path: "../node_modules/react-native/ReactCommon/callinvoker" 382 | React-Core: 383 | :path: "../node_modules/react-native/" 384 | React-CoreModules: 385 | :path: "../node_modules/react-native/React/CoreModules" 386 | React-cxxreact: 387 | :path: "../node_modules/react-native/ReactCommon/cxxreact" 388 | React-jsi: 389 | :path: "../node_modules/react-native/ReactCommon/jsi" 390 | React-jsiexecutor: 391 | :path: "../node_modules/react-native/ReactCommon/jsiexecutor" 392 | React-jsinspector: 393 | :path: "../node_modules/react-native/ReactCommon/jsinspector" 394 | React-logger: 395 | :path: "../node_modules/react-native/ReactCommon/logger" 396 | react-native-mapbox-navigation: 397 | :path: "../../" 398 | React-perflogger: 399 | :path: "../node_modules/react-native/ReactCommon/reactperflogger" 400 | React-RCTActionSheet: 401 | :path: "../node_modules/react-native/Libraries/ActionSheetIOS" 402 | React-RCTAnimation: 403 | :path: "../node_modules/react-native/Libraries/NativeAnimation" 404 | React-RCTBlob: 405 | :path: "../node_modules/react-native/Libraries/Blob" 406 | React-RCTImage: 407 | :path: "../node_modules/react-native/Libraries/Image" 408 | React-RCTLinking: 409 | :path: "../node_modules/react-native/Libraries/LinkingIOS" 410 | React-RCTNetwork: 411 | :path: "../node_modules/react-native/Libraries/Network" 412 | React-RCTSettings: 413 | :path: "../node_modules/react-native/Libraries/Settings" 414 | React-RCTText: 415 | :path: "../node_modules/react-native/Libraries/Text" 416 | React-RCTVibration: 417 | :path: "../node_modules/react-native/Libraries/Vibration" 418 | React-runtimeexecutor: 419 | :path: "../node_modules/react-native/ReactCommon/runtimeexecutor" 420 | ReactCommon: 421 | :path: "../node_modules/react-native/ReactCommon" 422 | Yoga: 423 | :path: "../node_modules/react-native/ReactCommon/yoga" 424 | 425 | SPEC CHECKSUMS: 426 | boost: a7c83b31436843459a1961bfd74b96033dc77234 427 | DoubleConversion: 831926d9b8bf8166fd87886c4abab286c2422662 428 | FBLazyVector: e5569e42a1c79ca00521846c223173a57aca1fe1 429 | FBReactNativeSpec: fe08c1cd7e2e205718d77ad14b34957cce949b58 430 | fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9 431 | glog: 5337263514dd6f09803962437687240c5dc39aa4 432 | MapboxCommon: f15bb4cc4810d8d72e2d72bf2295f3f0cb328b11 433 | MapboxCoreMaps: ee3d7f31efbbafe81ce33907b6a96066e111a244 434 | MapboxCoreNavigation: 90cfee78d9a7aeada16468e6ad9cbf425c41acc3 435 | MapboxDirections: aaa6f1ae1612692ef3b4211d20d22404ad8ef607 436 | MapboxMaps: e4c4620a76b9e26a5d6cae10ffee5681a135b3de 437 | MapboxMobileEvents: 14d7ac3ee95b4142c4fec2205dfd48ff453e8871 438 | MapboxNavigation: ae52148971b92fd0b5735b15db7f5b1feb13906f 439 | MapboxNavigationNative: 5319134183246da72d3ad7f4d4089452ce450167 440 | MapboxSpeech: e4ed02984444b6373374c72c369edaf045cc490c 441 | Polyline: fce41d72e1146c41c6d081f7656827226f643dff 442 | RCT-Folly: a21c126816d8025b547704b777a2ba552f3d9fa9 443 | RCTRequired: 4bf86c70714490bca4bf2696148638284622644b 444 | RCTTypeSafety: c475a7059eb77935fa53d2c17db299893f057d5d 445 | React: f64af14e3f2c50f6f2c91a5fd250e4ff1b3c3459 446 | React-callinvoker: b74e4ae80287780dcdf0cab262bcb581eeef56e7 447 | React-Core: 3eb7432bad96ff1d25aebc1defbae013fee2fd0e 448 | React-CoreModules: ad9e1fd5650e16666c57a08328df86fd7e480cb9 449 | React-cxxreact: 02633ff398cf7e91a2c1e12590d323c4a4b8668a 450 | React-jsi: 805c41a927d6499fb811772acb971467d9204633 451 | React-jsiexecutor: 94ce921e1d8ce7023366873ec371f3441383b396 452 | React-jsinspector: d0374f7509d407d2264168b6d0fad0b54e300b85 453 | React-logger: 933f80c97c633ee8965d609876848148e3fef438 454 | react-native-mapbox-navigation: 0966e03abd15664a2255a40f315c91e109a8a054 455 | React-perflogger: 93075d8931c32cd1fce8a98c15d2d5ccc4d891bd 456 | React-RCTActionSheet: 7d3041e6761b4f3044a37079ddcb156575fb6d89 457 | React-RCTAnimation: 743e88b55ac62511ae5c2e22803d4f503f2a3a13 458 | React-RCTBlob: bee3a2f98fa7fc25c957c8643494244f74bea0a0 459 | React-RCTImage: 19fc9e29b06cc38611c553494f8d3040bf78c24e 460 | React-RCTLinking: dc799503979c8c711126d66328e7ce8f25c2848f 461 | React-RCTNetwork: 417e4e34cf3c19eaa5fd4e9eb20180d662a799ce 462 | React-RCTSettings: 4df89417265af26501a7e0e9192a34d3d9848dff 463 | React-RCTText: f8a21c3499ab322326290fa9b701ae29aa093aa5 464 | React-RCTVibration: e3ffca672dd3772536cb844274094b0e2c31b187 465 | React-runtimeexecutor: dec32ee6f2e2a26e13e58152271535fadff5455a 466 | ReactCommon: 57b69f6383eafcbd7da625bfa6003810332313c4 467 | Solar-dev: 4612dc9878b9fed2667d23b327f1d4e54e16e8d0 468 | Turf: 1a6bc2d0142f84610445159565c3c93d62b83897 469 | Yoga: e7dc4e71caba6472ff48ad7d234389b91dadc280 470 | 471 | PODFILE CHECKSUM: b825e0c0c2130ea0c4924baa443a786ab3686731 472 | 473 | COCOAPODS: 1.11.2 474 | -------------------------------------------------------------------------------- /example/metro.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Metro configuration for React Native 3 | * https://github.com/facebook/react-native 4 | * 5 | * @format 6 | */ 7 | 8 | const path = require('path'); 9 | const blacklist = require('metro-config/src/defaults/exclusionList'); 10 | const escape = require('escape-string-regexp'); 11 | const pak = require('../package.json'); 12 | 13 | const root = path.resolve(__dirname, '../'); 14 | 15 | const modules = Object.keys({ 16 | ...pak.peerDependencies, 17 | }); 18 | 19 | module.exports = { 20 | projectRoot: __dirname, 21 | watchFolders: [root], 22 | 23 | // We need to make sure that only one version is loaded for peerDependencies 24 | // So we blacklist them at the root, and alias them to the versions in example's node_modules 25 | resolver: { 26 | blacklistRE: blacklist( 27 | modules.map( 28 | m => new RegExp(`^${escape(path.join(root, 'node_modules', m))}\\/.*$`), 29 | ), 30 | ), 31 | 32 | extraNodeModules: modules.reduce((acc, name) => { 33 | acc[name] = path.join(__dirname, 'node_modules', name); 34 | return acc; 35 | }, {}), 36 | }, 37 | transformer: { 38 | getTransformOptions: async () => ({ 39 | transform: { 40 | experimentalImportSupport: false, 41 | inlineRequires: true, 42 | }, 43 | }), 44 | }, 45 | }; 46 | -------------------------------------------------------------------------------- /example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "basicapp", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "android": "react-native run-android", 7 | "ios": "react-native run-ios", 8 | "start": "react-native start", 9 | "test": "jest", 10 | "lint": "eslint ." 11 | }, 12 | "dependencies": { 13 | "react": "17.0.2", 14 | "react-native": "0.66.4" 15 | }, 16 | "devDependencies": { 17 | "@babel/core": "^7.12.9", 18 | "@babel/runtime": "^7.12.5", 19 | "@react-native-community/eslint-config": "^2.0.0", 20 | "babel-jest": "^26.6.3", 21 | "babel-plugin-module-resolver": "^4.1.0", 22 | "eslint": "7.14.0", 23 | "glob-to-regexp": "^0.4.1", 24 | "jest": "^26.6.3", 25 | "metro-react-native-babel-preset": "^0.66.2", 26 | "react-test-renderer": "17.0.2" 27 | }, 28 | "jest": { 29 | "preset": "react-native" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /img/bridging-header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/homeeondemand/react-native-mapbox-navigation/d0f729ce8665020145be7024c50bc3867e21001d/img/bridging-header.png -------------------------------------------------------------------------------- /img/build-setting-linking.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/homeeondemand/react-native-mapbox-navigation/d0f729ce8665020145be7024c50bc3867e21001d/img/build-setting-linking.png -------------------------------------------------------------------------------- /img/build-setting-path.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/homeeondemand/react-native-mapbox-navigation/d0f729ce8665020145be7024c50bc3867e21001d/img/build-setting-path.png -------------------------------------------------------------------------------- /img/ios-nav.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/homeeondemand/react-native-mapbox-navigation/d0f729ce8665020145be7024c50bc3867e21001d/img/ios-nav.png -------------------------------------------------------------------------------- /ios/MapboxNavigation-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "React/RCTBridgeModule.h" 2 | #import "React/RCTViewManager.h" 3 | #import "React/RCTEventEmitter.h" 4 | -------------------------------------------------------------------------------- /ios/MapboxNavigation.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 957B881A244753D70058C6C1 /* MapboxNavigationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 957B8816244753D70058C6C1 /* MapboxNavigationView.swift */; }; 11 | 957B881C244753D70058C6C1 /* MapboxNavigationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 957B8818244753D70058C6C1 /* MapboxNavigationManager.m */; }; 12 | 957B881D244753D70058C6C1 /* MapboxNavigationManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 957B8819244753D70058C6C1 /* MapboxNavigationManager.swift */; }; 13 | /* End PBXBuildFile section */ 14 | 15 | /* Begin PBXCopyFilesBuildPhase section */ 16 | 58B511D91A9E6C8500147676 /* CopyFiles */ = { 17 | isa = PBXCopyFilesBuildPhase; 18 | buildActionMask = 2147483647; 19 | dstPath = "include/$(PRODUCT_NAME)"; 20 | dstSubfolderSpec = 16; 21 | files = ( 22 | ); 23 | runOnlyForDeploymentPostprocessing = 0; 24 | }; 25 | /* End PBXCopyFilesBuildPhase section */ 26 | 27 | /* Begin PBXFileReference section */ 28 | 134814201AA4EA6300B7C361 /* libMapboxNavigation.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libMapboxNavigation.a; sourceTree = BUILT_PRODUCTS_DIR; }; 29 | 957B8815244753D60058C6C1 /* MapboxNavigation-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MapboxNavigation-Bridging-Header.h"; sourceTree = ""; }; 30 | 957B8816244753D70058C6C1 /* MapboxNavigationView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MapboxNavigationView.swift; sourceTree = ""; }; 31 | 957B8818244753D70058C6C1 /* MapboxNavigationManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MapboxNavigationManager.m; sourceTree = ""; }; 32 | 957B8819244753D70058C6C1 /* MapboxNavigationManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MapboxNavigationManager.swift; sourceTree = ""; }; 33 | /* End PBXFileReference section */ 34 | 35 | /* Begin PBXFrameworksBuildPhase section */ 36 | 58B511D81A9E6C8500147676 /* Frameworks */ = { 37 | isa = PBXFrameworksBuildPhase; 38 | buildActionMask = 2147483647; 39 | files = ( 40 | ); 41 | runOnlyForDeploymentPostprocessing = 0; 42 | }; 43 | /* End PBXFrameworksBuildPhase section */ 44 | 45 | /* Begin PBXGroup section */ 46 | 134814211AA4EA7D00B7C361 /* Products */ = { 47 | isa = PBXGroup; 48 | children = ( 49 | 134814201AA4EA6300B7C361 /* libMapboxNavigation.a */, 50 | ); 51 | name = Products; 52 | sourceTree = ""; 53 | }; 54 | 58B511D21A9E6C8500147676 = { 55 | isa = PBXGroup; 56 | children = ( 57 | 957B8818244753D70058C6C1 /* MapboxNavigationManager.m */, 58 | 957B8819244753D70058C6C1 /* MapboxNavigationManager.swift */, 59 | 957B8816244753D70058C6C1 /* MapboxNavigationView.swift */, 60 | 957B8815244753D60058C6C1 /* MapboxNavigation-Bridging-Header.h */, 61 | 134814211AA4EA7D00B7C361 /* Products */, 62 | ); 63 | sourceTree = ""; 64 | }; 65 | /* End PBXGroup section */ 66 | 67 | /* Begin PBXNativeTarget section */ 68 | 58B511DA1A9E6C8500147676 /* MapboxNavigation */ = { 69 | isa = PBXNativeTarget; 70 | buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "MapboxNavigation" */; 71 | buildPhases = ( 72 | 58B511D71A9E6C8500147676 /* Sources */, 73 | 58B511D81A9E6C8500147676 /* Frameworks */, 74 | 58B511D91A9E6C8500147676 /* CopyFiles */, 75 | ); 76 | buildRules = ( 77 | ); 78 | dependencies = ( 79 | ); 80 | name = MapboxNavigation; 81 | productName = RCTDataManager; 82 | productReference = 134814201AA4EA6300B7C361 /* libMapboxNavigation.a */; 83 | productType = "com.apple.product-type.library.static"; 84 | }; 85 | /* End PBXNativeTarget section */ 86 | 87 | /* Begin PBXProject section */ 88 | 58B511D31A9E6C8500147676 /* Project object */ = { 89 | isa = PBXProject; 90 | attributes = { 91 | LastUpgradeCheck = 0920; 92 | ORGANIZATIONNAME = Facebook; 93 | TargetAttributes = { 94 | 58B511DA1A9E6C8500147676 = { 95 | CreatedOnToolsVersion = 6.1.1; 96 | LastSwiftMigration = 1140; 97 | }; 98 | }; 99 | }; 100 | buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "MapboxNavigation" */; 101 | compatibilityVersion = "Xcode 3.2"; 102 | developmentRegion = English; 103 | hasScannedForEncodings = 0; 104 | knownRegions = ( 105 | English, 106 | en, 107 | ); 108 | mainGroup = 58B511D21A9E6C8500147676; 109 | productRefGroup = 58B511D21A9E6C8500147676; 110 | projectDirPath = ""; 111 | projectRoot = ""; 112 | targets = ( 113 | 58B511DA1A9E6C8500147676 /* MapboxNavigation */, 114 | ); 115 | }; 116 | /* End PBXProject section */ 117 | 118 | /* Begin PBXSourcesBuildPhase section */ 119 | 58B511D71A9E6C8500147676 /* Sources */ = { 120 | isa = PBXSourcesBuildPhase; 121 | buildActionMask = 2147483647; 122 | files = ( 123 | 957B881C244753D70058C6C1 /* MapboxNavigationManager.m in Sources */, 124 | 957B881D244753D70058C6C1 /* MapboxNavigationManager.swift in Sources */, 125 | 957B881A244753D70058C6C1 /* MapboxNavigationView.swift in Sources */, 126 | ); 127 | runOnlyForDeploymentPostprocessing = 0; 128 | }; 129 | /* End PBXSourcesBuildPhase section */ 130 | 131 | /* Begin XCBuildConfiguration section */ 132 | 58B511ED1A9E6C8500147676 /* Debug */ = { 133 | isa = XCBuildConfiguration; 134 | buildSettings = { 135 | ALWAYS_SEARCH_USER_PATHS = NO; 136 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 137 | CLANG_CXX_LIBRARY = "libc++"; 138 | CLANG_ENABLE_MODULES = YES; 139 | CLANG_ENABLE_OBJC_ARC = YES; 140 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 141 | CLANG_WARN_BOOL_CONVERSION = YES; 142 | CLANG_WARN_COMMA = YES; 143 | CLANG_WARN_CONSTANT_CONVERSION = YES; 144 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 145 | CLANG_WARN_EMPTY_BODY = YES; 146 | CLANG_WARN_ENUM_CONVERSION = YES; 147 | CLANG_WARN_INFINITE_RECURSION = YES; 148 | CLANG_WARN_INT_CONVERSION = YES; 149 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 150 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 151 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 152 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 153 | CLANG_WARN_STRICT_PROTOTYPES = YES; 154 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 155 | CLANG_WARN_UNREACHABLE_CODE = YES; 156 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 157 | COPY_PHASE_STRIP = NO; 158 | ENABLE_STRICT_OBJC_MSGSEND = YES; 159 | ENABLE_TESTABILITY = YES; 160 | GCC_C_LANGUAGE_STANDARD = gnu99; 161 | GCC_DYNAMIC_NO_PIC = NO; 162 | GCC_NO_COMMON_BLOCKS = YES; 163 | GCC_OPTIMIZATION_LEVEL = 0; 164 | GCC_PREPROCESSOR_DEFINITIONS = ( 165 | "DEBUG=1", 166 | "$(inherited)", 167 | ); 168 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 169 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 170 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 171 | GCC_WARN_UNDECLARED_SELECTOR = YES; 172 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 173 | GCC_WARN_UNUSED_FUNCTION = YES; 174 | GCC_WARN_UNUSED_VARIABLE = YES; 175 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 176 | MTL_ENABLE_DEBUG_INFO = YES; 177 | ONLY_ACTIVE_ARCH = YES; 178 | SDKROOT = iphoneos; 179 | }; 180 | name = Debug; 181 | }; 182 | 58B511EE1A9E6C8500147676 /* Release */ = { 183 | isa = XCBuildConfiguration; 184 | buildSettings = { 185 | ALWAYS_SEARCH_USER_PATHS = NO; 186 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 187 | CLANG_CXX_LIBRARY = "libc++"; 188 | CLANG_ENABLE_MODULES = YES; 189 | CLANG_ENABLE_OBJC_ARC = YES; 190 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 191 | CLANG_WARN_BOOL_CONVERSION = YES; 192 | CLANG_WARN_COMMA = YES; 193 | CLANG_WARN_CONSTANT_CONVERSION = YES; 194 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 195 | CLANG_WARN_EMPTY_BODY = YES; 196 | CLANG_WARN_ENUM_CONVERSION = YES; 197 | CLANG_WARN_INFINITE_RECURSION = YES; 198 | CLANG_WARN_INT_CONVERSION = YES; 199 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 200 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 201 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 202 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 203 | CLANG_WARN_STRICT_PROTOTYPES = YES; 204 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 205 | CLANG_WARN_UNREACHABLE_CODE = YES; 206 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 207 | COPY_PHASE_STRIP = YES; 208 | ENABLE_NS_ASSERTIONS = NO; 209 | ENABLE_STRICT_OBJC_MSGSEND = YES; 210 | GCC_C_LANGUAGE_STANDARD = gnu99; 211 | GCC_NO_COMMON_BLOCKS = YES; 212 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 213 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 214 | GCC_WARN_UNDECLARED_SELECTOR = YES; 215 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 216 | GCC_WARN_UNUSED_FUNCTION = YES; 217 | GCC_WARN_UNUSED_VARIABLE = YES; 218 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 219 | MTL_ENABLE_DEBUG_INFO = NO; 220 | SDKROOT = iphoneos; 221 | VALIDATE_PRODUCT = YES; 222 | }; 223 | name = Release; 224 | }; 225 | 58B511F01A9E6C8500147676 /* Debug */ = { 226 | isa = XCBuildConfiguration; 227 | buildSettings = { 228 | CLANG_ENABLE_MODULES = YES; 229 | HEADER_SEARCH_PATHS = ( 230 | "$(inherited)", 231 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 232 | "$(SRCROOT)/../../../React/**", 233 | "$(SRCROOT)/../../react-native/React/**", 234 | ); 235 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 236 | LIBRARY_SEARCH_PATHS = "$(inherited)"; 237 | OTHER_LDFLAGS = "-ObjC"; 238 | PRODUCT_NAME = MapboxNavigation; 239 | SKIP_INSTALL = YES; 240 | SWIFT_OBJC_BRIDGING_HEADER = "MapboxNavigation-Bridging-Header.h"; 241 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 242 | SWIFT_VERSION = 5.0; 243 | }; 244 | name = Debug; 245 | }; 246 | 58B511F11A9E6C8500147676 /* Release */ = { 247 | isa = XCBuildConfiguration; 248 | buildSettings = { 249 | CLANG_ENABLE_MODULES = YES; 250 | HEADER_SEARCH_PATHS = ( 251 | "$(inherited)", 252 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 253 | "$(SRCROOT)/../../../React/**", 254 | "$(SRCROOT)/../../react-native/React/**", 255 | ); 256 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 257 | LIBRARY_SEARCH_PATHS = "$(inherited)"; 258 | OTHER_LDFLAGS = "-ObjC"; 259 | PRODUCT_NAME = MapboxNavigation; 260 | SKIP_INSTALL = YES; 261 | SWIFT_OBJC_BRIDGING_HEADER = "MapboxNavigation-Bridging-Header.h"; 262 | SWIFT_VERSION = 5.0; 263 | }; 264 | name = Release; 265 | }; 266 | /* End XCBuildConfiguration section */ 267 | 268 | /* Begin XCConfigurationList section */ 269 | 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "MapboxNavigation" */ = { 270 | isa = XCConfigurationList; 271 | buildConfigurations = ( 272 | 58B511ED1A9E6C8500147676 /* Debug */, 273 | 58B511EE1A9E6C8500147676 /* Release */, 274 | ); 275 | defaultConfigurationIsVisible = 0; 276 | defaultConfigurationName = Release; 277 | }; 278 | 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "MapboxNavigation" */ = { 279 | isa = XCConfigurationList; 280 | buildConfigurations = ( 281 | 58B511F01A9E6C8500147676 /* Debug */, 282 | 58B511F11A9E6C8500147676 /* Release */, 283 | ); 284 | defaultConfigurationIsVisible = 0; 285 | defaultConfigurationName = Release; 286 | }; 287 | /* End XCConfigurationList section */ 288 | }; 289 | rootObject = 58B511D31A9E6C8500147676 /* Project object */; 290 | } 291 | -------------------------------------------------------------------------------- /ios/MapboxNavigation.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/MapboxNavigation.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/MapboxNavigationManager.m: -------------------------------------------------------------------------------- 1 | #import "React/RCTViewManager.h" 2 | 3 | @interface RCT_EXTERN_MODULE(MapboxNavigationManager, RCTViewManager) 4 | 5 | RCT_EXPORT_VIEW_PROPERTY(onLocationChange, RCTDirectEventBlock) 6 | RCT_EXPORT_VIEW_PROPERTY(onRouteProgressChange, RCTDirectEventBlock) 7 | RCT_EXPORT_VIEW_PROPERTY(onError, RCTDirectEventBlock) 8 | RCT_EXPORT_VIEW_PROPERTY(onCancelNavigation, RCTDirectEventBlock) 9 | RCT_EXPORT_VIEW_PROPERTY(onArrive, RCTDirectEventBlock) 10 | RCT_EXPORT_VIEW_PROPERTY(origin, NSArray) 11 | RCT_EXPORT_VIEW_PROPERTY(destination, NSArray) 12 | RCT_EXPORT_VIEW_PROPERTY(shouldSimulateRoute, BOOL) 13 | RCT_EXPORT_VIEW_PROPERTY(showsEndOfRouteFeedback, BOOL) 14 | RCT_EXPORT_VIEW_PROPERTY(hideStatusView, BOOL) 15 | RCT_EXPORT_VIEW_PROPERTY(mute, BOOL) 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /ios/MapboxNavigationManager.swift: -------------------------------------------------------------------------------- 1 | @objc(MapboxNavigationManager) 2 | class MapboxNavigationManager: RCTViewManager { 3 | override func view() -> UIView! { 4 | return MapboxNavigationView(); 5 | } 6 | 7 | override static func requiresMainQueueSetup() -> Bool { 8 | return true 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /ios/MapboxNavigationView.swift: -------------------------------------------------------------------------------- 1 | import MapboxCoreNavigation 2 | import MapboxNavigation 3 | import MapboxDirections 4 | 5 | // // adapted from https://pspdfkit.com/blog/2017/native-view-controllers-and-react-native/ and https://github.com/mslabenyak/react-native-mapbox-navigation/blob/master/ios/Mapbox/MapboxNavigationView.swift 6 | extension UIView { 7 | var parentViewController: UIViewController? { 8 | var parentResponder: UIResponder? = self 9 | while parentResponder != nil { 10 | parentResponder = parentResponder!.next 11 | if let viewController = parentResponder as? UIViewController { 12 | return viewController 13 | } 14 | } 15 | return nil 16 | } 17 | } 18 | 19 | class MapboxNavigationView: UIView, NavigationViewControllerDelegate { 20 | weak var navViewController: NavigationViewController? 21 | var embedded: Bool 22 | var embedding: Bool 23 | 24 | @objc var origin: NSArray = [] { 25 | didSet { setNeedsLayout() } 26 | } 27 | 28 | @objc var destination: NSArray = [] { 29 | didSet { setNeedsLayout() } 30 | } 31 | 32 | @objc var shouldSimulateRoute: Bool = false 33 | @objc var showsEndOfRouteFeedback: Bool = false 34 | @objc var hideStatusView: Bool = false 35 | @objc var mute: Bool = false 36 | 37 | @objc var onLocationChange: RCTDirectEventBlock? 38 | @objc var onRouteProgressChange: RCTDirectEventBlock? 39 | @objc var onError: RCTDirectEventBlock? 40 | @objc var onCancelNavigation: RCTDirectEventBlock? 41 | @objc var onArrive: RCTDirectEventBlock? 42 | 43 | override init(frame: CGRect) { 44 | self.embedded = false 45 | self.embedding = false 46 | super.init(frame: frame) 47 | } 48 | 49 | required init?(coder aDecoder: NSCoder) { 50 | fatalError("init(coder:) has not been implemented") 51 | } 52 | 53 | override func layoutSubviews() { 54 | super.layoutSubviews() 55 | 56 | if (navViewController == nil && !embedding && !embedded) { 57 | embed() 58 | } else { 59 | navViewController?.view.frame = bounds 60 | } 61 | } 62 | 63 | override func removeFromSuperview() { 64 | super.removeFromSuperview() 65 | // cleanup and teardown any existing resources 66 | self.navViewController?.removeFromParent() 67 | } 68 | 69 | private func embed() { 70 | guard origin.count == 2 && destination.count == 2 else { return } 71 | 72 | embedding = true 73 | 74 | let originWaypoint = Waypoint(coordinate: CLLocationCoordinate2D(latitude: origin[1] as! CLLocationDegrees, longitude: origin[0] as! CLLocationDegrees)) 75 | let destinationWaypoint = Waypoint(coordinate: CLLocationCoordinate2D(latitude: destination[1] as! CLLocationDegrees, longitude: destination[0] as! CLLocationDegrees)) 76 | 77 | // let options = NavigationRouteOptions(waypoints: [originWaypoint, destinationWaypoint]) 78 | let options = NavigationRouteOptions(waypoints: [originWaypoint, destinationWaypoint], profileIdentifier: .automobileAvoidingTraffic) 79 | 80 | Directions.shared.calculate(options) { [weak self] (_, result) in 81 | guard let strongSelf = self, let parentVC = strongSelf.parentViewController else { 82 | return 83 | } 84 | 85 | switch result { 86 | case .failure(let error): 87 | strongSelf.onError!(["message": error.localizedDescription]) 88 | case .success(let response): 89 | guard let weakSelf = self else { 90 | return 91 | } 92 | 93 | let navigationService = MapboxNavigationService(routeResponse: response, routeIndex: 0, routeOptions: options, simulating: strongSelf.shouldSimulateRoute ? .always : .never) 94 | 95 | let navigationOptions = NavigationOptions(navigationService: navigationService) 96 | let vc = NavigationViewController(for: response, routeIndex: 0, routeOptions: options, navigationOptions: navigationOptions) 97 | 98 | vc.showsEndOfRouteFeedback = strongSelf.showsEndOfRouteFeedback 99 | StatusView.appearance().isHidden = strongSelf.hideStatusView 100 | 101 | NavigationSettings.shared.voiceMuted = strongSelf.mute; 102 | 103 | vc.delegate = strongSelf 104 | 105 | parentVC.addChild(vc) 106 | strongSelf.addSubview(vc.view) 107 | vc.view.frame = strongSelf.bounds 108 | vc.didMove(toParent: parentVC) 109 | strongSelf.navViewController = vc 110 | } 111 | 112 | strongSelf.embedding = false 113 | strongSelf.embedded = true 114 | } 115 | } 116 | 117 | func navigationViewController(_ navigationViewController: NavigationViewController, didUpdate progress: RouteProgress, with location: CLLocation, rawLocation: CLLocation) { 118 | onLocationChange?(["longitude": location.coordinate.longitude, "latitude": location.coordinate.latitude]) 119 | onRouteProgressChange?(["distanceTraveled": progress.distanceTraveled, 120 | "durationRemaining": progress.durationRemaining, 121 | "fractionTraveled": progress.fractionTraveled, 122 | "distanceRemaining": progress.distanceRemaining]) 123 | } 124 | 125 | func navigationViewControllerDidDismiss(_ navigationViewController: NavigationViewController, byCanceling canceled: Bool) { 126 | if (!canceled) { 127 | return; 128 | } 129 | onCancelNavigation?(["message": ""]); 130 | } 131 | 132 | func navigationViewController(_ navigationViewController: NavigationViewController, didArriveAt waypoint: Waypoint) -> Bool { 133 | onArrive?(["message": ""]); 134 | return true; 135 | } 136 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@homee/react-native-mapbox-navigation", 3 | "title": "React Native Mapbox Navigation", 4 | "version": "2.0.1", 5 | "description": "Smart Mapbox turn-by-turn routing based on real-time traffic for React Native.", 6 | "main": "dist/index.js", 7 | "types": "dist/index.d.ts", 8 | "source": "src/index", 9 | "scripts": { 10 | "prepublishOnly": "tsc", 11 | "test": "echo \"Error: no test specified\" && exit 1" 12 | }, 13 | "repository": { 14 | "type": "git", 15 | "url": "git+https://github.com/homeeondemand/react-native-mapbox-navigation.git", 16 | "baseUrl": "https://github.com/homeeondemand/react-native-mapbox-navigation.git" 17 | }, 18 | "keywords": [ 19 | "react-native", 20 | "mapbox", 21 | "navigation" 22 | ], 23 | "license": "MIT", 24 | "licenseFilename": "LICENSE", 25 | "readmeFilename": "README.md", 26 | "bugs": { 27 | "url": "https://github.com/homeeondemand/react-native-mapbox-navigation/issues" 28 | }, 29 | "homepage": "https://github.com/homeeondemand/react-native-mapbox-navigation#readme", 30 | "peerDependencies": { 31 | "react": "*", 32 | "react-native": "*" 33 | }, 34 | "devDependencies": { 35 | "react": "17.0.2", 36 | "react-native": "0.66.4", 37 | "typescript": "4.3.5" 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /react-native-mapbox-navigation.podspec: -------------------------------------------------------------------------------- 1 | require "json" 2 | 3 | package = JSON.parse(File.read(File.join(__dir__, "package.json"))) 4 | 5 | # TargetsToChangeToDynamic = ['MapboxMobileEvents'] 6 | TargetsToChangeToDynamic = [] 7 | 8 | $RNMBNAV = Object.new 9 | 10 | def $RNMBNAV.post_install(installer) 11 | installer.pod_targets.each do |pod| 12 | if TargetsToChangeToDynamic.include?(pod.name) 13 | if pod.send(:build_type) != Pod::BuildType.dynamic_framework 14 | pod.instance_variable_set(:@build_type,Pod::BuildType.dynamic_framework) 15 | puts "* Changed #{pod.name} to `#{pod.send(:build_type)}`" 16 | fail "Unable to change build_type" unless mobile_events_target.send(:build_type) == Pod::BuildType.dynamic_framework 17 | end 18 | end 19 | end 20 | end 21 | 22 | def $RNMBNAV.pre_install(installer) 23 | installer.aggregate_targets.each do |target| 24 | target.pod_targets.select { |p| TargetsToChangeToDynamic.include?(p.name) }.each do |mobile_events_target| 25 | mobile_events_target.instance_variable_set(:@build_type,Pod::BuildType.dynamic_framework) 26 | puts "* Changed #{mobile_events_target.name} to #{mobile_events_target.send(:build_type)}" 27 | fail "Unable to change build_type" unless mobile_events_target.send(:build_type) == Pod::BuildType.dynamic_framework 28 | end 29 | end 30 | end 31 | 32 | Pod::Spec.new do |s| 33 | s.name = "react-native-mapbox-navigation" 34 | s.version = package["version"] 35 | s.summary = package["description"] 36 | s.description = <<-DESC 37 | Smart Mapbox turn-by-turn routing based on real-time traffic for React Native. 38 | DESC 39 | s.homepage = "https://github.com/homeeondemand/react-native-mapbox-navigation" 40 | s.license = { :type => "MIT", :file => "LICENSE" } 41 | s.authors = { "HOMEE" => "support@homee.com" } 42 | s.platforms = { :ios => "11.0" } 43 | s.source = { :git => "https://github.com/homeeondemand/react-native-mapbox-navigation.git", :tag => "#{s.version}" } 44 | 45 | s.source_files = "ios/**/*.{h,m,swift}" 46 | s.requires_arc = true 47 | 48 | s.dependency "React-Core" 49 | s.dependency "MapboxNavigation", "~> 2.1.1" 50 | end 51 | 52 | -------------------------------------------------------------------------------- /src/index.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import { requireNativeComponent, StyleSheet } from 'react-native'; 3 | 4 | import { IMapboxNavigationProps } from './typings'; 5 | 6 | const MapboxNavigation = (props: IMapboxNavigationProps) => { 7 | return ; 8 | }; 9 | 10 | const RNMapboxNavigation = requireNativeComponent( 11 | 'MapboxNavigation', 12 | MapboxNavigation 13 | ); 14 | 15 | const styles = StyleSheet.create({ 16 | container: { 17 | flex: 1, 18 | }, 19 | }); 20 | 21 | export default MapboxNavigation; 22 | -------------------------------------------------------------------------------- /src/typings.ts: -------------------------------------------------------------------------------- 1 | /** @type {[number, number]} 2 | * Provide an array with longitude and latitude [$longitude, $latitude] 3 | */ 4 | type Coordinate = [number, number]; 5 | 6 | type OnLocationChangeEvent = { 7 | nativeEvent?: { 8 | latitude: number; 9 | longitude: number; 10 | }; 11 | }; 12 | 13 | type OnRouteProgressChangeEvent = { 14 | nativeEvent?: { 15 | distanceTraveled: number; 16 | durationRemaining: number; 17 | fractionTraveled: number; 18 | distanceRemaining: number; 19 | }; 20 | }; 21 | 22 | type OnErrorEvent = { 23 | nativeEvent?: { 24 | message?: string; 25 | }; 26 | }; 27 | 28 | export interface IMapboxNavigationProps { 29 | origin: Coordinate; 30 | destination: Coordinate; 31 | shouldSimulateRoute?: boolean; 32 | onLocationChange?: (event: OnLocationChangeEvent) => void; 33 | onRouteProgressChange?: (event: OnRouteProgressChangeEvent) => void; 34 | onError?: (event: OnErrorEvent) => void; 35 | onCancelNavigation?: () => void; 36 | onArrive?: () => void; 37 | showsEndOfRouteFeedback?: boolean; 38 | hideStatusView?: boolean; 39 | mute?: boolean; 40 | } 41 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "es6", 5 | "declaration": true, 6 | "outDir": "./dist", 7 | "strict": false, 8 | "jsx": "react-native", 9 | "skipLibCheck": true, 10 | "moduleResolution": "node" 11 | }, 12 | "include": ["src"], 13 | "exclude": ["node_modules", "**/__tests__/*", "example"] 14 | } 15 | --------------------------------------------------------------------------------