Poking a Hole in the Sandbox: Using URLs on ios



Similar documents
Apple URL Scheme Reference

Customize Mobile Apps with MicroStrategy SDK: Custom Security, Plugins, and Extensions

Introduction to iphone Development

TCP/IP Networking, Part 2: Web-Based Control

QUICK START GUIDE Bluetooth Cordless Hand Scanner (CHS)

Tag Specification Document

ITP 342 Mobile App Development. Notifications

Salesforce Mobile Push Notifications Implementation Guide

Jordan Jozwiak November 13, 2011

Data storage and retrieval in ios

Salesforce Mobile Push Notifications Implementation Guide

Google Product. Google Module 1

ios Dev Fest Research Network Operations Center Thursday, February 7, 13

Bypassing Internet Explorer s XSS Filter

ios App Programming Guide

Owner of the content within this article is Written by Marc Grote

Programming Autodesk PLM 360 Using REST. Doug Redmond Software Engineer, Autodesk

SonicWALL Mobile Connect. Mobile Connect for OS X 3.0. User Guide

ICE Trade Vault. Public User & Technology Guide June 6, 2014

ONLINE ACCOUNTABILITY FOR EVERY DEVICE. Quick Reference Guide V1.0

Microsoft Tag Scanning SDK for iphone & Android Apps

Introduction to the AirWatch Browser Guide

Game Center Programming Guide

FileMaker Server 15. Custom Web Publishing Guide

MA-WA1920: Enterprise iphone and ipad Programming

4D Plugin SDK v11. Another minor change, real values on 10 bytes is no longer supported.

Web application Architecture

Everything is Terrible

Developing for the App Store. (Legacy)

TakeMySelfie ios App Documentation

Donky Technical Overview

Wireless Presentation Gateway. User Guide

A Standards-based Mobile Application IdM Architecture

Implementing Mobile Thin client Architecture For Enterprise Application

ios App for Mobile Website! Documentation!

FileMaker 14. ODBC and JDBC Guide

AppConnect FAQ for MobileIron Technology Partners! AppConnect Overview

SmartTV User Interface Development for SmartTV using Web technology and CEA2014. George Sarosi

Fuzzing in Microsoft and FuzzGuru framework

By Global Delight. Voila Screen Capture For Mac 1

Blackbox Reversing of XSS Filters

Cloud to Cloud Integrations with Force.com. Sandeep Bhanot Developer

Universal XSS via IE8s XSS Filters

Before You Begin, Your Computer Must Meet the System Requirements

FileMaker 13. ODBC and JDBC Guide

Remote Desktop Connection Setup at King s College in Wilkes-Barre, PA

Symplified I: Windows User Identity. Matthew McNew and Lex Hubbard

OneDrive for Business

Citrix Worx App SDK Overview

Internet services in iphone Apps. Ole Gammelgaard Poulsen

Connect for iphone. Aug, 2012 Ver 5.3b AWest. 1 P age

Instructions on accessing your journal s content on your new app

Cloud Elements! Marketing Hub Provisioning and Usage Guide!

Mobile Application Development

From Delphi to the cloud

How To Use Salesforce Identity Features

Getting Started Guide with WIZ550web

Identity Implementation Guide

Integrating with BarTender Integration Builder

Salesforce1 Mobile Security Guide

Spring Design ScreenShare Service SDK Instructions

EXPOLeads Connect User Guide

How To Run A Hello World On Android (Jdk) On A Microsoft Ds.Io (Windows) Or Android Or Android On A Pc Or Android 4 (

Fairsail REST API: Guide for Developers

GATE Mímir and cloud services. Multi-paradigm indexing and search tool Pay-as-you-go large-scale annotation

Getting Started with New Relic Mobile

Next Generation ETS Software A preview of the upcoming new ETS5 system & user enhancements. KNX Association, Brussels André Hänel

Stellar Phoenix. SQL Database Repair 6.0. Installation Guide

Cloud Elements! Events Management BETA! API Version 2.0

LoadRunner and Performance Center v11.52 Technical Awareness Webinar Training

Wireless Security Camera with the Arduino Yun

RESCO MOBILE CRM QUICK GUIDE. for MS Dynamics CRM. ios (ipad & iphone) Android phones & tablets

Islington ebooks Help / FAQs

INTRODUCTION TO IOS CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 13 02/22/2011

FAQs for OPEN PAYMENTS Mobile for Physicians & OPEN PAYMENTS Mobile for Industry

SAS Visual Analytics 7.2 for SAS Cloud: Quick-Start Guide

Importing Data. Imports. File Sources. Importing Via Safari Download

STANDARD BANNER: Ad Specs

Net 2. NetApp Electronic Library. User Guide for Net 2 Client Version 6.0a

Michigan State University. Team Meijer. Tablet-Based Point-of-Sale System. Project Plan. Fall 2011

ios Application Development &

Introducing Apache Pivot. Greg Brown, Todd Volkert 6/10/2010

Schema documentation for types1.2.xsd

Qvidian Playbooks & Salesforce Setup Guide. Fall Release 2013

Welcome to icue! Version 4

Pendragon Forms Industrial

Introducing Xcode Source Control

Apple Help Programming Guide

Internationalizing the Domain Name System. Šimon Hochla, Anisa Azis, Fara Nabilla

Flexible Identity Federation

Pwning Intranets with HTML5

CA Unified Infrastructure Management Server

FileMaker Server 12. Custom Web Publishing with XML

Salesforce Files Connect Implementation Guide

Chapter 4: Computer Codes

Transcription:

Poking a Hole in the Sandbox: Using URLs on ios Greg Pierce @agiletortoise

Who am I? Greg Pierce President, Agile Tortoise @agiletortoise http:// Indie app development, web consulting

What do I do? Drafts Terminology Phraseology

What am I talking about? Custom URLs schemes as tool for inter-app communication on ios. - Limited options in the sandbox. - Consume URLs in other apps. - Provide services with URLs.

Inter-app whaaa? Integrating with other apps can make your app... - More useful. - Offers great opportunities for cross-promotion.

Overview Part 1 - What? - Local and Lightweight Part 2 - Why? - Use Cases Part 3 - How? - Implementation Part 4 - X-Callback-URL Q & A

Part 1 - What? Local and Lightweight

Anatomy of a URL - URL = Uniform Resource Locator scheme://domain:port/path? query_string#fragment_id - scheme or protocol is registered with OS. - Safari registers http - Phone.app registers tel - Mail.app registers mailto

Custom URLs - ios provides means to register Custom URL schemes for apps. - Registering says you know what to do with scheme: URLs. - Simple entries in app s Info.plist. - One app can register many custom URL schemes.

URLs - Lightweight Messaging between apps. - No OAuth, Web Services, complex setup. - Local - No network require for locally installed apps. - Few options!

Custom URL structure - Beyond the scheme and the colon, custom URL can look like anything. scheme:* - Not tied to HTTP (host:port/path) structure, but... - reuse tools/code that already exist to parse. - easier to document/consume. - Must follow escaping/encoding guidelines - Can support 80k characters at least.

Using URLs - URLs can be triggered like any links - Link embedded on a webpage - Programmatically two important methods: [[UIApplication sharedapplication] canopenurl:(nsurl *)url]; [[UIApplication sharedapplication] openurl:(nsurl *)url];

What happens? When a custom URL is opened... - Source app is backgrounded. - Target app is launched (or foregrounded) - Target AppDelegate is notified with a URL, using... - (BOOL)application:(UIApplication *)application openurl:(nsurl *)url sourceapplication:(nsstring *)sourceapplication annotation:(id)annotation

Part 2 - Why? Use cases

Testing if app is installed If you register a unique URL scheme, you give other apps a way to test if your app is installed. This includes your own apps...great for crosspromoting apps, without annoying people who have already downloaded.

Launching Without any additional work, registering a URL scheme gives apps a way to launch your app. See Launch Center Pro from App Cubby...

Launching with Context Have the user arrive at a specific place in your app... Facebook: fb://profile fb://events Tweetbot: tweetbot://post

Launching with Content Send some bit of string data to the target app. Drafts drafts://x-callback-url/create?text=%@ OmniFocus omnifocus:///add?name=%@

Executing an Action Dial a phone number tel:8175551234 Open this URL, Phone.app will launch and dial the number.

Two-Way Interaction - All these examples are one-way. Source App > Target App - What about 2-way? Source App > Target App > Source App - Callback URLs

Instapaper > Terminology > Instapaper terminology://x-callback-url/lookup? text=ceremony &x-source=instapaper &x-success=instapaper://

Instapaper > Terminology > Instapaper Terminology does the lookup Tap and Terminology will trigger the url in the x-success param x-source param provides friendly name for source

Two-Way with Data - Terminology Replace terminology://x-callback-url/replace? text=select &x-success=drafts://x-callback-url/replaceselection &x-source=drafts &x-cancel=drafts:// drafts://x-callback-url/replaceselection &replacewith=choose drafts://

Other Two-Way - izettle - Credit Card Transactions - Scanner Go - Bar Code Scanning - Authorization - Dropbox SDK, Facebook SDK

What not to do with URLs - Destructive actions myapp://deleteeverything - If destructive, require user confirmation. - Think about HTTP GET RESTful actions.

Part 3 - How? Implementation

URLScheme Demo App Example app on Github https://github.com/agiletortoise/urlschemes

Consuming URLs

Building URLs #import "Scratchpad.h" #import "NSString+URLEncoding.h" // Category for encoding @implementation Scratchpad - (void)examples { NSString *urlstring = @"test://action?param1=%@&param2=%@"; NSString *p1 = @"Hello World"; NSString *p2 = @"You re Awesome"; NSString *fullurlstring = [NSString stringwithformat:urlstring, [p1 urlencodeusingencoding:nsutf8stringencoding], [p2 urlencodeusingencoding:nsutf8stringencoding]]; NSURL *url = [NSURL URLWithString:fullURLString]; } @end test://action? param1=hello%20world &param2=you%e2%80%99re%20awesome

Opening URLs if ([[UIApplication sharedapplication] canopenurl:url]) { [[UIApplication sharedapplication] openurl:url]; } - Use canopenurl to build UI, don t show things that can t be used. - canopenurl doesn t need full URLs, test with just scheme://

Providing URLs

Register scheme

Register in Info.plist

Valid URL Scheme Names - Sequence of characters beginning with a letter and followed by any combination of letters, digits, plus ("+"), period ("."), or hyphen ("-"). - NOT case sensitive.

Recommended URL Scheme Names - Your app name as it appears on the device, with hyphens in place of spaces. My App Name my-app-name://

Versioning If you provide actions that you need to version over time, register additional URLs x-app-api10:// x-app-api20:// Now you have a way to test for compatibility.

Reacting to URL On AppDelegate, define: - (BOOL)application:(UIApplication *)application openurl:(nsurl *)url sourceapplication:(nsstring *)sourceapplication annotation:(id)annotation; c - called after applicationwillenterforeground - called before applicationdidbecomeactive - return NO if you don t recognize the URL - (Nothing happens, just best practice)

ios 3 note... Prior to ios 4, you handled URLs in... - (BOOL)application:(UIApplication *)application handleopenurl:(nsurl *)url; If you need to support ios 3, implement this method and forward to your application: openurl: sourceapplication: annotation method.

Parsing Parameters myapp://actionname?test=param%20value&test2=paramvalue URLParser *parser = [[URLParser alloc] initwithurlstring:[url absolutestring]]; NSString *testparamvalue = [parser valueforvariable:@"test"]; // testparamvalue == @ param value

Parsing Parameters If you parse using some other method, USE THIS METHOD TO DECODE!!! [str stringbyreplacingpercentescapesusingencoding:nsutf8stringencoding]

DEMO (unreheased, apologies in advance)

Part 4 X-Callback-URL

X-Callback-URL - Specification to standardize URL formats - Drafts, Terminology, Instapaper, Agenda, Due, icab Mobile, Poster, Phraseology, Notesy. - Collaboration of myself, Marco Arment with input from a few others. http://x-callback-url.com

X-Callback-URL format scheme://x-callback-url/[action]?[x-callback parameters]&[action parameters] - [action] is specific to your app/implementation and should typically be a verb. - [action parameters] are also specific to your app and show be in a URL query string...i.e.: subject=the%20subject&body=the%20body

X-Callback-URL Parameters x-source: Friendly name of source app. x-success: Base URL to fire if successful x-error: Base URL to fire if error occurs x-cancel: Base URL to fire if user cancels

Finally... - Why use URL schemes? Why not? - Why format them with X-Callback-URL? Why not? - Document what you implement!!!!!! - Use affiliate links to promote apps you integrate with!!!!! - UTF8 escape and decode parameters! - Test with Unicode chars and cold starts.

Resources Find URL schemes: - http://handleopenurl.com - http://wiki.akosma.com/iphone_url_schemes Tutorial: - http://mobile.tutsplus.com/tutorials/iphone/ios-sdk-workingwith-url-schemes/ X-Callback-URL: - http://x-callback-url.com (sample apps/examples) URLSchemes Demo App: - https://github.com/agiletortoise/urlschemes

Q & A @agiletortoise Slides and Links: http:///blog