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
135 changes: 135 additions & 0 deletions MIGRATING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# Migration Guide

This document covers breaking changes and migration steps between major versions of `@googlemaps/react-native-driver-sdk`.

## Table of Contents

- [Migrating from 0.4.x to 0.5.x](#migrating-from-04x-to-05x)

---

## Migrating from 0.4.x to 0.5.x

Version 0.5.0 introduces React Native's **New Architecture** (TurboModules) as a requirement, dropping support for the legacy architecture. This release upgrades the underlying `@googlemaps/react-native-navigation-sdk` to 0.15.x which also requires the New Architecture.

### Summary of Breaking Changes

| Category | Change |
| -------------- | -------------------------------------------------------------------------------------- |
| Architecture | New Architecture required (React Native 0.79+) |
| Navigation SDK | Upgraded to `@googlemaps/react-native-navigation-sdk` 0.15.x (New Architecture) |
| Native Modules | Migrated from `NativeModules` bridge to TurboModules (JSI) |
| React Native | Support for React Native versions below 0.79.x has been dropped |

### Prerequisites

- **React Native 0.79 or higher** is required
- **New Architecture must be enabled** in your project

### Step 1: Enable New Architecture

#### Android

Update `android/gradle.properties`:

```diff
- newArchEnabled=false
+ newArchEnabled=true
```

#### iOS

Update `ios/Podfile`:

```diff
- ENV['RCT_NEW_ARCH_ENABLED'] = '0'
+ ENV['RCT_NEW_ARCH_ENABLED'] = '1'
```

Then reinstall pods:

```bash
cd ios && pod install
```

### Step 2: Migrate Navigation SDK Usage

The Driver SDK depends on `@googlemaps/react-native-navigation-sdk`, which has undergone significant breaking changes in its New Architecture upgrade. If your app uses any Navigation SDK APIs directly (e.g., `NavigationView`, `useNavigation`, navigation initialization, event listeners, or view callbacks), you **must** follow the Navigation SDK migration guide:

> **[Navigation SDK Migration Guide (0.13.x to 0.14.x)](https://github.com/googlemaps/react-native-navigation-sdk/blob/main/MIGRATING.md#migrating-from-013x-to-014x)**

> [!NOTE]
> Check the [Navigation SDK release notes](https://github.com/googlemaps/react-native-navigation-sdk/releases) for the full list of breaking changes and new features across versions.

Key changes in the Navigation SDK that may affect your app:

| Category | Change |
| --------------- | ------------------------------------------------------------------------------------------------ |
| Navigation Init | Terms and Conditions dialog and session initialization are now separate methods |
| Navigation Init | `init()` returns `NavigationSessionStatus` instead of throwing errors |
| Event Listeners | `addListeners`/`removeListeners` with callback objects replaced with individual setter functions |
| View Callbacks | `mapViewCallbacks` and `navigationViewCallbacks` replaced with individual callback props |
| View Props | UI settings moved from controller methods to declarative view props |
| Route Status | `onRouteStatusResult` removed; use `await setDestination()` / `await setDestinations()` instead |
| Color API | All color properties now support React Native's `ColorValue` type |

### Step 3: Update Driver SDK Module Imports (If Using Native Modules Directly)

The native modules have been migrated from the React Native bridge (`NativeModules`) to TurboModules. If you only use the TypeScript API (`DeliveryDriverApi`, `RidesharingDriverApi`), no changes are needed — the migration is handled internally.

If you were accessing native modules directly:

#### Before (0.4.x)

```tsx
import { NativeModules, Platform } from 'react-native';

const DeliveryModule = NativeModules.DeliveryDriverModule;

// Ridesharing had platform-specific module names
const RidesharingModule = Platform.OS === 'ios'
? NativeModules.RideSharingModule
: NativeModules.RidesharingModule;
```

#### After (0.5.x)

```tsx
// Native modules are now accessed via TurboModules internally.
// Use the public API classes instead of accessing native modules directly:
import {
DeliveryDriverApi,
RidesharingDriverApi,
} from '@googlemaps/react-native-driver-sdk';
```

> [!NOTE]
> The platform-specific module name difference for Ridesharing (`RideSharingModule` on iOS vs `RidesharingModule` on Android) has been unified under the TurboModule system.

### Step 4: Update Build Configuration

#### Android

Ensure your `android/build.gradle` uses compatible versions:

- **Android Gradle Plugin (AGP)**: 8.10.0 (recommended)
- **Gradle**: 8.11.1 (recommended)
- **compileSdk**: 36 or higher
- **targetSdk**: 36 or higher
- **minSdk**: 26 or higher

#### iOS

Ensure your `Podfile` specifies iOS 16.0+ as the deployment target:

```ruby
platform :ios, '16.0'
```

### Need Help?

If you encounter issues during migration:

1. Check the [example apps](./example) for complete working examples
2. Review the [Navigation SDK Migration Guide](https://github.com/googlemaps/react-native-navigation-sdk/blob/main/MIGRATING.md) for navigation-related changes
3. [File an issue](https://github.com/googlemaps/react-native-driver-sdk/issues) on GitHub
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ This is the beta release of the Google Driver SDK package for React Native. It i
## React Native Compatibility

> [!IMPORTANT]
> This package does not yet support React Native's new architecture. Make sure the new architecture is disabled in your project configuration as shown in the [Installation](#installation) section.
> This package requires React Native 0.79+ with the new architecture (TurboModules) enabled. Make sure the new architecture is enabled in your project configuration as shown in the [Installation](#installation) section.

> [!NOTE]
> For users upgrading from versions prior to 0.5.0, please refer to the [Migration Guide](./MIGRATING.md) for instructions on migrating to the new architecture.

## Installation

Expand Down Expand Up @@ -62,12 +65,12 @@ This is the beta release of the Google Driver SDK package for React Native. It i
### Android


#### Disable new architecture
#### Enable new architecture

This package does not yet support new architecture. Make sure new architecture is disabled in your `android/gradle.properties` file:
This package requires the new architecture. Make sure new architecture is enabled in your `android/gradle.properties` file:

```groovy
newArchEnabled=false
newArchEnabled=true
```

#### Enable Jetifier
Expand Down Expand Up @@ -121,12 +124,12 @@ See example configuration for secrets plugin at example applications [build.grad

### iOS

#### Disable new architecture
#### Enable new architecture

This package does not yet support new architecture. Make sure new architecture is disabled in your `ios/Podfile`:
This package requires the new architecture. Make sure new architecture is enabled in your `ios/Podfile`:

```ruby
ENV['RCT_NEW_ARCH_ENABLED'] = '0'
ENV['RCT_NEW_ARCH_ENABLED'] = '1'
```

#### Set Google Maps API Key
Expand Down
55 changes: 15 additions & 40 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,71 +12,47 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import groovy.json.JsonSlurper

buildscript {
ext.kotlin_version = '2.1.21'
repositories {
google()
mavenCentral()
}

dependencies {
classpath("com.android.tools.build:gradle:8.6.1")
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

def isNewArchitectureEnabled() {
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

apply plugin: 'com.android.library'

if (isNewArchitectureEnabled()) {
apply plugin: "com.facebook.react"
}
apply plugin: 'kotlin-android'
apply plugin: 'com.facebook.react'

android {
namespace "com.google.android.react.driversdk"

compileSdkVersion 36
compileSdk safeExtGet('compileSdkVersion', 35)

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
minSdkVersion 26
targetSdkVersion 36
versionCode 1
// get version name from package.json version
versionName "1.0"
minSdk safeExtGet('minSdkVersion', 26)
targetSdk safeExtGet('targetSdkVersion', 35)
}

buildTypes {
release {
minifyEnabled false
minifyEnabled false
}
}

lintOptions {
abortOnError false
disable "GradleCompatible"
}
}

allprojects {
// Required: you must exclude the Google Play service Maps SDK from
// your transitive dependencies. This is to ensure there won't be
// multiple copies of Google Maps SDK in your binary, as the Navigation
// SDK already bundles the Google Maps SDK.
configurations {
implementation {
exclude group: 'com.google.android.gms', module: 'play-services-maps'
sourceSets {
main {
java.srcDirs += [
"generated/java",
"generated/jni"
]
}
}
}
}

repositories {
Expand All @@ -87,7 +63,6 @@ repositories {
dependencies {
implementation 'com.google.android.libraries.mapsplatform.transportation:transportation-driver:7.0.0'
implementation 'com.facebook.react:react-native:+'
implementation 'com.android.support:multidex:1.0.3'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
api 'com.google.guava:guava:31.0.1-android'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,68 @@
*/
package com.google.android.react.driversdk;

import androidx.annotation.NonNull;
import com.facebook.react.ReactPackage;
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.BaseReactPackage;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.module.model.ReactModuleInfo;
import com.facebook.react.module.model.ReactModuleInfoProvider;
import com.facebook.react.uimanager.ViewManager;
import com.google.android.react.driversdk.lmfs.DeliveryDriverModule;
import com.google.android.react.driversdk.odrd.RidesharingModule;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@DoNotStrip
public class ReactNativeDriverSdkPackage extends BaseReactPackage {

public class ReactNativeDriverSdkPackage implements ReactPackage {
@NonNull
@Override
public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>();
modules.add(new RidesharingModule(reactContext));
modules.add(new DeliveryDriverModule(reactContext));
return modules;
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
return new ArrayList<>();
}

@NonNull
@Override
public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
return new ArrayList<>();
public NativeModule getModule(String name, ReactApplicationContext reactContext) {
switch (name) {
case RidesharingModule.REACT_CLASS:
return new RidesharingModule(reactContext);
case DeliveryDriverModule.REACT_CLASS:
return new DeliveryDriverModule(reactContext);
default:
return null;
}
}

@Override
public ReactModuleInfoProvider getReactModuleInfoProvider() {
return () -> {
Map<String, ReactModuleInfo> moduleInfos = new HashMap<>();

moduleInfos.put(
RidesharingModule.REACT_CLASS,
new ReactModuleInfo(
RidesharingModule.REACT_CLASS,
RidesharingModule.REACT_CLASS,
false, // canOverrideExistingModule
false, // needsEagerInit
false, // isCxxModule
true // isTurboModule
));

moduleInfos.put(
DeliveryDriverModule.REACT_CLASS,
new ReactModuleInfo(
DeliveryDriverModule.REACT_CLASS,
DeliveryDriverModule.REACT_CLASS,
false, // canOverrideExistingModule
false, // needsEagerInit
false, // isCxxModule
true // isTurboModule
));

return moduleInfos;
};
}
}
Loading
Loading