Launching external apps from a DPS folio

Inter-app communication is a frequent request from my DPS customers. For instance, they would like to be able to launch Mail with a message already populated, or send a tweet, or post to LinkedIn. While it could be possible to do that within a Web Content Overlay, often times it is preferable to send a request to the native application or service on the device.

iOS applications have a method to allow apps to talk to each other called a Custom URL Scheme. Not all apps make use of this feature, though; it is up to the developer to implement it properly. This method is documented at Apple’s Developer Connection, and I have an article in the Adobe Developer Connection that uses the Custom URL Scheme method to navigate within a DPS folio using JavaScript and HTML. This article will discuss communicating with external apps via the Custom URL Scheme.

Some Custom URL Schemes are well understood and have been part of the HTML consciousness for a long time.

mailto:

and

tel:

are used frequently to send emails and dial a telephone, for instance. I have an article in this blog that talks about using the mailto: Custom URL scheme. How, then, can we use similar methods to communicate with other apps? First, we need to determine the Custom URL Scheme that is registered to an app. Some apps make their Custom URL Schemes well known, like Google Maps. Others do not. You can search for apps and get some help with how to craft a URL at Magnatron’s handleOpenURL site. Searching that site for Twitter, for instance, I can see that the native Twitter app uses the “twitter:” scheme and some directives to start the Twitter app and have it so something. Here are some of the commands:

twitter://user?screen_name=jameslockman
twitter://timeline
twitter://mentions
twitter://messages
twitter://list?screen_name=jameslockman&slug=abcd
twitter://post?message=hello%20world

It’s clear that if we know how to properly phrase our request, then we can easily create integrations between DPS apps and other native apps. Armed with the Custom URL Scheme, I decided to try to use it for a specific use case.

I had a request from a customer who needs to launch a Connect meeting on their iPad from a DPS application. The customer wants to provide eLearning content in DPS for offline use, and then provide a button in the DPS folio that will launch Connect Mobile and pre-populate the meeting room information.

I asked around internally, and the Connect Mobile folks were kind enough to provide me with the following Custom URL Scheme for Connect Mobile:

connectpro://https://connect.server.address/connect.room.path

OK, I thought, I’ll just make a button in InDesign and set it to go to the URL. Unfortunately, when I tap the button, the colon (“:”) after “https” didn’t pass over to Connect Mobile, so the URL got passed as

https//connect.server.address/connect.room.path

In addition, DPS launched an empty Web Overlay so that when I returned to the folio, I had to tap the “Done” button to close the overlay. Not very elegant, and not exactly what I was looking to accomplish.

After some back and forth with a few people on the Connect side (Props to David Knight, Vincent Le Quang and Minh Huynh for taking time out of their busy days to help diagnose the issue) and a lot of trying and failing with variations on escaping the colon character, it dawned on me that the solution was easy and should have been obvious.

When we create a button or hyperlink in InDesign, that button’s or hyperlink’s URL target gets passed out of the folio and to the Content Viewer, which then passes it on to iOS. This is two steps, and the special character was getting decoded and then left behind, which makes sense. The answer is to use a Web Content Overlay, which provided only one step to iOS as it is a native iOS Webkit Overlay.

I made an HTML snippet, escaped the problematic colon character with %3A, and inserted the HTML (Object>Insert>HTML) into my folio:

<a href="connectpro://https%3A//connect.server.address/connect.room.path">tap here to go to the meeting (%3A escaped)</a>

InDesign recognized the inserted HTML as a Web Content Overlay, so all that’s left to do is to set the Web Content overlay to auto play. Now, when I tap the link in DPS, my Connect Mobile app launches, the meeting URL is filled in, and all I need to do is tap Next to log in to the room. Once the session is running, I can use the 4 fingered swipe to switch back and forth between the DPS app and Connect. Pretty neat!

In most cases, you should be able to use Custom URL Schemes on buttons and hyperlinks directly from InDesign. However, you may need to put that URL into a Web Content overlay in order to allow special characters to pass out to iOS, and ultimately to your external app. Of course, it is possible to use JavaScript to dynamically compose a Custom URL Scheme request, so expect some more interesting examples from me in the future.

Share on Facebook

2 Responses to Launching external apps from a DPS folio

  1. RF says:

    Slightly different question (also related to your ADC article). What if from inside the javascript you want to launch out to an http URL in Safari? Doing a window.location.href = url from inside the javascript is fine if the URL scheme is custom but if it’s “http” all it does is to change the content of the web overlay.

    Is there a way to force a launch out to Safari from inside the javascript?

    Thanks!

    • James Lockman says:

      So far as I know, Safari has no custom URL scheme. The OS will direct all http: calls to the default browser, which in the WebKit overlay will be the WebKit overlay. Apple prevents any other behavior unless you jailbreak your iPhone or iPad, which I do not recommend.