diff --git a/Classes/BITAuthenticator.h b/Classes/BITAuthenticator.h index 8adb828fd0..9c677f6378 100644 --- a/Classes/BITAuthenticator.h +++ b/Classes/BITAuthenticator.h @@ -244,6 +244,12 @@ typedef NS_ENUM(NSUInteger, BITAuthenticatorAppRestrictionEnforcementFrequency) This is required if `identificationType` is set to `BITAuthenticatorIdentificationTypeDevice`. Your app needs to implement the default `ha` URL scheme or register its own scheme via `urlScheme`. + BITAuthenticator checks if the given URL is actually meant to be parsed by it and will + return NO if it doesn't think so. It does this by checking the 'host'-part of the URL to be 'authorize', as well + as checking the protocol part. + Please make sure that if you're using a custom URL scheme, it does _not_ conflict with BITAuthenticator's. + If BITAuthenticator thinks the URL was meant to be an authorization URL, but could not find a valid token, it will + reset the stored identification token and state. Sample usage (in AppDelegate): diff --git a/Classes/BITAuthenticator.m b/Classes/BITAuthenticator.m index 5d973c705e..fffebf9eda 100644 --- a/Classes/BITAuthenticator.m +++ b/Classes/BITAuthenticator.m @@ -526,8 +526,9 @@ static NSString* const kBITAuthenticatorAuthTokenTypeKey = @"BITAuthenticatorAut } - (NSString *) UDIDFromOpenURL:(NSURL *) url annotation:(id) annotation isValidURL:(BOOL*) isValid{ + NSString *const kAuthorizationHost = @"authorize"; NSString *urlScheme = _urlScheme ? : [NSString stringWithFormat:@"ha%@", self.appIdentifier]; - if([[url scheme] isEqualToString:urlScheme]) { + if([[url scheme] isEqualToString:urlScheme] && [[url host] isEqualToString:kAuthorizationHost]) { if(isValid) { *isValid = YES; }