This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local model = system.getInfo("model") | |
| -- Are we on the Simulator? | |
| if ( "simulator" == system.getInfo("environment") ) then | |
| M.isSimulator = true | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if ( device.isApple ) then | |
| store.init( "apple", transactionCallback ) | |
| store.restore() | |
| elseif ( device.isGoogle ) then | |
| store.init( "google", transactionCallback ) | |
| store.restore() | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Return the table "M", providing access to it from where the module is "require"d | |
| return M |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| notification = | |
| { | |
| google = | |
| { | |
| projectNumber = "yourprojectnumberhere", | |
| }, | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| elseif ( display.pixelHeight / display.pixelWidth > 1.72 ) then | |
| application = | |
| { | |
| content = | |
| { | |
| width = 320, | |
| height = 570, | |
| scale = "letterBox", | |
| xAlign = "center", |
NewerOlder