Changes to calling URL Schemes via system.openURL under iOS9

When you you open an app via a URL Scheme - e.g. system.openURL(“myapp://”) -  you can also include parameters e.g.  system.openURL(“myapp://myapp://doca”).

This can be decoded in the app startup function …

local function onSystemEvent( event )

  if event.type == “applicationOpen” and event.url then

    – opened via url scheme

    local launchURL = event.url

    – parse launchURL here to detect parameters

  elseif event.type == “applicationStart” then

  elseif event.type == “applicationExit” then

  elseif event.type == “applicationSuspend” then

  end

end

Runtime:addEventListener( “system”, onSystemEvent )

Do you know what any of the calls are/where i can find out what they are? Like Safari or Pages?

This site has a good catalog of deeplinks for apps. I can’t vouch for their validity, but the listing appears to be relatively comprehensive. 

http://handleopenurl.com/scheme

If you want to use third-party app then Alex has pointed you in the right direction. You refer specifically to Safari and Pages - web pages get opened by system.openURL (and can be local or remote - use http:// prefix). As far as I know you cannot directly call the Pages app by a URL Scheme but mobile Safari will open Pages (and Word or PDF) documents so you can use the same call.

Otherwise read this guide for using your own URL Schemes …

https://coronalabs.com/blog/2011/12/22/using-app-url-schemes-in-ios/

It’s a bit old but still relevant for iOS.

Android Intents now also work. See here …

https://forums.coronalabs.com/topic/37105-handling-url-scheme-on-android/

I’ve been trying to open PDF and Word documents with it (Using system.pathForFile) and it never loads. Any ideas why/Is there anything I’m doing wrong?

system.openURL(system.pathForFile(“MyDocument.pdf”, system.DocumentsDirectory))

OK my mistake - try loading the document into a web view instead (which has the advantage of being resizable to doesn’t have to be full screen but, note, as it is a native object it displays on top of everything else) …

local webView = native.newWebView( display.contentCenterX, display.contentCenterY, 320, 480 )

webView:request( “MyDocument.pdf”, system.DocumentsDirectory )

No, that just presents a large blank white box

I tried a webpopup too and that does the same thing…

Can you post an example of your code?

I created a new project through Corona and just copied and pasted what you’d written into main.lua (I changed the document to one i actually had)

----------------------------------------------------------------------------------------- -- -- main.lua -- ----------------------------------------------------------------------------------------- -- Your code here local webView = native.newWebView( display.contentCenterX, display.contentCenterY, 320, 480 ) webView:request( "websitedesignbrief.docx", system.DocumentsDirectory )

OK I just tried it and it does only seems to work with a PDF file. I have a vague memory of using this method a few years ago but maybe it doesn’t work for local files, only ones on a web server, or something has changed? According to Apple’s documentation the web view should support other document types. 

The alternative is to use the Quick Look plug-in …

https://coronalabs.com/blog/2013/12/24/tutorial-introducing-the-quicklook-plugin-ios/

Note this is iOS only, although I think on Android the OS will try to open a web view document using an appropriate file viewer.

Ok! I’ll give that a go when I get back to work tomorrow! Thanks so much for your help so far :slight_smile:

Regarding .doc/.docx files specifically, the below thread might also be useful:

https://forums.coronalabs.com/topic/59324-read-docx-files/

So the plugin works perfectly! Thank you so much for your help, this has been a major problem for me! :slight_smile: Also, I’m interested in the XML stuff so I’ll take a look into that too. Thank you!

Glad to help!  :slight_smile:

Really helpful write up. I have some doubht about usage of iOS9, this write up help me to clear that.

Thankyou :slight_smile: :slight_smile: :slight_smile: