Created
November 28, 2012 06:35
-
-
Save cjanis/4159433 to your computer and use it in GitHub Desktop.
Corona SDK Rating Prompt
This file contains 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
-- show rating prompt | |
local function ratingPrompt() | |
local function ask() | |
local function answer(event) | |
if ("clicked" == event.action) then | |
if (event.index == 1) then | |
system.openURL("http://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=440754678") | |
data.rated = "yes" | |
writeData() | |
elseif (event.index == 2) then | |
elseif (event.index == 3) then | |
data.rated = "never" | |
writeData() | |
end | |
end | |
end | |
if (data.rated == "no") then | |
local alert = native.showAlert("Welcome back!", "You've played \"The Playmatic\" several times now, you must like it! Will you please take a moment rate it in iTunes?", { "Sure!", "Maybe Later", "Don't Ask Again" }, answer) | |
end | |
end | |
for i = 1, 30 do | |
if (data.visits == (i * 3)) then | |
ask() | |
end | |
end | |
end | |
-- iterate visit count | |
local visitCounter = function(event) | |
if (event.type == "applicationStart") or (event.type == "applicationResume") then | |
if (event.type == "applicationStart") then | |
data.visits = math.ceil(data.visits + 1) | |
elseif (event.type == "applicationResume") then | |
data.visits = data.visits + 0.25 | |
end | |
writeData() | |
ratingPrompt() | |
end | |
end | |
Runtime:addEventListener("system", visitCounter) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment