diff --git a/Discovery/DiscoveryManager.m b/Discovery/DiscoveryManager.m index 672ce82a..4c13b2dc 100644 --- a/Discovery/DiscoveryManager.m +++ b/Discovery/DiscoveryManager.m @@ -38,6 +38,7 @@ #import "AppStateChangeNotifier.h" #import +#import @interface DiscoveryManager() @@ -244,6 +245,7 @@ - (void) unregisterDeviceService:(Class)deviceClass withDiscovery:(Class)discove - (void) startSSIDTimer { + [_ssidTimer invalidate]; _ssidTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(detectSSIDChange) userInfo:nil repeats:YES]; [_ssidTimer fire]; } @@ -265,6 +267,11 @@ - (void) detectSSIDChange if ([interface caseInsensitiveCompare:@"en0"] != NSOrderedSame) return; + if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined || + [CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied) { + return; + } + CFDictionaryRef cfDict = CNCopyCurrentNetworkInfo((CFStringRef)interface); NSDictionary *info = (NSDictionary *)CFBridgingRelease(cfDict); diff --git a/Services/DIALService.m b/Services/DIALService.m index dd3b418b..ed89b16b 100644 --- a/Services/DIALService.m +++ b/Services/DIALService.m @@ -408,6 +408,9 @@ - (void)launchYouTube:(NSString *)contentId success:(AppLaunchSuccessBlock)succe - (void) launchYouTube:(NSString *)contentId startTime:(float)startTime success:(AppLaunchSuccessBlock)success failure:(FailureBlock)failure { + AppInfo *appInfo = [AppInfo appInfoForId:@"YouTube"]; + appInfo.name = appInfo.id; + NSString *params; if (contentId && contentId.length > 0) { @@ -419,23 +422,30 @@ - (void) launchYouTube:(NSString *)contentId startTime:(float)startTime success: return; } - // YouTube on some platforms requires a pairing code, which may be a random string - NSString *pairingCode = [[CTGuid randomGuid] stringValue]; - - params = [NSString stringWithFormat:@"pairingCode=%@&v=%@&t=%.1f", pairingCode, contentId, startTime]; + params = [NSString stringWithFormat:@"v=%@&t=%.1f", contentId, startTime]; } - AppInfo *appInfo = [AppInfo appInfoForId:@"YouTube"]; - appInfo.name = appInfo.id; - - [self.launcher launchAppWithInfo:appInfo params:(id)params success:^(LaunchSession *launchSession) - { + [self.launcher launchAppWithInfo:appInfo params:(id)params success:^(LaunchSession *launchSession) { if (success) success(launchSession); - } failure:^(NSError *error) - { - if (failure) + } failure:^(NSError *error) { + + if (params) { + // YouTube on some platforms requires a pairing code, which may be a random string. + // Let's retry once more + NSString *pairingCode = [[CTGuid randomGuid] stringValue]; + NSString *paramsWithCode = [NSString stringWithFormat:@"pairingCode=%@&%@", pairingCode, params]; + [self.launcher launchAppWithInfo:appInfo params:(id)paramsWithCode success:^(LaunchSession *launchSession) { + if (success) + success(launchSession); + } failure:^(NSError *error) { + if (failure) + failure(error); + }]; + + } else if (failure) { failure(error); + } }]; } diff --git a/Services/Helpers/AirPlayServiceMirrored.m b/Services/Helpers/AirPlayServiceMirrored.m index 743da295..c40868cd 100644 --- a/Services/Helpers/AirPlayServiceMirrored.m +++ b/Services/Helpers/AirPlayServiceMirrored.m @@ -515,7 +515,7 @@ - (BOOL)webView:(WKWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *) - (void)webViewDidFinishLoad:(WKWebView *)webView { - DLog(@"%@", webView.request.URL.absoluteString); + DLog(@"%@", webView.URL.absoluteString); if (self.launchSuccessBlock) self.launchSuccessBlock(nil); @@ -526,7 +526,7 @@ - (void)webViewDidFinishLoad:(WKWebView *)webView - (void)webViewDidStartLoad:(WKWebView *)webView { - DLog(@"%@", webView.request.URL.absoluteString); + DLog(@"%@", webView.URL.absoluteString); } @end