×
A new build of Corona SDK is now available to subscribers. Not a subscriber? Subscribe now.
CoronaSDK 2012.821 | Released: 23 May 2012, 2:01am | What's New | Download Now

system.openURL()

Description:

Open a web page in the browser; create an email; or call a phone number.

Note: Executing this function will close the app and switch to the built-in browser, email or phone app.

Syntax:

1
system.openURL( url )

Example:

system.openURL( "http://www.anscamobile.com" ) -- open URL in browser

Parameters:

url

url can be one of the following:

  • Email address: "mailto:nobody@mycompany.com"
    • The email address url can also contain subject and body parameters, both of which must be url encoded. Example: "mailto:nobody@mycompany.com?subject=Hi%20there&body=I%20just%20wanted%20to%20say%2C%20Hi!" Try this URL encoder to encode your text.
  • Phone number: "tel:415-867-5309"
  • Web link: "http://www.anscamobile.com"
Returns:

Nothing.

Remarks:
Supported on operating systems and platforms for build numbers shown:
  • Mac OS X:
    Corona SDK 1.0
  • Windows:
    Corona SDK 2.0
  • iOS:
    Corona SDK 1.0
  • Android:
    Corona SDK 2.0

Replies

richard3's picture
richard3
User offline. Last seen 1 week 2 days ago. Offline
Joined: 27 Jan 2011

It would be nice to be able to see if a certain app is installed.
To do this other schemes would need to be supported.

A native call to [[UIApplication sharedApplication] canOpenURL:url]

Maybe some sort of callback with urlRequest...

iwoof@yahoo.com's picture
iwoof@yahoo.com
User offline. Last seen 1 day 12 hours ago. Offline
Joined: 21 Jan 2011

I could use that ability as well.

Perhaps built into network.setStatusListener() which could return the reachability of the URL scheme in the callback with something like event.canOpenURL

--Woof!

jwwtaker
User offline. Last seen 9 hours 1 min ago. Offline
Joined: 28 Apr 2010

Is there some way to open an email and embed in the email body an attachment of a screenshot?

koolou7
User offline. Last seen 1 week 1 day ago. Offline
Joined: 25 Apr 2011

Have the same question with jwwtaker.

Ninja Pig Studios's picture
Ninja Pig Studios
User offline. Last seen 10 hours 35 min ago. Offline
Joined: 26 Jan 2011

Tel: doesn't work on Android. Has anyone had any luck with it?

Regards,
Jordan Schuetz
Ninja Pig Studios

cbartlett
User offline. Last seen 1 week 17 hours ago. Offline
Joined: 10 Feb 2011

On android if you do
system.openURL( "market://details?id=com.yourdoman.packagename" )

It will link directly to an apps market page.
Usefull for promoting any other apps you might have.

bogeybox
User offline. Last seen 13 hours 49 min ago. Offline
Joined: 27 Jul 2011

This function returns a boolean (contrary to what is stated here) which can be used to check if an app is installed. for example

local isAppInstalled = system.openURL("skype://")
if isAppInstalled == false then
--open appstore for skype if it is not installed
system.openURL("http://itunes.apple.com/br/app/skype/id304878510?mt=8")
end

Tested on build 732

liongera
User offline. Last seen 2 weeks 4 days ago. Offline
Joined: 4 May 2011

Does anyone find a workaround to make calls from an android device?

Pathfinder
User offline. Last seen 16 hours 45 min ago. Offline
Joined: 20 Jan 2012

I was able to get phone calls working on Android with the following permission in my build.settings file:

1
2
3
androidPermissions = {
  "android.permission.CALL_PHONE"
}

Also, in case anyone is wondering how to do extensions, you can use a ; after the telephone #:

1
"123-456-7890;7777"