Prior to iOS7 it was possible to inject touch events with the GSSendSystemEvent
and GSSendEvent
private API calls, eg:
On iOS7 these calls seem to silently fail though. An alternative has been suggested in Simulating system-wide touches in iOS 7 but it only works on jailbroken devices. https://github.com/kif-framework/KIF looks like another option, but it appears that it only supports injecting events for the current app rather than system wide (so you couldn't inject a touch event while you're app is in the background, for example).
So how can you inject system wide touch events on iOS7, without a jailbreak?
I assume you need to do this system-wide for a testing scenario? In which case you might be well served by Apple's UI Automation framework, a JavaScript-based tool useful for on-device testing.
While you can't do things like simulate a home-button press, you can send your app to the background for a specified duration, for example:
UIATarget.localTarget().deactivateAppForDuration(seconds);
Here are the docs:
https://developer.apple.com/library/ios/documentation/DeveloperTools/Reference/UIAutomationRef
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With