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
2 changes: 1 addition & 1 deletion CARPLAY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This guide explains how to enable and integrate Apple CarPlay with the React Nat

## Requirements

- iOS device or iOS simulator (iOS 15.0+)
- iOS device or iOS simulator (iOS 16.0+)
- CarPlay Simulator
- CarPlay entitlement for your application (provided by Apple)

Expand Down
28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This repository contains a React Native plugin that provides a [Google Navigatio

| | Android | iOS |
| ------------------------------- | ------- | --------- |
| **Minimum mobile OS supported** | SDK 23+ | iOS 15.0+ |
| **Minimum mobile OS supported** | SDK 23+ | iOS 16.0+ |

* A React Native project
* A Google Cloud project
Expand Down Expand Up @@ -62,20 +62,12 @@ To ensure compatibility with AndroidX, enable Jetifier in your `android/gradle.p
android.enableJetifier=true
```

#### Minimum SDK Requirements for Android
#### Enable Core Library Desugaring

The `minSdkVersion` for your Android project must be set to 23 or higher in `android/app/build.gradle`:
Core library desugaring **must be enabled** for your Android project, regardless of your minSdkVersion.

```groovy
android {
defaultConfig {
minSdkVersion 23
}
}
```
To enable desugaring, update your `android/app/build.gradle` file:

If `minSdkVersion` is set to less than 34 (API 34), you need to configure desugaring for your Android app.
To enable desugaring, add the following configurations to `android/app/build.gradle` file:
```groovy
android {
...
Expand All @@ -90,7 +82,17 @@ dependencies {
}
```

You may also need to upgrade to Gradle 8.4 and the Android Gradle plugin version 8.3.0
#### Minimum SDK Requirements for Android

The `minSdkVersion` for your Android project must be set to 23 or higher in `android/app/build.gradle`:

```groovy
android {
defaultConfig {
minSdkVersion 23
}
}
```

#### Set Google Maps API Key

Expand Down
6 changes: 3 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import groovy.json.JsonSlurper

buildscript {
ext.kotlin_version = '2.0.0'
ext.kotlin_version = '2.1.21'
repositories {
google()
mavenCentral()
Expand All @@ -39,7 +39,7 @@ if (isNewArchitectureEnabled()) {

android {
namespace "com.google.android.react.navsdk"
compileSdkVersion 34
compileSdkVersion 35

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand Down Expand Up @@ -76,6 +76,6 @@ dependencies {
implementation "androidx.car.app:app-projected:1.4.0"
implementation 'com.facebook.react:react-native:+'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation "com.google.android.libraries.navigation:navigation:6.1.0"
implementation "com.google.android.libraries.navigation:navigation:6.3.1"
api 'com.google.guava:guava:31.0.1-android'
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public enum Command {
REMOVE_GROUND_OVERLAY(36, "removeGroundOverlay"),
SET_ZOOM_CONTROLS_ENABLED(37, "setZoomControlsEnabled"),
SET_RECENTER_BUTTON_ENABLED(38, "setRecenterButtonEnabled"),
SET_PADDING(39, "setPadding");
SET_PADDING(39, "setPadding"),
SET_REPORT_INCIDENT_BUTTON_ENABLED(40, "setReportIncidentButtonEnabled");

private final int value;
private final String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ public interface INavViewFragment extends IMapViewFragment {
void showRouteOverview();

void setNightModeOption(int jsValue);

void setReportIncidentButtonEnabled(boolean enabled);
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
public interface INavigationViewCallback {
void onMapReady();

void onRecenterButtonClick();

void onMarkerClick(Marker marker);

void onPolylineClick(Polyline polyline);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ public void onMapReady() {
emitEvent("onMapReady", null);
}

@Override
public void onRecenterButtonClick() {
emitEvent("onRecenterButtonClick", null);
}

@Override
public void onMarkerClick(Marker marker) {
emitEvent("onMarkerClick", ObjectTranslationUtil.getMapFromMarker(marker));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.google.android.gms.maps.model.Polygon;
import com.google.android.gms.maps.model.Polyline;
import com.google.android.libraries.navigation.NavigationView;
import com.google.android.libraries.navigation.PromptVisibilityChangedListener;
import com.google.android.libraries.navigation.StylingOptions;
import com.google.android.libraries.navigation.SupportNavigationFragment;

Expand All @@ -55,14 +56,24 @@ public NavViewFragment(ReactApplicationContext reactContext, int viewTag) {
this.viewTag = viewTag;
}

private NavigationView.OnRecenterButtonClickedListener onRecenterButtonClickedListener =
private final NavigationView.OnRecenterButtonClickedListener onRecenterButtonClickedListener =
new NavigationView.OnRecenterButtonClickedListener() {
@Override
public void onRecenterButtonClick() {
emitEvent("onRecenterButtonClick", null);
}
};

private final PromptVisibilityChangedListener onPromptVisibilityChangedListener =
new PromptVisibilityChangedListener() {
@Override
public void onVisibilityChanged(boolean isVisible) {
WritableMap map = Arguments.createMap();
map.putBoolean("visible", isVisible);
emitEvent("onPromptVisibilityChanged", map);
}
};

private String style = "";

@SuppressLint("MissingPermission")
Expand All @@ -87,6 +98,7 @@ public void onMapReady(GoogleMap googleMap) {

setNavigationUiEnabled(NavModule.getInstance().getNavigator() != null);
addOnRecenterButtonClickedListener(onRecenterButtonClickedListener);
addPromptVisibilityChangedListener(onPromptVisibilityChangedListener);
}
});
}
Expand Down Expand Up @@ -118,11 +130,6 @@ public void onMapReady() {
emitEvent("onMapReady", null);
}

@Override
public void onRecenterButtonClick() {
emitEvent("onRecenterButtonClick", null);
}

@Override
public void onMarkerClick(Marker marker) {
emitEvent("onMarkerClick", ObjectTranslationUtil.getMapFromMarker(marker));
Expand Down Expand Up @@ -176,6 +183,7 @@ public GoogleMap getGoogleMap() {

private void cleanup() {
removeOnRecenterButtonClickedListener(onRecenterButtonClickedListener);
removePromptVisibilityChangedListener(onPromptVisibilityChangedListener);
}

private void emitEvent(String eventName, @Nullable WritableMap data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,10 @@ public void receiveCommand(
getFragmentForRoot(root)
.getMapController()
.setPadding(args.getInt(0), args.getInt(1), args.getInt(2), args.getInt(3));
break;
case SET_REPORT_INCIDENT_BUTTON_ENABLED:
getNavFragmentForRoot(root).setReportIncidentButtonEnabled(args.getBoolean(0));
break;
}
}

Expand All @@ -318,6 +322,9 @@ public Map<String, Object> getExportedCustomDirectEventTypeConstants() {
.put(
"onRecenterButtonClick",
MapBuilder.of("registrationName", "onRecenterButtonClick"))
.put(
"onPromptVisibilityChanged",
MapBuilder.of("registrationName", "onPromptVisibilityChanged"))
.put("onMapReady", MapBuilder.of("registrationName", "onMapReady"))
.put("onMapClick", MapBuilder.of("registrationName", "onMapClick"))
.put("onMarkerClick", MapBuilder.of("registrationName", "onMarkerClick"))
Expand Down
3 changes: 2 additions & 1 deletion example/.detoxrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ module.exports = {
type: 'ios.simulator',
device: {
type: 'iPhone 16 Pro',
os: 'iOS 18.5',
},
},
attached: {
Expand All @@ -70,7 +71,7 @@ module.exports = {
emulator: {
type: 'android.emulator',
device: {
avdName: 'Pixel_8_API_35',
avdName: 'Pixel_9_Pro_API_35',
},
},
},
Expand Down
13 changes: 1 addition & 12 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,6 @@ react {
*/
def enableProguardInReleaseBuilds = true


/**
* Set this to true to enable desugaring if minSdkVersion is set to 34 or below.
* Note that this currently affects Detox testing with release builds and therefore is not enabled by default.
*/
def enableDesugaring = false

/**
* The preferred build flavor of JavaScriptCore (JSC)
*
Expand Down Expand Up @@ -132,7 +125,6 @@ android {
}
}
compileOptions {
coreLibraryDesugaringEnabled enableDesugaring
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
Expand All @@ -155,10 +147,7 @@ dependencies {
implementation "androidx.car.app:app-projected:1.4.0"

// Include the Google Navigation SDK.
implementation 'com.google.android.libraries.navigation:navigation:6.1.0'

// Desugar Java 8+ APIs
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.3'
implementation 'com.google.android.libraries.navigation:navigation:6.3.1'
}

secrets {
Expand Down
36 changes: 28 additions & 8 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.

/**
* Desugaring is required to be set on from navigation-sdk version 6.3.0 onwards.
* Note that this enableDesugaring currently affects Detox testing with release builds.
*/
def enableDesugaring = true

buildscript {
ext {
buildToolsVersion = "35.0.0"
// If minSDKVersion is set below 34, make sure to enable desugaring
// to use certain Java 8+ APIs on lower API levels
// by setting enableDesugaring true in app/build.gradle file.
minSdkVersion = 34
compileSdkVersion = 35
targetSdkVersion = 34
Expand All @@ -35,11 +38,28 @@ buildscript {
}

allprojects {
repositories {
maven {
url("$rootDir/../node_modules/detox/Detox-android")
}
repositories {
maven {
url("$rootDir/../node_modules/detox/Detox-android")
}
}
}

subprojects {
afterEvaluate { project ->
if (project.hasProperty('android')) {
android {
compileOptions {
coreLibraryDesugaringEnabled enableDesugaring
}
}

dependencies {
// Desugar Java 8+ APIs
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.3'
}
}
}
}
}

apply plugin: "com.facebook.react.rootproject"
2 changes: 1 addition & 1 deletion example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ end
node_require('react-native/scripts/react_native_pods.rb')
node_require('react-native-permissions/scripts/setup.rb')

platform :ios, "15.1"
platform :ios, "16.0"
prepare_react_native_project!

setup_permissions([
Expand Down
12 changes: 8 additions & 4 deletions example/ios/SampleApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@
"$(inherited)",
);
INFOPLIST_FILE = SampleAppTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
IPHONEOS_DEPLOYMENT_TARGET = 16.6;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand All @@ -615,7 +615,7 @@
BUNDLE_LOADER = "$(TEST_HOST)";
COPY_PHASE_STRIP = NO;
INFOPLIST_FILE = SampleAppTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
IPHONEOS_DEPLOYMENT_TARGET = 16.6;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -649,6 +649,7 @@
"CARPLAY=1",
);
INFOPLIST_FILE = "SampleApp/Info-CarPlay.plist";
IPHONEOS_DEPLOYMENT_TARGET = 16.6;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -697,6 +698,7 @@
"CARPLAY=1",
);
INFOPLIST_FILE = "SampleApp/Info-CarPlay.plist";
IPHONEOS_DEPLOYMENT_TARGET = 16.6;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -745,6 +747,7 @@
"COCOAPODS=1",
);
INFOPLIST_FILE = SampleApp/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 16.6;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -791,6 +794,7 @@
"COCOAPODS=1",
);
INFOPLIST_FILE = SampleApp/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 16.6;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -873,7 +877,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
IPHONEOS_DEPLOYMENT_TARGET = 16.6;
LD = "";
LDPLUSPLUS = "";
LD_RUNPATH_SEARCH_PATHS = (
Expand Down Expand Up @@ -947,7 +951,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
IPHONEOS_DEPLOYMENT_TARGET = 16.6;
LD = "";
LDPLUSPLUS = "";
LD_RUNPATH_SEARCH_PATHS = (
Expand Down
2 changes: 1 addition & 1 deletion example/ios/SampleApp/Keys.plist.sample
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<plist version="1.0">
<dict>
<key>API_KEY</key>
<string>[Add your key]</string>
<string>[Add Google Maps API key here]</string>
</dict>
</plist>
Loading
Loading