Closed janwiebe-jump closed 4 months ago
I looked through the source and I don't think this method is registered on Android either.
@birkir Did you have a vision in mind with didPressMenuItem
? It doesn't actually appear to be implemented on Android or iOS.
Fixed on #162.
Patch :
diff --git a/node_modules/react-native-carplay/src/CarPlay.ts b/node_modules/react-native-carplay/src/CarPlay.ts
index 4694d0a..c9e074f 100644
--- a/node_modules/react-native-carplay/src/CarPlay.ts
+++ b/node_modules/react-native-carplay/src/CarPlay.ts
@@ -1,4 +1,4 @@
-import { ImageSourcePropType, NativeEventEmitter, NativeModule, NativeModules } from 'react-native';
+import { ImageSourcePropType, NativeEventEmitter, NativeModule, NativeModules, Platform } from 'react-native';
import { ActionSheetTemplate } from './templates/ActionSheetTemplate';
import { AlertTemplate } from './templates/AlertTemplate';
import { ContactTemplate } from './templates/ContactTemplate';
@@ -22,6 +22,8 @@ import { TripConfig } from './navigation/Trip';
import { TimeRemainingColor } from './interfaces/TimeRemainingColor';
import { TextConfiguration } from './interfaces/TextConfiguration';
import { Action } from './interfaces/Action';
+import { MessageTemplate } from './templates/android/MessageTemplate';
+import { PaneTemplate } from './templates/android/PaneTemplate';
export interface InternalCarPlay extends NativeModule {
checkForConnection(): void;
@@ -35,9 +37,9 @@ export interface InternalCarPlay extends NativeModule {
enableNowPlaying(enabled: boolean): void;
updateManeuversNavigationSession(id: string, x: Maneuver[]): void;
updateTravelEstimatesNavigationSession(
- id: string,
- index: number,
- estimates: TravelEstimates,
+ id: string,
+ index: number,
+ estimates: TravelEstimates,
): void;
cancelNavigationSession(id: string): void;
finishNavigationSession(id: string): void;
@@ -49,17 +51,17 @@ export interface InternalCarPlay extends NativeModule {
updateTemplate(id: string, config: unknown): void;
invalidate(id: string): void;
startNavigationSession(
- id: string,
- tripId: string,
+ id: string,
+ tripId: string,
): Promise<{
tripId: string;
navigationSessionId: string;
}>;
updateTravelEstimatesForTrip(
- id: string,
- tripId: string,
- travelEstimates: TravelEstimates,
- timeRemainingColor: TimeRemainingColor,
+ id: string,
+ tripId: string,
+ travelEstimates: TravelEstimates,
+ timeRemainingColor: TimeRemainingColor,
): void;
updateMapTemplateConfig(id: string, config: unknown): void;
updateMapTemplateMapButtons(id: string, config: unknown): void;
@@ -94,18 +96,20 @@ export interface InternalCarPlay extends NativeModule {
const { RNCarPlay } = NativeModules as { RNCarPlay: InternalCarPlay };
export type PushableTemplates =
- | MapTemplate
- | SearchTemplate
- | GridTemplate
- | PointOfInterestTemplate
- | ListTemplate
- | InformationTemplate
- | ContactTemplate
- | NowPlayingTemplate
- | NavigationTemplate
- | PlaceListMapTemplate
- | PlaceListNavigationTemplate
- | RoutePreviewNavigationTemplate;
+ | MapTemplate
+ | SearchTemplate
+ | GridTemplate
+ | PointOfInterestTemplate
+ | ListTemplate
+ | MessageTemplate
+ | PaneTemplate
+ | InformationTemplate
+ | ContactTemplate
+ | NowPlayingTemplate
+ | NavigationTemplate
+ | PlaceListMapTemplate
+ | PlaceListNavigationTemplate
+ | RoutePreviewNavigationTemplate;
export type PresentableTemplates = AlertTemplate | ActionSheetTemplate | VoiceControlTemplate;
@@ -157,11 +161,13 @@ export class CarPlayInterface {
callback();
});
});
- this.emitter.addListener('didPressMenuItem', e => {
- if (e?.title === 'Reload Android Auto') {
- this.bridge.reload();
- }
- });
+ if (Platform.OS === 'android') {
+ this.emitter.addListener('didPressMenuItem', e => {
+ if (e?.title === 'Reload Android Auto') {
+ this.bridge.reload();
+ }
+ });
+ }
// check if already connected this will fire any 'didConnect' events
// if a connected is already present.
Describe the bug Error:
didPressMenuItem
is not a supporte event type for RNCarPlayTo Reproduce Steps to reproduce the behavior:
Expected behavior A clear and concise description of what you expected to happen.
Screenshots/Videos If applicable, add screenshots to help explain your problem.
CarPlay (please complete the following information):
Android Auto (please complete the following information):
Additional context