$30 off During Our Annual Pro Sale. View Details »

CocoaHeads SKG #3 - iOS link Handling

CocoaHeads SKG #3 - iOS link Handling

CocoaHeadsSKG

April 04, 2016
Tweet

More Decks by CocoaHeadsSKG

Other Decks in Technology

Transcript

  1. iOS link handling
    Dimitri James Tsiflitzis
    CocoaheadsSKG

    View Slide

  2. Inter-App Communication
    1. URL Schemes
    2. Universal Links

    View Slide

  3. Using URL Schemes to Communicate with Apps
    ● Easy to setup & define
    ● Even easier to use
    ● Available in older iOS versions with some limitations on iOS9

    View Slide

  4. Registering Custom URL Schemes
    In your plist
    If more than one third-party app registers to handle the same URL scheme ¯\_(ツ)_/¯

    View Slide

  5. Handling URL Requests
    E.g. meetup://events/229782259 (scheme://host/path?query)

    View Slide

  6. Check if a URL scheme is available

    View Slide

  7. Preparing for URL Schemes in iOS9
    ● Add schemes checked using canOpenURL to the plist

    View Slide

  8. Some extra stuff
    ● Visit http://handleopenurl.com/ to get a list of schemes
    ● Use custom URL schemes to have a Today Extension
    communicate with your app

    View Slide

  9. Using Universal Links (from the docs)
    ● Unique. Unlike custom URL schemes, universal links can’t be claimed by
    other apps, because they use standard HTTP or HTTPS links to your website.
    ● Secure. When users install your app, iOS checks a file that you’ve uploaded
    to your web server to make sure that your website allows your app to open
    URLs on its behalf. Only you can create and upload this file, so the
    association of your website with your app is secure.
    ● Flexible. Universal links work even when your app is not installed. When your
    app isn’t installed, tapping a link to your website opens the content in Safari,
    as users expect.
    ● Simple. One URL works for both your website and your app.
    ● Private. Other apps can communicate with your app without needing to know
    whether your app is installed.

    View Slide

  10. Adding support for Universal links
    ● Create an apple-app-site-association file that contains JSON data about
    the URLs that your app can handle.
    ● Upload the apple-app-site-association file to your HTTPS web server.
    ● Prepare your app to handle universal links.

    View Slide

  11. Server side
    Add a apple-app-site-association to the root of your server (prefix can be found in
    provisioning portal.)

    View Slide

  12. Client Side
    ● Add an entitlement that specifies the domains your app supports.

    View Slide

  13. Client side
    ● Update your app delegate to respond appropriately when it receives the
    NSUserActivity object.

    View Slide

  14. Some extra stuff
    ● Work in SFSafariViewController, don’t work in UIWebView
    ● Debugging the apple-app-site-association is hard
    ● Some popular app don’t support them, e.g. gmail
    ● Actions are remembered

    View Slide

  15. Ευχαριστούμε :)
    @sprimp
    CocoaheadsSKG

    View Slide