Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfixes #76

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Discovery/DiscoveryManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#import "AppStateChangeNotifier.h"

#import <SystemConfiguration/CaptiveNetwork.h>
#import <CoreLocation/CoreLocation.h>

@interface DiscoveryManager() <DiscoveryProviderDelegate, ServiceConfigDelegate>

Expand Down Expand Up @@ -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];
}
Expand All @@ -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);

Expand Down
34 changes: 22 additions & 12 deletions Services/DIALService.m
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
}
}];
}

Expand Down
4 changes: 2 additions & 2 deletions Services/Helpers/AirPlayServiceMirrored.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -526,7 +526,7 @@ - (void)webViewDidFinishLoad:(WKWebView *)webView

- (void)webViewDidStartLoad:(WKWebView *)webView
{
DLog(@"%@", webView.request.URL.absoluteString);
DLog(@"%@", webView.URL.absoluteString);
}

@end