Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.pbxproj -text
# specific for windows script files
*.bat text eol=crlf
81 changes: 81 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# OSX
#
.DS_Store

# XDE
.expo/

# VSCode
.vscode/
jsconfig.json

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace
.xcode.env.local

# Android/IJ
#
.classpath
.cxx
.gradle
.idea
.project
.settings
local.properties
android.iml

# Cocoapods
#
example/**/ios/Pods
example/**/ios/Podfile.lock

# node.js
#
node_modules/
npm-debug.log
yarn-debug.log
yarn-error.log
package-lock.json

# BUCK
buck-out/
\.buckd/
android/app/libs
android/keystores/debug.keystore

# Yarn
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# Expo
.expo/

# Turborepo
.turbo/

# generated by bob
lib/

# tests
coverage/
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
example
coverage
node_modules
541 changes: 541 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

Large diffs are not rendered by default.

874 changes: 874 additions & 0 deletions .yarn/releases/yarn-3.6.1.cjs

Large diffs are not rendered by default.

16 changes: 11 additions & 5 deletions scripts/tsExpectErrorCommentsCount.sh → .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
#! bin/bash
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

grep -r '@ts-expect-error' -h ../components | # Find all lines containing "@ts-expect-error"
sed -E 's/^.*\/[*/] | \*\/|,//g' | # Remove whitespace and brackets
wc -l # Count number of lines
nodeLinker: node-modules
nmHoistingLimits: workspaces

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"

yarnPath: .yarn/releases/yarn-3.6.1.cjs
34 changes: 8 additions & 26 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ This project follows
- Linux, Mac OS X, or Windows.
- [git](https://git-scm.com) (used for source version control).
- An IDE such as [Android Studio](https://developer.android.com/studio) or [Visual Studio Code](https://code.visualstudio.com/).
- [addlicense](https://github.com/google/addlicense)

## 2. Forking & cloning the repository

Expand Down Expand Up @@ -72,27 +73,6 @@ To update the Javascript codes, edit the library files inside node_modules

Simply run the sample app to test your changes.

## Submitting changes

Copy your changes from the node_modules folder and paste it over to the root directory. Don't copy the entire contents of the node_modules, instead just copy the changes you made. This process can also be optimized with shell commands.

### Android

![rnProjectAndroid](/images/submit_android.png)


### iOS

Just copy the .m and .h files. There's no need to copy the .xcodeproj file unless new files are added to the library.

![rnProjectXcode](/images/submit_ios.png)


### Javacript

![rnProjectJS](/images/submit_javascript.png)


### Code reviews

All submissions, including submissions by project members, require review. We
Expand All @@ -113,14 +93,16 @@ keep the code consistent and avoid common pitfalls.

#### Commit changes

1. `git commit -a -m "<your informative commit message>"`
1. This project uses `lefthook` to ensure tests pass before committing. Please configure your environment paths to include the Go binary path for `addlicense` and the Node binary path for `npx` in the `~/.lefthookrc` file. For more information, refer to the [lefthook documentation](https://github.com/evilmartians/lefthook/blob/master/docs/configuration.md#rc).

2. `git commit -a -m "<your informative commit message>"`

Please make sure all your check-ins have detailed commit messages explaining the patch.
When naming the title of your pull request, please follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0-beta.4/) guide. For example, for a fix to the Driver library:
Please make sure all your check-ins have detailed commit messages explaining the patch.
When naming the title of your pull request, please follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0-beta.4/) guide. For example, for a fix to the Driver library:

`fix(navigation_view): fixed a bug!`
`fix: fixed a bug!`

2. `git push origin <name_of_your_branch>`
3. `git push origin <name_of_your_branch>`

#### Create pull request

Expand Down
118 changes: 70 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,23 @@ This is the beta release of the Google Driver SDK package for React Native. It i

1. To install the library run the following command from your project root:

`npm install --save https://github.com/googlemaps/react-native-driver-sdk#{version_tag}`
```bash
npm install --save https://github.com/googlemaps/react-native-driver-sdk#{version_tag}
```
or
```bash
yarn add https://github.com/googlemaps/react-native-driver-sdk#{version_tag}
```

1. Install the `@googlemaps/react-native-navigation-sdk` dependency:

```bash
npm install --save @googlemaps/react-native-navigation-sdk
```
or
```bash
yarn add @googlemaps/react-native-navigation-sdk
```

### Android

Expand All @@ -49,33 +65,40 @@ android {
### Ridesharing
#### Initializing the API

1. As mentioned above, this library depends on the React Native: NavigationSDK library. Specifically, it depends on the existence of a `NavigationView` component in the application. Please refer to the Navigation SDK [Sample app](https://github.com/googlemaps/react-native-navigation-sdk/tree/main/SampleApp) for all details on how to set up the navigation component.
1. As mentioned above, this library depends on the React Native: NavigationSDK library. Specifically, it depends on the existence of a `NavigationView` component in the application.

1. In your react-native component, import and instantiate the RidesharingDriverapi and reference it through variable.

```typescript
import RidesharingDriverapi from "react-native-driver-sdk/components/ridesharing/RidesharingDriverApi";

const ridesharing = new RidesharingDriverapi();
```

1. Second step is to initialize the Api. Make sure to capture the viewId associated to the `NavigationView` component prior to this as it's needed.

```typescript
await ridesharingDriverApi
.initialize(
PROVIDER_ID,
VEHICLE_ID,
navigationViewId,
(tokenContext) => {
// Check if the token is expired, in such case request a new one.
return Promise.resolve(authToken || "");
},
(statusLevel, statusCode, message) => {
console.log("onStatusUpdate: " + statusLevel + " " + statusCode + " " + message);
}
);
```
```typescript
import RidesharingDriverApi from "@googlemaps/react-native-driver-sdk";

const ridesharing = new RidesharingDriverapi();
```

2. Start navigation. Please refer to the Navigation SDK [Sample app](https://github.com/googlemaps/react-native-navigation-sdk/tree/main/example) for all details on how to set up the navigation component and its listeners.

```typescript
const { navigationController } = useNavigation();
...
await navigationController.init();
```

3. Second step is to initialize the Api. Navigation must be initialized before the Driver SDK is initialized.

```typescript
await ridesharingDriverApi
.initialize(
PROVIDER_ID,
VEHICLE_ID,
(tokenContext) => {
// Check if the token is expired, in such case request a new one.
return Promise.resolve(authToken || "");
},
(statusLevel, statusCode, message) => {
console.log("onStatusUpdate: " + statusLevel + " " + statusCode + " " + message);
}
);
```

Note: The `initialize` method takes a `onGetTokenCallback` field as parameter. This will be called periodically to ensure the token stays refresh while there's requests to Fleet Engine. Please make sure to check that the token is valid (e.g. checking expiration time) before setting it.

Expand All @@ -97,29 +120,28 @@ The vehicle reporter allows developers to enable/disable location reporting to F

1. In your react-native component, import and instantiate the RidesharingDriverapi and reference it through variable.

```typescript
import DeliveryDriverapi from "react-native-driver-sdk/components/delivery/DeliveryDriverapi";

const deliveryApi = new DeliveryDriverapi();
```

1. Second step is to initialize the Api. Make sure to capture the viewId associated to the `NavigationView` component prior to this as it's needed.

```typescript
await deliveryApi
.initialize(
PROVIDER_ID,
DELIVERY_VEHICLE_ID,
navigationViewId,
(tokenContext) => {
// Check if the token is expired, in such case request a new one.
return Promise.resolve(authToken || "");
},
(statusLevel, statusCode, message) => {
console.log("onStatusUpdate: " + statusLevel + " " + statusCode + " " + message);
}
);
```
```typescript
import DeliveryDriverApi from "@googlemaps/react-native-driver-sdk";

const deliveryApi = new DeliveryDriverapi();
```

2. Second step is to initialize the Api.

```typescript
await deliveryApi
.initialize(
PROVIDER_ID,
DELIVERY_VEHICLE_ID,
(tokenContext) => {
// Check if the token is expired, in such case request a new one.
return Promise.resolve(authToken || "");
},
(statusLevel, statusCode, message) => {
console.log("onStatusUpdate: " + statusLevel + " " + statusCode + " " + message);
}
);
```

Note: The `initialize` method takes a `onGetTokenCallback` field as parameter. This will be called periodically to ensure the token stays refresh while there's requests to Fleet Engine. Please make sure to check that the token is valid (e.g. checking expiration time) before setting it.

Expand Down
Loading