How can I simulate the touch events by IOHIDEvent? - iphone

I want to simulate touch events on iOS 6. I learned something useful from IOHIDEvent, which is a low-level functions bundle for human interface devices.
From: https://github.com/kennytm/iphone-private-frameworks/tree/master/IOKit/hid I got the private framework with IOHIDEvent, but the headers were changed after iOS 4, and some functions were not supported any more.
Does anyone know how to get the functions in iOS6, or known how to simulate the events at system-level?

As I mentioned in my answer to your other question today, you might try looking at GSEvent.h from GraphicsServices.framework, or in IOKit.framework.
Here are some good answers on stackoverflow to help you:
iOS Private API: lock device and power off the screen
GSSendEvent - Inject Touch Event iOS
iOS touch event notifications (private API)

May be UIAutomation helps you http://developer.apple.com/library/ios/#documentation/DeveloperTools/Reference/UIAutomationRef/_index.html ?
Or UISpec: http://code.google.com/p/uispec/wiki/Documentation

If you want to simulate touch events at the system level, you have to jailbreak your device.
Check this:
Simulate Touch Event on iOS - jailbroken - iOS13+
Is possible to simulate touch event using an external keyboard on ios jailbroken?

Related

Getting notification of iOS device usage in background

Might be i am using a wrong title but i will try to explain here what i want.
In iOS i need to implement a functionality to get notify if the user is using their iOS device.
My app will be running in background using location services and i need to find out if the the user is using their device. It is doable as i have looked into this application which is sending notifications in background to the drivers who is suing their devices while driving.
https://itunes.apple.com/fr/app/cellcontrol/id661169580?l=en&mt=8&ign-mpt=uo=2
So i need similar kind of functionality to find out if a user is using iOS device or not. If anyone of you can suggest me any approach then it would be great for me to start.
Thank you!
Note: I have tried to find out touch events in background but that is not possible as i have done some research on this.
You won't be able to receive touch events when the app is in background using public API's. However, you can do that with the help of mobileSubstrate library ( http://iphonedevwiki.net/index.php/MobileSubstrate - The MobileHooker component is the one that would be used). by hooking your process to the OS. As an example, the display recorder app in Cydia tracks global gestures while recording the screen. This will be a cydia tweak and you will need to jailbreak your device to do all that.
Coming to your specific use-case, the example app you cited should be using one of the exceptions for background applications mentioned in https://developer.apple.com/library/ios/documentation/iphone/conceptual/iphoneosprogrammingguide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html (see the section - "Implementing Long-Running Background Tasks"), probably the one to receive updates from external accessories.

How to capture and record iOS Touch Events at system level?

I want to capture all the touch events at the system level, I do not mean capturing at one specified app, but all the apps even the SpringBoard.I tried IOHIDEvent(https://github.com/kennytm/iphone-private-frameworks/tree/master/IOKit/hid), but the runtime headers was changed after iOS4, and now I can not get them of iOS6.
May be GSEvent is also a good way, but does anyone known how to do this by GSEvent?
Thank you!
Take a look at EntryDevLevel excellent answer here on how to capture and record clicks on iOS using iOHID:
iOS touch event notifications (private API)
BTW. His solution works on non jailbroken iOS either.

Check if iPhone 4 or not

I would like to check if the user is using an iPhone 4 or not. How can I do that ?
Thanks !
Sebastian
Apple specifically recommends against this, instead preferring that you check for individual features and act according to these. This makes your life a lot easier when Apple releases new hardware; if for instance Apple releases an iPod Touch with a camera, and you need a camera for your app, your users wont be upset that it tells them "No camera found" when it does have one, all because it reports as not an iPhone. Here is one way to require all the differentiating hardware features. Do not use these for enabling/disabling features that are supported but not required: this can be determined at runtime through the APIs used to interact with that feature.
UIDevice (see here, also the docs) can help you determine if it is an iPhone, but again, don't do this.
To detect the difference between the iPod Touch and the iPhone, we use
if(![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
There might be something similar to check for a the forward camera.

How to send a touch event to iPhone OS? [duplicate]

This question already has an answer here:
Is possible to simulate touch event using an external keyboard on ios jailbroken?
(1 answer)
Closed 2 years ago.
Im writing an app running in background on a jailbreak iphone. I need to send touch event to iPhone OS to simulate finger touches. Is this possible?
See Matt Gallagher's article "Synthesizing a touch event on the iPhone". You may also check out the Three20 framework, which I believe used synthesized touch events to test UI elements (leading to a rash of recent application rejections due to the use of private APIs).
Yes it is possible, using GSEvents. Try the KennyTM's private framework and GSEvent.h. It is under the GraphicServices framework.
https://github.com/kennytm/iphone-private-frameworks

iPhone Apps running on iPod Touch

If I create an App for the iPhone (OS 3) will it run without modification on an iPod Touch or will I need to create a separate binary? If it is the same runtime, does it just have stubs for the iPhone only features or do you have to check feature by feature using UIDevice to ensure the particular class/method is supported on the device to avoid a crash?
Sorry for the elementary questions, can't find a simple explanation of this anywhere.
Cheers
Dave
EDITED: Based on discussions below:
How can you check if a device supports making calls? At the moment I am assuming if it is an iPod Touch it can't. Is there a way of finding out what shared applications/URL schemes are supported by a device?
You shouldn't really try to guess what the device is. You're far more future-proof if you test for the specific functionality you're trying to use. After all, in the future there might be iPods with cameras. Or compasses (which are on some iPhones but not others).
Since it sounds like all you want to do is see if you can open a URL, why not use -[UIApplication canOpenURL:] ? (This would presumably work on iPod touches that had applications that could handle VOIP -- I don't know if any such exist, but I think it's an example of why you need to test for functionality and not make assumptions based on hardware or OS version.)
The app will run on an iPod touch, no need to compile a separate version. Features that require an iPhone (e.g. camera) will not work, obviously.
What such features do you intend to use? You may provide alternatives for iPod users or alert them that e.g. no camera is available.
This question adresses how to check if a microphone is present: Detecting iPhone iPod touch accessories