1

I am currently developing an "in device" (not simulator) monitoring system for an iPad app. The system should be able to do the following:

-User input simulation: Simulate user inputs: taps, drags, keyboard.

-Information recollection: Get text values and results after doing inputs.

This information will be later reported to an event management server. I have already taken care of the two points in a single app, by using some code from KIF software https://github.com/square/KIF and some self developed code. I use the accessibleName property of the UIView objects to get their pointer and send artificial events to the [[UIApplication sharedApplication] sendEvent:] method.

Here’s the thing: I need to send these events from app#1 in which I am, to app#2. (To keep the monitoring independent, also embedding all the code in app#2 is not an option) I use the [[UIApplication sharedApplication] openURL:] method to open the app#2. https://developer.apple.com/library/IOs/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/AdvancedAppTricks/AdvancedAppTricks.html#//apple_ref/doc/uid/TP40007072-CH7-SW18

The problem is, I cannot send events from app#1 to app#2 because I cannot seem to get the pointer to the [UIApplication sharedApplication] object of app#2 in the app#1 code.

A shared memory communication between the processes would be great, but according to the information that I found, the URL messaging scheme seems to be the only communication between apps (or processes) in iOS. The NSConnection class is also not present in iOS. I've also read a little bit about Mach ports and POSIX file descriptors, but they seem fairly complicated and I have no idea if they can help.

I even tried to send the value of the pointer of the app#2 [UIApplication sharedApplication] instance as a string parameter in the URL message, then converted the string back to a pointer in app#1, but got a EXC_BAD_ACCESS. I suppose the pointer address does not mean the same in both processes. Maybe each process has its own "offset"? Any help would be greatly appreciated.

Jorge Aguirre
  • 2,787
  • 3
  • 20
  • 27

1 Answers1

2

In first instance I wold clarify that what you want to do is not possibile without private APIs. Each app is sandboxed and you cannot access to other apps (directly). I think that your problem is really big.

Each app running in iOS is like small, independent, eco-system that ends when the user press the 'Home' button (except if you declare some background services like VOIP, localization or audio player). Once the app has been closed the only thing that you can still run is a process that should not be longer than 10 mins. This is to prevent an excessive usage of background tasks and even here, the app isn't accessible from other apps.

I think the only way is to search for private APIs, hoping someone else already found a way to create a data streaming (directly) between 2 apps.

bontoJR
  • 6,995
  • 1
  • 26
  • 40
  • Yes, this is not possible without private APIs. Actually, the KIF itself does use private APIs to fake tap events. This is not a problem, since this code or app will not be submitted to the app store. It is just for monitoring and surveillance purposes. I tried the background approach (calling [UIApplication sharedApplication] when app#1 is in background and app#2 is active) but it returned app#1's UIApplication instance. Do you think one of those APIs already exists? Is it done with Mach ports or POSIX file descriptors, or Distributed objects? Thanks for your help. – Jorge Aguirre Mar 01 '12 at 13:56
  • 1
    Yes, I'm sure that you can access an app from another app. And [this post](http://stackoverflow.com/questions/4312613/can-we-retrieve-the-applications-currently-running-in-iphone-and-ipad) could be a good place to start playing with private APIs and then find a way to access the memory of the other app. – bontoJR Mar 01 '12 at 14:01