Applicationresume Event Not Working On Ios?!

‘applicationStart’ is working, but ‘applicationResume’ doesn’t work, I already set “UIApplicationExitsOnSuspend = false”, also it is strange that it actually works on Corona Simulator, but not work on real device (iPhone5/iOS6).

Here is the code: 

local onSystem = function( event )

    if event.type == “applicationStart” then

        system.cancelNotification()

         native.setProperty( “applicationIconBadgeNumber”,0)

    elseif event.type == “applicationExit” then

        print(“exit”)

    elseif event.type == “applicationSuspend” then

        print(“suspend”)

    elseif event.type == “applicationResume” then

        native.showAlert( “Hihi”, “”, { “OK” } )

    end

end

– setup a system event listener

Runtime:addEventListener( “system”, onSystem )

Any ideas??

Thanks. 

can you put some prints in the other parts of the if statement and what gets printed on the console?

Thanks for your advice. I found the following codes in the program (the program is not written by me), once I comment out the 'fb.logout();’, it works, I checked the console, this code crash something, but I don’t understand why there are two section of codes to handle system events, what is the difference between this one and the above one??  Sorry, I am new to Corona. 

local function onSystemEvent( event ) 

    if event.type == “applicationStart” then

        --fb.logout();        

         return true

    end

    if event.type == “applicationExit” then

        --fb.logout();

        return true

    end

end

Also, I found IAP’s prompt messages would also trigger the ‘Suspend’ and ‘Resume’ events, how can I prevent this?

Thanks!!

The IAP suspend/resume is coming from the OS and not Corona. You will also get it for phone calls and Siri too.

How can I differentiate the source of system events?

You can’t. From the OS point of view you shouldn’t care and need to handle every suspended event as if it was your last. The user may choose to quit your app and you will never get a resume event.

But it is just a IAP prompt…

Could you also answer another question above? Thanks. 

can you put some prints in the other parts of the if statement and what gets printed on the console?

Thanks for your advice. I found the following codes in the program (the program is not written by me), once I comment out the 'fb.logout();’, it works, I checked the console, this code crash something, but I don’t understand why there are two section of codes to handle system events, what is the difference between this one and the above one??  Sorry, I am new to Corona. 

local function onSystemEvent( event ) 

    if event.type == “applicationStart” then

        --fb.logout();        

         return true

    end

    if event.type == “applicationExit” then

        --fb.logout();

        return true

    end

end

Also, I found IAP’s prompt messages would also trigger the ‘Suspend’ and ‘Resume’ events, how can I prevent this?

Thanks!!

The IAP suspend/resume is coming from the OS and not Corona. You will also get it for phone calls and Siri too.

How can I differentiate the source of system events?

You can’t. From the OS point of view you shouldn’t care and need to handle every suspended event as if it was your last. The user may choose to quit your app and you will never get a resume event.

But it is just a IAP prompt…

Could you also answer another question above? Thanks. 

I also see there is no “applicationResume” event from iOS devices, why it that?

I remember it was not like this before…

iOS changed something?

my app relies on “applicationResume” to do something, now it’s gone, which caused a bug.

@dev606

The answer to your other question Corona has been ignoring to answer

is that… if you add system event after Facebook is required (require(“facebook”))

You will see no “applicationResume” in iOS.

So the solution is to add system event before Facebook is required. (And I implemented a simple subscriber-notification mechanism for other modules to receive the system events from a single system event listener before FB is required)

Why? I don’t know. I found this out in the hard way. Don’t thank me too much.

Is there a bug report on this?

No, I am reluctant to file new bug reports because I can’t see the bugs I already filed are going to be fixed any time soon.

Besides, I really don’t like Corona relies a lot on end-users (us, as paying customers) to find out the bugs for you. Just like this thread for example, someone already pointed out clearly that the event is missing for iOS, but it seems no one inside Corona cares to dig out further (This problem has been there for an year). Ignoring becomes a norm.

It’s totally fine if this is Corona strategy considering all the business & financial factors running the company. But I just don’t like it.

Besides, I feel Corona has a policy that never promise anything, which is also something I don’t like. I can never see any plan of bug fixing and roadmaps about this SDK future. I will take whatever it is now and make no further hope.

I haven’t used facebook myself yet, but I just tested this and it’s confirmed. If Facebook is required() before adding your own event handlers the applicationResume event fails to dispatch.
 
 
Now I’ll go {OffTopicRant=true}
 
I wouldn’t go so far as to say that CoronaLabs is ignoring anybody.
 
First of all, a single post on a forum doesn’t sound an alarm in the engineering department. There are so many topics posted every day that it’s impossible for CoronaLabs to scour through every single one of them to find potential bugs.
 
Secondly, *any* SDK has bugs and the only way to bring attention to them is to officially report them.
I know it might feel like a pain to file bug reports, but the fact of the matter is if anybody finds what seems to be a bug, it *must* be reported via the “Report a bug” link if you want it to get attention. Only then can CoronaLabs analyze, prioritize and schedule a fix.
It’s as simple as that…
 
{OffTopicRant=false}