How do you open Safari?

I just want to have a button link to an external site, so that when clicked it opens up Safari and goes to the specified URL.

Yep i want the exact same thing for a client i'm making an app for not sure how to do it either.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
local function testNetworkConnection()
    local netConn = require('socket').connect('www.apple.com', 80)
    if netConn == nil then
        return false
    end
    netConn:close()
    return true
end
 
    local DEVICE = system.getInfo ( "environment" )
    local AppURL = "http://url.of.your.choice/"
    if DEVICE == "simulator" then
        print ( "Cannot spawn this URL in the simulator" )
    else
        if testNetworkConnection() then
            system.openURL ( AppURL )
        end
    end

http://developer.anscamobile.com/reference/index/systemopenurl

@robmiracle, why do you need to do all those checks for network connection or simulator environment? I just used a single line (system.openURL("http://www.website.com") and it works fine even in the simulator. Is this just used to make your app more user friendly so you can return a "not connected" type message?

Because it was in the code I stole.. er. borrowed from.

Its basically good practice, as you said, so you can let the user know whats going on.

thanks, this works.

views:1511 update:2011/9/28 9:01:40
corona forums © 2003-2011