Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

iOS and MacOS / How to catch when your iOS app gets sent to the background

Author
Message
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 10th Jul 2012 22:19 Edited at: 10th Jul 2012 22:43
In theory the agk command 'GetResumed()' would let you know that you have come back from the background.

However, it only works on Android devices.

I found how (in Tier 2) to catch when the app is going to the background and let you do things like pause it actively (stop things doing stuff).

EDIT: I had to do a fix to make an error go away when executing.

This is the updated template.h file:


This is the updated template.cpp file (with a simple message to show that it works):


Then, you make this mod in the Core.m file:


I went with the applicationWillResignActive function instead of applicationDidBecomeActive because that one triggers when the app starts up, not just when it had been in the background.

Steve/Paul, might this be some help getting the 'GetResumed()' command to work for iOS?

Cheers,
Ancient Lady
AGK Community Tester
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 11th Jul 2012 00:22
GREAT!

lots of
anwserman
12
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 19th Jul 2012 12:50
Congratulations, Ancient Lady. I pointed you in the right direction but you still did all of the hard work

Hi there. My name is Dug. I have just met you, and I love you.
FakeBlood
21
Years of Service
User Offline
Joined: 18th Nov 2002
Location: Alabama, United States
Posted: 20th Jul 2012 02:23 Edited at: 20th Jul 2012 02:23
So is AppGameKit not able (in current state T1 or T2) to pause and resume apps on the iphone(other iOS devices) when leaving and going back to the app?

That's a crippling issue if so.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 23rd Jul 2012 17:22
On an iOS device, the app does pause and resume when sent to the background.

But there had not been a way to tell that you'd been paused, so your game starts back up exactly as it had been.

If you have a game that has dynamic motion, this might catch you by surprise.

Cheers,
Ancient Lady
AGK Community Tester
erebusman
12
Years of Service
User Offline
Joined: 23rd Jul 2011
Location: Sacramento, CA
Posted: 18th Nov 2012 05:26
I have an issue on the opposite end of this spectrum and when searching for it found this thread ; so maybe you know Ancient Lady ...

My Android app keeps playing music after its been sent to the background.


I know how to do GetResumed() .. which I would do if it was stopping and not coming back on after resuming.

But I can't find a command for "getsenttobackground" or whatever its going to be called .. I would like to stop the music when its sending to the background.

Its quite irritating to have the music keep going and going when the app is in the background!

Any ideas?

erebusman
12
Years of Service
User Offline
Joined: 23rd Jul 2011
Location: Sacramento, CA
Posted: 18th Nov 2012 20:23
So I found how android handles this; I just cant find how AppGameKit handles it:


From
http://developer.android.com/reference/android/app/Activity.html



onPause() is where you deal with the user leaving your activity. Most importantly, any changes made by the user should at this point be committed (usually to the ContentProvider holding the data).


This is exactly what I need just dont see how AppGameKit addresses this.

erebusman
12
Years of Service
User Offline
Joined: 23rd Jul 2011
Location: Sacramento, CA
Posted: 18th Nov 2012 20:24
And finally seeing how this thread is in iOS I'm going to post a separate thread in Android as my questions are more android specific at this point - sorry I found the thread via search and didnt notice at first it was an iOS thread specifically.

Login to post a reply

Server time is: 2024-04-20 16:30:57
Your offset time is: 2024-04-20 16:30:57