applicationOpen event not firing

I am currently implementing Facebook deep linking in my app using a URL scheme. I’ve gotten everything to work from a cold start (i.e. not from suspended state): I click on open graph object in my Facebook news feed and it takes me directly to the object in the app.

However, I can’t get this functionality working when the app resumes from a suspended state. The link still opens my app, but only an applicationResume event fires, not an applicationOpen event; and since there’s no corresponding event.url for the applicationResume event, there’s no data for me to parse and direct the user to the requested page.

Any advice would be appreciated. [import]uid: 44153 topic_id: 29587 reply_id: 329587[/import]

I’m not sure what you’re expecting but there is no applicationOpen event. There is an applicationSuspend and applicationResume “type” that is part of the “system” event. http://developer.coronalabs.com/reference/index/eventtype-0 [import]uid: 7559 topic_id: 29587 reply_id: 118807[/import]

Please take a look at these links (I didn’t make this event up):

http://www.coronalabs.com/blog/2011/12/22/using-app-url-schemes-in-ios/

http://docs.coronalabs.com/api/event/system/type.html

http://docs.coronalabs.com/api/event/system/url.html

[import]uid: 44153 topic_id: 29587 reply_id: 118808[/import]

This probably isn’t ideal, but could you force the app to NEVER suspend, using the config and build settings, thus it quits every time and always starts “cold”? You could then use the simulated save-state methods discussed in a recent blog post to make the app appear as if it was suspended by iOS, even though it wasn’t. This would provide your “open” URL parameters every time. Again, I know it’s not ideal, but it might be your only option in this case. :frowning:

Brent [import]uid: 9747 topic_id: 29587 reply_id: 118820[/import]

@Brent

Thanks for the response. That was my first thought too, but like you said, it’s definitely not ideal. My specific concern is how such an approach would affect my Facebook single sign on (SSO) implementation. [import]uid: 44153 topic_id: 29587 reply_id: 118895[/import]

Hi,

I have the exact same problem. And a cold start is not an option. You have documented in the above mentioned blog posts that it should be done like this:

local function onSystemEvent( event )
if event.type == “applicationOpen” and event.url then
printURL( event.url )
end
end

Runtime:addEventListener( “system”, onSystemEvent )

We have spent a huge amount of time implementing Facebook InviteRequests and having the server autmatically set up 2-player games when two users connect, and then in the end it turns out it will only work on cold start.

This must be fixed immediately in the next daily build. [import]uid: 21746 topic_id: 29587 reply_id: 123920[/import]

Has anyone filed a bug report with a project showing the problem? Without a bug case with code to demonstrate the problem, it won’t get fixed.

The forum is great for exchanging ideas and helping to determine if a bug really exists, but it’s not the same as submitting a bug to be fixed. Our bug reporting system is the only way we can handle and track all the bugs that we receive. [import]uid: 7559 topic_id: 29587 reply_id: 123924[/import]

The only way you guys fix anything is by having your users pay for PREMIUM support, so no one, except from those new to Corona, bothers to file bug reports anymore. [import]uid: 21746 topic_id: 29587 reply_id: 123926[/import]

Hi @haakon,

Can you please describe in more detail how your app is designed? Regardless of a “cold” or “warm” start, what happens when your app is started? Does it immediately try to connect to another (networked) user, before a menu screen or anything is shown?

If it’s a “warm” start, do you try to re-initiate a networked session between the 2 players that were previously playing? Is this a turn-by-turn game like “Words With Friends” where one player might not log in for hours (or days) before making his/her turn?

I’m just curious how your app is designed, and if a workaround might be coded to deal with the issue you’re having…

Thanks,
Brent
[import]uid: 9747 topic_id: 29587 reply_id: 124020[/import]

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]

I see your point and the associated issue. I’ll file a bug report on your behalf. Bug reports do, in fact, get put before the engineering team… if they didn’t, Corona would have devolved into an unusable SDK long, long ago.

Brent Sorrentino
[import]uid: 9747 topic_id: 29587 reply_id: 124102[/import]

Please let us know the bug number so we can keep an eye out in the daily builds section. Thanks! [import]uid: 44153 topic_id: 29587 reply_id: 124125[/import]

Hi,

I have the exact same problem. And a cold start is not an option. You have documented in the above mentioned blog posts that it should be done like this:

local function onSystemEvent( event )
if event.type == “applicationOpen” and event.url then
printURL( event.url )
end
end

Runtime:addEventListener( “system”, onSystemEvent )

We have spent a huge amount of time implementing Facebook InviteRequests and having the server autmatically set up 2-player games when two users connect, and then in the end it turns out it will only work on cold start.

This must be fixed immediately in the next daily build. [import]uid: 21746 topic_id: 29587 reply_id: 123920[/import]

Has anyone filed a bug report with a project showing the problem? Without a bug case with code to demonstrate the problem, it won’t get fixed.

The forum is great for exchanging ideas and helping to determine if a bug really exists, but it’s not the same as submitting a bug to be fixed. Our bug reporting system is the only way we can handle and track all the bugs that we receive. [import]uid: 7559 topic_id: 29587 reply_id: 123924[/import]

The only way you guys fix anything is by having your users pay for PREMIUM support, so no one, except from those new to Corona, bothers to file bug reports anymore. [import]uid: 21746 topic_id: 29587 reply_id: 123926[/import]

Hi @haakon,

Can you please describe in more detail how your app is designed? Regardless of a “cold” or “warm” start, what happens when your app is started? Does it immediately try to connect to another (networked) user, before a menu screen or anything is shown?

If it’s a “warm” start, do you try to re-initiate a networked session between the 2 players that were previously playing? Is this a turn-by-turn game like “Words With Friends” where one player might not log in for hours (or days) before making his/her turn?

I’m just curious how your app is designed, and if a workaround might be coded to deal with the issue you’re having…

Thanks,
Brent
[import]uid: 9747 topic_id: 29587 reply_id: 124020[/import]

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]

I see your point and the associated issue. I’ll file a bug report on your behalf. Bug reports do, in fact, get put before the engineering team… if they didn’t, Corona would have devolved into an unusable SDK long, long ago.

Brent Sorrentino
[import]uid: 9747 topic_id: 29587 reply_id: 124102[/import]

Please let us know the bug number so we can keep an eye out in the daily builds section. Thanks! [import]uid: 44153 topic_id: 29587 reply_id: 124125[/import]

Yeah, once again I have pulled up my Credit Card to PAY Corona Labs for fixing their own bugs, so expect to see this fixed in a daily build in a couple of days.

I HATE the way Corona Labs treat their customers (us), but unfortunately we’re stuck with your SDK for a while and just have to take what we get. We’re not your best ambassador, though. [import]uid: 21746 topic_id: 29587 reply_id: 124750[/import]