I am trying to implement an SSO scenario with using sfsafariviewcontroller
. The scenario is below.
- The user opens the app, and the login page displays in
wkwebview
. - User clicks login button then
safariviewcontroller
opens the SSO page. - The user enters username and password then presses login button in SSO page.
- For two-step verification, the user enters an SMS-pin in next SSO page and presses the Done button.
- When verification completes, the user automatically returns with authorized state.
The problem is at step 4. When the user opens messages to get the SMS-pin and returns to the app, the sfsafariviewcontroller
reloads the page with the initial URL. So the user cannot enter the SMS-pin.
Why does SfSafariViewController
reload the page with the initial URL every time?
The implementation is below.
@interface WebContentViewController()<SFSafariViewControllerDelegate>
...
@end
@implementation WebContentViewController
...
...
- (BOOL)decideNavigationFlow:(NSURL *) url isLinkClicked: (BOOL) isLinkClicked {
....
....
if(IS_IOS9_OR_GREATER){
SFSafariViewController *svc = [[SFSafariViewController alloc] initWithURL:url];
[self presentViewController:svc animated:YES completion:nil];
}
}
-(void)safariViewController:(SFSafariViewController *)controller didCompleteInitialLoad:(BOOL)didLoadSuccessfully {
LogInfo(@"#######Initial load completed");
}
-(void)safariViewControllerDidFinish:(SFSafariViewController *)controller {
LogInfo(@"#######Done pressed");
}
@end