diff options
author | NicoleYarroch <nicole@livio.io> | 2019-02-28 09:05:14 -0500 |
---|---|---|
committer | NicoleYarroch <nicole@livio.io> | 2019-02-28 09:05:14 -0500 |
commit | 3567b5d237d27eb6a2f3ffb1300214cb2c721ebf (patch) | |
tree | 84c8d9b30fcc894fbf731f480d1b6d405c64c86a | |
parent | c5731dbe636043f0a0a2e9b07480bee5878e3bcd (diff) | |
download | sdl_ios-3567b5d237d27eb6a2f3ffb1300214cb2c721ebf.tar.gz |
Added support for downloading the cloud app icon
When the library gets an `OnSystemRequest` from Core, it downloads the image from the `url` provided by Core and sends an `SystemRequest` to Core with the image data.
-rw-r--r-- | SmartDeviceLink/SDLProxy.m | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/SmartDeviceLink/SDLProxy.m b/SmartDeviceLink/SDLProxy.m index 99c681f87..5226a2023 100644 --- a/SmartDeviceLink/SDLProxy.m +++ b/SmartDeviceLink/SDLProxy.m @@ -509,7 +509,9 @@ static float DefaultConnectionTimeout = 45.0; if ([requestType isEqualToEnum:SDLRequestTypeProprietary]) { [self handleSystemRequestProprietary:systemRequest]; } else if ([requestType isEqualToEnum:SDLRequestTypeLockScreenIconURL]) { - [self handleSystemRequestLockScreenIconURL:systemRequest]; + [self sdl_handleSystemRequestLockScreenIconURL:systemRequest]; + } else if ([requestType isEqualToEnum:SDLRequestTypeIconURL]) { + [self sdl_handleSystemRequestIconURL:systemRequest]; } else if ([requestType isEqualToEnum:SDLRequestTypeHTTP]) { [self sdl_handleSystemRequestHTTP:systemRequest]; } else if ([requestType isEqualToEnum:SDLRequestTypeLaunchApp]) { @@ -696,7 +698,7 @@ static float DefaultConnectionTimeout = 45.0; }]; } -- (void)handleSystemRequestLockScreenIconURL:(SDLOnSystemRequest *)request { +- (void)sdl_handleSystemRequestLockScreenIconURL:(SDLOnSystemRequest *)request { __weak typeof(self) weakSelf = self; [self sdl_sendDataTaskWithURL:[NSURL URLWithString:request.url] completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { @@ -711,6 +713,27 @@ static float DefaultConnectionTimeout = 45.0; }]; } +- (void)sdl_handleSystemRequestIconURL:(SDLOnSystemRequest *)request { + __weak typeof(self) weakSelf = self; + [self sdl_sendDataTaskWithURL:[NSURL URLWithString:request.url] + completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + __strong typeof(weakSelf) strongSelf = weakSelf; + if (error != nil) { + SDLLogW(@"OnSystemRequest (icon url) HTTP download task failed: %@", error.localizedDescription); + return; + } else if (data.length == 0) { + SDLLogW(@"OnSystemRequest (icon url) HTTP download task failed to get the cloud app icon image data"); + return; + } + + SDLSystemRequest *iconURLSystemRequest = [[SDLSystemRequest alloc] initWithType:SDLRequestTypeIconURL fileName:request.url]; + iconURLSystemRequest.requestSubType = SDLNameId; + iconURLSystemRequest.bulkData = data; + + [strongSelf sendRPC:iconURLSystemRequest]; + }]; +} + - (void)sdl_handleSystemRequestHTTP:(SDLOnSystemRequest *)request { if (request.bulkData.length == 0) { // TODO: not sure how we want to handle http requests that don't have bulk data (maybe as GET?) |