Implement touch system events on iOS7

Prior to iOS7, you could enter touch events using GSSendSystemEvent and GSSendEvent private API calls, for example:

  • GSSendEvent - Inject Touch Event iOS
  • Modeling System Wide Touch events on iOS
  • System-wide crane modeling on iOS
  • Send global touch event to iOS 6

In iOS7, these calls seem to be silent. An alternative was suggested in Simulate 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 seems to only support injection events for the current application, and not the whole system (so you can't enter a touch event when you are in the background, for example).

So, how can you enter system events with a touch screen on iOS7 without jailbreak?

+48
ios objective-c iphone ios7 iphone-privateapi
Oct 19 '13 at 21:53 on
source share
3 answers

I assume you need to do this system-wide for a test scenario? In this case, you might be well provided with the Apple UI Automation infrastructure, a JavaScript-based tool useful for testing on a device.

While you cannot do things such as simulating a home button, you can send your application to the background for a certain duration, for example:

UIATarget.localTarget().deactivateAppForDuration(seconds);

Here are the docs:

https://developer.apple.com/library/ios/documentation/DeveloperTools/Reference/UIAutomationRef

+2
Jan 31 '14 at 11:41
source share

You can subclass UIWindow and overwrite sendEvent. I use it to implement a pattern of multiple listeners, but you can also use it to fire events ...

 - (void)sendEvent:(UIEvent*)event { [super sendEvent:event]; //NSLog(@"NSEventListenerWindow.sentEvent: %@\n", event); // pass all events on to those who listen for ( id listener in listeners) { if ([listener respondsToSelector:@selector(sendEvent:)]) { [listener sendEvent:event]; } } ..... 
-four
Nov 14 '13 at 18:03
source share

I think you would be better off using the IIS SDK Notification api service. This will be the cleanest way to achieve what you want.

Conceptually, Apple does not intend (third parties) to release system events, since this will not go well with the iOS thorough training model, so people resort to private APIs and jailbreaks. Private APIs, as the name suggests, should not be relied upon.

Think of it this way, unless you are responsible for the whole system that the user application cannot be, you really don't have any business system events. I know how Android does it, but this is another story (not suitable for this topic).

On a Mac, the XPC Services api allows processes to interact with each other, but not quite the way events are generated in the system. I would advise you to use the iOS SDK notification API, which would probably be the cleanest method to achieve what you want. Yes, he goes to Apple and returns to the device, but the mechanism that is still available.

-5
Jan 08 '14 at
source share



All Articles