File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed
packages/react-native-carplay Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -216,6 +216,36 @@ - (void)updateListRowItemImageWithURL:(CPListImageRowItem *)item imgUrl:(NSStrin
216216 }
217217}
218218
219+ RCT_REMAP_METHOD (getConnectionStatus,
220+ resolver:(RCTPromiseResolveBlock)resolve
221+ rejecter:(RCTPromiseRejectBlock)reject)
222+ {
223+ // Check for CarPlay scene
224+ BOOL carplayConnected = NO ;
225+ for (UIScene *scene in [UIApplication sharedApplication ].connectedScenes ) {
226+ if ([scene isKindOfClass: [CPTemplateApplicationScene class ]]) {
227+ carplayConnected = YES ;
228+ break ;
229+ }
230+ }
231+
232+ // Check for phone (active foreground window scene)
233+ BOOL phoneConnected = NO ;
234+ for (UIScene *scene in [UIApplication sharedApplication ].connectedScenes ) {
235+ if ([scene isKindOfClass: [UIWindowScene class ]] &&
236+ scene.activationState == UISceneActivationStateForegroundActive) {
237+ phoneConnected = YES ;
238+ break ;
239+ }
240+ }
241+
242+ resolve (@{
243+ @" carplay" : @(carplayConnected),
244+ @" phone" : @(phoneConnected)
245+ });
246+ }
247+
248+
219249RCT_EXPORT_METHOD (createTemplate:(NSString *)templateId config:(NSDictionary *)config callback:(id )callback) {
220250 // Get the shared instance of the RNCPStore class
221251 RNCPStore *store = [RNCPStore sharedManager ];
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ import { RoutePreviewNavigationTemplate } from './templates/android/RoutePreview
3333
3434export interface InternalCarPlay extends NativeModule {
3535 checkForConnection ( ) : void ;
36+ getConnectionStatus ( ) : Promise < { carplay : boolean , phone : boolean } > ;
3637 setRootTemplate ( templateId : string , animated : boolean ) : void ;
3738 pushTemplate ( templateId : string , animated : boolean ) : void ;
3839 popToTemplate ( templateId : string , animated : boolean ) : void ;
You can’t perform that action at this time.
0 commit comments