Closed SteveDCronin closed 5 years ago
So the answer is:
'url' that is passed in: [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) { //completion codes here }];
is updated inside the completionHandler. All that is required is to read 'url' inside the completionHandler! Done!
Thats bizarre!
Simon;
I'm currently trying to implement zkSforce in an iPad app using OAuth.
Your OAuthDemo is macOS only and relies on 2 Mac-isms 1) [[NSWorkspace sharedWorkspace] openURL:url]; 2) [[NSAppleEventManager sharedAppleEventManager] setEventHandler:self andSelector:@selector(getUrl:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL];
The first can be easily retro-fitted with: [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) { //completion codes here }];
The second has me stumped... When I am authenticating for the first time I build the loginURL like so: NSString login = [NSString stringWithFormat:@"https://login.salesforce.com/services/oauth2/authorize?response_type=token&client_id=%@&redirect_uri=%@", [SALESFORCE_OAUTH_CLIENTID stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]], [SALESFORCE_OAUTH_CALLBACK stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]]]; NSURL url = [NSURL URLWithString:login];
If I then use the UIApplication openURL method shown above I'm not seeing how I can obtain the callback (NSString) that the macOS implementation obtains by using the 'ReplyEvent'...
Can you shed any light on how to complete the initial OAuth login on iOS? Thanks! Steve