diff options
author | NicoleYarroch <nicole@livio.io> | 2019-05-29 12:03:28 -0400 |
---|---|---|
committer | NicoleYarroch <nicole@livio.io> | 2019-05-29 12:03:28 -0400 |
commit | 71b807fa75ef46b0aaad6ee20d0b20c78eab822f (patch) | |
tree | b67f6b56ffe6fb6714130a70593ee525ec1fd18e | |
parent | 6c4bf0d712e41ebdcc3291890efc654df863a972 (diff) | |
download | sdl_ios-71b807fa75ef46b0aaad6ee20d0b20c78eab822f.tar.gz |
Examples apps restarted if the manager still exists
-rw-r--r-- | Example Apps/Example ObjC/ProxyManager.m | 14 | ||||
-rw-r--r-- | Example Apps/Example Swift/ProxyManager.swift | 11 |
2 files changed, 17 insertions, 8 deletions
diff --git a/Example Apps/Example ObjC/ProxyManager.m b/Example Apps/Example ObjC/ProxyManager.m index a7732892a..c045531ef 100644 --- a/Example Apps/Example ObjC/ProxyManager.m +++ b/Example Apps/Example ObjC/ProxyManager.m @@ -54,7 +54,7 @@ NS_ASSUME_NONNULL_BEGIN return self; } -- (void)startManager { +- (void)sdlex_startManager { __weak typeof (self) weakSelf = self; [self.sdlManager startWithReadyHandler:^(BOOL success, NSError * _Nullable error) { if (!success) { @@ -109,10 +109,14 @@ NS_ASSUME_NONNULL_BEGIN } - (void)sdlex_setupConfigurationWithLifecycleConfiguration:(SDLLifecycleConfiguration *)lifecycleConfiguration { - SDLConfiguration *config = [SDLConfiguration configurationWithLifecycle:lifecycleConfiguration lockScreen:[SDLLockScreenConfiguration enabledConfigurationWithAppIcon:[UIImage imageNamed:ExampleAppLogoName] backgroundColor:nil] logging:[self.class sdlex_logConfiguration] fileManager:[SDLFileManagerConfiguration defaultConfiguration]]; - self.sdlManager = [[SDLManager alloc] initWithConfiguration:config delegate:self]; - - [self startManager]; + if (self.sdlManager == nil) { + SDLConfiguration *config = [SDLConfiguration configurationWithLifecycle:lifecycleConfiguration lockScreen:[SDLLockScreenConfiguration enabledConfigurationWithAppIcon:[UIImage imageNamed:ExampleAppLogoName] backgroundColor:nil] logging:[self.class sdlex_logConfiguration] fileManager:[SDLFileManagerConfiguration defaultConfiguration]]; + self.sdlManager = [[SDLManager alloc] initWithConfiguration:config delegate:self]; + [self sdlex_startManager]; + } else { + // Manager already created, just start it again. + [self sdlex_startManager]; + } } + (SDLLifecycleConfiguration *)sdlex_setLifecycleConfigurationPropertiesOnConfiguration:(SDLLifecycleConfiguration *)config { diff --git a/Example Apps/Example Swift/ProxyManager.swift b/Example Apps/Example Swift/ProxyManager.swift index b6287bf6e..a645b0c1a 100644 --- a/Example Apps/Example Swift/ProxyManager.swift +++ b/Example Apps/Example Swift/ProxyManager.swift @@ -43,9 +43,14 @@ extension ProxyManager { /// /// - Parameter connectionType: The type of transport layer to use. func start(with proxyTransportType: ProxyTransportType) { - delegate?.didChangeProxyState(ProxyState.searching) - sdlManager = SDLManager(configuration: proxyTransportType == .iap ? ProxyManager.connectIAP() : ProxyManager.connectTCP(), delegate: self) - startManager() + if sdlManager == nil { + delegate?.didChangeProxyState(ProxyState.searching) + sdlManager = SDLManager(configuration: proxyTransportType == .iap ? ProxyManager.connectIAP() : ProxyManager.connectTCP(), delegate: self) + startManager() + } else { + // Manager already created, just start it again. + startManager() + } } /// Attempts to close the connection between the this app and the car's head unit. The `SDLManagerDelegate`'s `managerDidDisconnect()` is called when connection is actually closed. |