Swift, IOS, Detect power button pressed 3 times - ios

I want to do something like getting an event when a user has pressed the power button 3 times within 5 or 10 seconds.
Think of this like an SOS / emergency call. If the user pressed 3 times power button then I want to trigger a sound or alarm from within the app.
Can anyone suggest an alternative option if this is not possible. Can we get an event call multiple times when the method applicationWillResignActive occurs?

Related

Disable button good practice in IOS?

I currently have a UIButton in my app when clicked, starts running a block of code that takes awhile to finish so I run it on another queue.
I would like to keep the button enable so that if the user clicks the button in 2 quick succession for example, I would ignore the data returned from the first click and just use the data from the second click. My problem is that I'm worried that the user might click the button 20 or 30 times and my app would create 20-30 queues which would slow the execution?
How would I be able to deal with this? I feel like disabling the UIButton after 1 click is not a good solution.

Making the iPhone vibrate continuously till the button is pressed

I am trying to make the phone vibrate for the duration till the user keeps a button pressed. I am able to make it vibrate with the user touches it once using AudioServicesPlayAlertSound(SystemSoundID(kSystemSoundID_Vibrate)) but that generates 0.4 seconds of vibration followed by 0.1 seconds of silence.
Is there any way I can produce a continuous vibration for, say 3 seconds, while the the user keeps pressing the button? And also, how to implement this only till the user is pressing the button?
And yes, I know that Apple will reject this app if I submit it to the App Store, so please refrain from telling me that.

Neither touchUpInside nor toutchUpOutside is called on palm press/lift over several buttons

I am implementing an IOS APP with a view that provides a keypad for controlling a remote device and if you push on 6 or 8 (UI) buttons at the same time by using your palm then the App gets a touchDown but does not receive a touchUpInside or touchUpOutside when you lift the palm.
Problem is I start a timer upon the touchDown to repeat keys, but I never get a callback to end key repeats. Does anybody know how to deal with this.
I realize this is an anal scenario, but if repeats don't stop on time then expensive equipment could be damaged.
I am not sure this has any bearing on the situation but I am using ios 6 on an iPhone 5.
Is touching them at the same time also a requirement? If not, set exclusiveTouch to YES on all buttons. If yes, check UIControlEventTouchCancel as well.

Is there an easy way to detect *any* (and all) user activity?

If the user interacts with my app in any way at all I want to restart a force logoff timer.
Any menu item, any button clicked (not sure about just click on the form).
Is there an easy way to detect that the user is still "active"?
This component is exactly what you are looking for. It is called ETimer and can be found here
Basically just put the timer on a form and set its interval for like 1000 ms, then in the timer event check the Snooze property of the timer, if the snooze property is greater that 60000 (1 min) then you know that the app has had no user interaction for 1 min.
It pretty easy to use but let me know if you get stuck.

UILocalNotification - Need to vibrate for a longer duration during the alert / notification

Overview
In my iOS project, I am using UILocalNotification,
when a notification is fired, a custom sound is played.
the custom sound plays for about 20 seconds,
the phone vibrates only once at the start
What I want to do:
Presently the phone vibrates only once at the start. I want it to vibrate repeatedly for 20 seconds just like in Apple's alarm / Timer app before the user pressed on the action button ?
Question
During the alert is it possible to make the phone to vibrate for the 20 seconds before the user can attends to the notification or clicks on the action button ?
Problem
Since my app doesn't have any control till the user presses on the action button I am not sure how I can make it vibrate
The app might be closed when the notification is pops
Is there a way to do this ?
Schedule a timer that invokes the vibration function several times with some delay between calls. Don't forget to add an option to disable the vibration, cause you might get your app rejected from the app store because of this.

Resources