Hi,
it is a turn-based game, but with a server between, not device-to-device.
I doubt there is a work-around, other than exit on suspend, which is not an option, since that will kill some other functionality like the possibility to use the photo album or camer app to upload user avatars.
The only way to deal with this is that you fix your SDK to work like you document. We need the facebook url scheme to work on warm start, not only cold start. We use the url scheme to collect info about the facebook invite request clicked (we parse out the request_id from the URL scheme) and call our server with the request_id to create a game between the two players.
[code]
– Resume game
local function onSystemEvent(event)
if event.type == “applicationOpen” and event.url then
AutomaticFaceGame:Setup(event.url)
end
end
– Automatic Face Game class
AutomaticFaceGame = {}
function AutomaticFaceGame:Setup(fburl)
local function decode(s)
local function unescape(s)
s = string.gsub(s, “+”, " ")
s = string.gsub(s, “%%(%x%x)”, function (h)
return string.char(tonumber(h, 16))
end)
return s
end
local target_url = nil
for name, value in string.gfind(s, “([^&=]+)=([^&=]+)”) do
if name == “target_url” then
target_url = unescape(value)
break
end
end
if target_url then
local request_ids = nil
for name, value in string.gfind(target_url, “([^&=]+)=([^&=]+)”) do
if string.find(name, “request_ids”) then
request_ids = value
break
end
end
return request_ids
end
return nil
end
local request_id = decode(fburl)
if request_id then
local function requestListener(event)
if not event.isError then
result = json.decode(event.response)
if result then
if result.success then
ui.newNotification(result.message)
_G.doManualPoll()
elseif result.error then
ui.newNotification(result.error, “error”)
end
else
native.showAlert(“Error”, event.response, {“OK”})
end
end
end
local post_data = “user_id=” … url.escape(_G.user.id)
post_data = post_data … “&request_id=” … request_id
network.request(_G.server … “facebook/setup_game”, “POST”, requestListener, {body = post_data})
else
print(“No request id…”)
end
end
Runtime:addEventListener(“system”, onSystemEvent)
[/code] [import]uid: 21746 topic_id: 29587 reply_id: 124027[/import]