I have an application running in background. This application needs to generate a touch event at a particular xy co-ordinates, so that the application running in foreground behaves as a user actually touches the screen. Is it possible to generate touch events like this. Please help
+1
A:
No, iPhone background applications can't interact with anything.
Steam Trout
2010-08-03 08:59:43
Thanks Steam, Is it possible to fire a touch event at position if we know the x,y coordinates as we simulate mouse click in windows.
Alina
2010-08-03 09:18:14
You can use `- [UIApplication sendEvent:]` to send events however I can't remember off top of my head how to create a touch event with given coordinates or if it is even possible without subclassing.
Steam Trout
2010-08-03 09:31:17
Using [UIApplication sendEvent] we can fire touch events within the application right? Is it possible to fire events at os level. My idea is like if a touch event is fired at os level from background app, will it be behave like a touch sensed on foreground application. If there is any mistake in concept please forgive.
Alina
2010-08-03 09:56:21
Yes, using UIAppplication you can fire events within the application only. To my knowledge there is not "legal" way to fire events between the applications on the iPhone.You may try to work around it by using NSDistributedNotificationCenter to fire the notification with packaged event from the background app and then re-send it inside your foreground app using UIApplication.
Steam Trout
2010-08-03 11:16:56
@Alina - Even synthesizing UITouch events in this manner is going to lead to App Store rejection, because you will need to use private APIs to do so. There is no way currently to do what you want within an application you intend to put on the store.
Brad Larson
2010-08-03 12:31:54