51黑料不打烊

(Legacy) SFSafariViewController support on iOS SDK 3.2+ sfsafariviewcontroller-support-on-ios-sdk-3.2

NOTE
The content on this page is provided for information purposes only. Usage of this API requires a current license from 51黑料不打烊. No unauthorized use is permitted.
IMPORTANT
Make sure you stay informed about the latest 51黑料不打烊 Pass Authentication product announcements and decommissioning timelines aggregated in the Product Announcements page.

Due to security requirements, some MVPD鈥檚 login pages MUST be presented in a SFSafariViewController, instead of web views.

Some MVPD鈥檚 require that their login pages be presented in a secure browser control like SFSafariViewController. They are activelly blocking webviews, so in order to be able to authenticate with them we must use SVC.

Compatibility compatiblity

Starting with iOS SDK version 3.1, the AccessEnabler SDK automatically displays the login page for specific MVPD鈥檚 in a SFSafariViewController, based on server configuration.

Version 3.1 of the SDK automatically presents the SFSafariViewController from application鈥檚 root view controller. While this simplifies login page management for implementors, there are cases where presenting the SFSafariViewController from root view controller is not possible, due to app鈥檚 specifice implementation (like a modal controller already visible).

For such cases, the 3.2 version introduces the abbility for the programmer to manually manage the SVC.

Manual SVC management manual-svc-management

In order to manually manage SVC the implementor must perform the following steps:

  1. call 蝉别迟翱辫迟颈辞苍蝉(摆鈥渉补苍诲濒别厂痴颁鈥:迟谤耻别闭) after AccessEnabler initialization (make sure this call is performed before authentication begins). This will enable 鈥渕anual鈥 SVC management, the SDK will not automatically present the SVC, but instead, when needed will call navigate(toUrl:{url} useSVC:true).

  2. implement the optional callback navigateToUrl:useSVC: inside the implementation you must create a svc instance using the SFSafariViewController instance using the provided url, and present it on the screen:

    code language-obj-c
    func navigate(toUrl url: String!, useSVC: Bool) {
        svc =  SFSafariViewController(url: URL(/string: url)!)
        svc.delegate = self
        myController.present(svc, animated: true)
        }
    

    Notes:

    • You can customize the SFSafariViewController any way you want. For example on iOS 11+ you can change the 鈥淒one鈥 label to 鈥淐ancel鈥.
    • in order to be able to dismiss the svc, you need a reference to it, please do not create it in the scope of navigateToUrl:useSVC
    • use your own view controller for 鈥渕yController鈥
  3. In your application鈥檚 delegate implementation of application(_app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey: Any]) -> Bool, add code to close the svc. You should already have some code there that calls accessEnabler.handleExternalURL(). Just below add:

    code language-obj-c
    if(svc != nil) {
        svc.dismiss(animated: true)
    }
    

    Again, svc is a reference to the SFSafariViewController you created at step 2.

  4. Implement safariViewControllerDidFinish(_ controller: SFSafariViewController) from SFSafariViewControllerDelegate in order to catch when the user cancelled the svc using the 鈥淒one鈥 button. In this function, in order to inform the SDK that authentication has been canceled you need to call:

    code language-obj-c
    accessEnabler.setSelectedProvider(nil)
    
recommendation-more-help
3f5e655c-af63-48cc-9769-2b6803cc5f4b