Skip to content

Instantly share code, notes, and snippets.

View khaerul10056's full-sized avatar

Khaerul Umam khaerul10056

View GitHub Profile
-- Create a table that will contain all of our tests we are setting up.
local M = {}
-- Set up some defaults...
M.isApple = false
M.isAndroid = false
M.isGoogle = false
M.isKindleFire = false
M.isNook = false
M.is_iPad = false
local model = system.getInfo("model")
-- Are we on the Simulator?
if ( "simulator" == system.getInfo("environment") ) then
M.isSimulator = true
end
if ( (display.pixelHeight/display.pixelWidth) > 1.5 ) then
M.isTall = true
end
-- Now identify the Apple family of devices:
if ( string.sub( model, 1, 2 ) == "iP" ) then
-- We are an iOS device of some sort
M.isApple = true
if ( string.sub( model, 1, 4 ) == "iPad" ) then
else
-- Not Apple, so it must be one of the Android devices
M.isAndroid = true
-- Let's assume we are on Google Play for the moment
M.isGoogle = true
-- All of the Kindles start with "K", although Corona builds before #976 returned
-- "WFJWI" instead of "KFJWI" (this is now fixed, and our clause handles it regardless)
if ( model == "Kindle Fire" or model == "WFJWI" or string.sub( model, 1, 2 ) == "KF" ) then
if ( device.isApple ) then
store.init( "apple", transactionCallback )
store.restore()
elseif ( device.isGoogle ) then
store.init( "google", transactionCallback )
store.restore()
end
-- Return the table "M", providing access to it from where the module is "require"d
return M
function urlencode(str)
if (str) then
str = string.gsub (str, "\n", "\r\n")
str = string.gsub (str, "([^%w ])",
function (c) return string.format ("%%%02X", string.byte(c)) end)
str = string.gsub (str, " ", "+")
end
return str
end
local didOpenGoogleMaps =
system.openURL("comgooglemaps://?daddr=San+Francisco,+CA&saddr=cupertino")
if ( didOpenGoogleMaps == false ) then --defer to Apple Maps
system.openURL("http://maps.apple.com/?daddr=San+Francisco,+CA&saddr=cupertino")
end
notification =
{
google =
{
projectNumber = "yourprojectnumberhere",
},
},
elseif ( display.pixelHeight / display.pixelWidth > 1.72 ) then
application =
{
content =
{
width = 320,
height = 570,
scale = "letterBox",
xAlign = "center",