Detect if home button is pressed while the app is running in the background - ios

I need a way for my app to know if the home button is pressed, while the app is running in the background. If the home button is pressed, something is gonna be added to a list inside the app. Is that possible somehow?

If your app is in the background, your app wont receive any updates. Furthermore, there isn't any way to hook into the home button click even if your app is in the foreground.
Perhaps there is a private api way to handle this, but your app certainly won't be able to both achieve this goal and be in the Apple App Store. Sorry!
In case you wanted some idea why Apple doesn't allow this, it's because they don't want the home button switch's default behavior to be altered. See this:
10.5 Apps that alter the functions of standard switches, such as the Volume Up/Down and Ring/Silent switches, will be rejected

Related

iOS disable let user swipe the app in background list

In the iOS, when the user double home button , the app show in the list at background.
Have possible hidden my app show in the list, or force the user swiped the app, the app in the background can't close?
I just known applicationDidEnterBackground can do something in the background. But
I wish force the user can't swipe the app in the list or hidden the app in the list, or have some mobile device management method can do this effect(we can use private api)?
I search many time , but I was not found some answer...
thank you very much.
This is not possible in iOS, the user is in control and Apple does not allow your app to hide it self in this list.
If you want this you will need to target jailbroke devices and hook on the task switch. Then detect you app from being closed and restarted it.

Delphi XE6 and NotificationCenter only work with APP open

When I create an app using this component it just send notifications to Android while APP is opened or when she's in the background because I pressed the home button on the phone, if I close the app or exit using the back button notifications are no longer passed to the cell. Is there any way to fix this?
How do you expect for your app to create any notifications if it is not running? Your app needs to be rinning in order to create or post any notivications to the OS.
So now you would probably wanna focus on preventing the app instantly closing when back button is pressed in a way that you notiffy the user that closing the app will prevent its notifications to work and then give your user choice to either close the app or simply keep it workinng in the background.

Detecting home button press on iOS?

Is there any way to detect if the user has pressed the home button on iOS? Obviously if the app is running normally the app delegate methods gets called, but if the device is locked to an app (through Guided Access or an MDM-server) so the app doesn't quit when you push the home button - is there then any way to know if the user pushed it?
My initial thought was to listen for notifications, but I can't seem to see any generated by pressing the home button.
short:
no not on a stock idevice
longer:
on a stock device your best bet is UIApplicationDidEnterBackgroundNotification (Posted when the app enters the background.)
there is no dedicated way to listen for presses to the home button though, so this won't work for GuidedAccess either

Detect Home button long press event in background

How can I detect Home button long press like 4 second or more event in my app which is already running in background? Is it possible to so because app is already running in background and if user long press home button of the device for 4 second or more can i detect the event in my background running app and if possible than will Apple approve this for app store?
No that is not possible. As you should know, a long press on the home button brings up Siri. Your app would interfere with that. Also, I don't believe Apple allows access to the home button event like that.
Lastly; while your app is in the background, it goes into a suspend state after a short while and no events run. The only thing the app can do is receive push notifications - unless you have been given special access to audio / gps functions from Apple themselves.
Short answer : Not possible. not at least with public method and want your app to be on Appstore.
For the Research purpose, you might want to try use private method and do your R&D with it. it might be possible.

Catching hardware buttons on iOS when my app is in background

I would like to execute some code when user presses one of home, power or volume buttons(it doesn't matter, which of these).
I would like to catch events even application is minimized to background and device is sleeping.
So primary task is processing events, when device is inside user's pocket and the user presses button, but not takes out the device.
Is that possible? If it isnt't possible for power button, may be it's possible for volume or home buttons? How can I do it?
Your application cannot interact with the hardware buttons on an iOS device. Your application can receive notification that it has entered the background (which may be a side-effect of the use pressing the home button, for example) but that is about all
There is idea about volume buttons, if you create player instance you can get notifications about volume change, not sure that is still work but you can try.
see answers here: program access to iPhone volume buttons

Resources