-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathAppDelegateCarPlay.m
More file actions
97 lines (82 loc) · 3.39 KB
/
AppDelegateCarPlay.m
File metadata and controls
97 lines (82 loc) · 3.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/**
* Copyright 2023 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
*
* 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.
*/
#import "AppDelegateCarPlay.h"
#import <CarPlay/CarPlay.h>
#import <GoogleMaps/GoogleMaps.h>
#import <React/RCTBundleURLProvider.h>
#import <ReactAppDependencyProvider/RCTAppDependencyProvider.h>
#import <UIKit/UIKit.h>
#import "CarSceneDelegate.h"
#import "PhoneSceneDelegate.h"
@implementation AppDelegateCarPlay
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.moduleName = @"SampleApp";
self.dependencyProvider = [RCTAppDependencyProvider new];
// You can add your custom initial props in the dictionary below.
// They will be passed down to the ViewController used by React Native.
self.initialProps = @{};
// Note: Ensure that you have copied the Keys.plist.sample to Keys.plist
// and have added the correct API_KEY value to the file.
//
// Get the path for the Keys.plist file in the main bundle and read API_KEY.
NSString *path = [[NSBundle mainBundle] pathForResource:@"Keys" ofType:@"plist"];
NSDictionary *keysDictionary = [NSDictionary dictionaryWithContentsOfFile:path];
NSString *api_key = [keysDictionary objectForKey:@"API_KEY"];
[GMSServices provideAPIKey:api_key];
// Set automaticallyLoadReactNativeWindow to NO to prevent RCTAppDelegate from creating the
// window. It will be created in PhoneSceneDelegate for the main (phone) screen.
self.automaticallyLoadReactNativeWindow = NO;
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
- (UISceneConfiguration *)application:(UIApplication *)application
configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession
options:(UISceneConnectionOptions *)options {
if ([connectingSceneSession.role
isEqualToString:@"CPTemplateApplicationSceneSessionRoleApplication"]) {
UISceneConfiguration *scene =
[[UISceneConfiguration alloc] initWithName:@"CarPlay"
sessionRole:connectingSceneSession.role];
scene.delegateClass = [CarSceneDelegate class];
return scene;
} else {
UISceneConfiguration *scene =
[[UISceneConfiguration alloc] initWithName:@"Phone"
sessionRole:connectingSceneSession.role];
scene.delegateClass = [PhoneSceneDelegate class];
return scene;
}
}
- (void)application:(UIApplication *)application
didDiscardSceneSessions:(NSSet<UISceneSession *> *)sceneSessions {
}
- (BOOL)fabricEnabled {
return NO;
}
- (BOOL)bridgelessEnabled {
return NO;
}
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge {
return [self bundleURL];
}
- (NSURL *)bundleURL {
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}
@end