Skip to main content

iOS Event Monitoring / Capture / Logging



To monitor what goes on in an iOS app, we need to collect all user interactions. This data will give us an insight into the usage patterns of the users.

We need to collect data about different types of user interactions in the app environment, based on apple documentation, we can find that there are 3 different types of user events that can be triggered:

  • Touch Events using the glass pane, includes various gestures
  • Motion Events using the device’s gyroscope, includes, shake, rotate, etc
  • Remote Events using the remote, like volume up/down buttons.

The above classification is based on the input mode of the events however based on the activity performed, the events are classified into different Gestures. Each gesture is a simple or a composite action made by the user which triggers an expected response from the app.

There are many types of gestures and they are handled in iOS by GestureRecognizers. Gesture Recognisers, capture events which match the predetermined gestures and process them. So if you want to process a touch/tap event, you should get the tap event from initialising the UITapGestureRecognizer and passing the handleGesture message.  

This is the straight forward implementation, however as a third party, we have to get the gestures from a central point where we can collect data about the gesture events but still not intervene with the regular flow of the app.


Approach 1: Attach a subclass of UIApplication in main.m file.

One way to do this according to this stackoverflow post is to attach a custom implementation of the UIApplication class and passing it to the return statement of the main.m file.

The code in the main.m file would be:

return UIApplicationMain(argc, argv, @"MyApplication", @"MyApplicationDelegate");

where MyApplication is the name of the custom class which subclasses UIApplication. In MyApplication class we need to override the sendEvent message definition and handle a log, then pass the event to the UIApplication, through sendEvent message.

- (void)sendEvent:(UIEvent*)event {
    //log the event, call a util class. whatever your app does, then forward to super class

   
[super sendEvent:event];
}


This works for all events, however I found that some apps have their own extension of UIApplication and thus our inject code cannot stay the same, also since we are getting events and not gestures we get a lot of noise. 

For example, we get can get upto two events for a single touch gesture: touch down and touch up, but we want only a single gesture for this event. We may have to get the appropriate event by identifying the touch up event alone, as the touch can be considered complete when the finger moves up after a tap.

Consider a more complex gesture such as a swipe of a pan, each move is considered as a new event and lot of events are generated. Parsing through all of the generated events is non-sensical and time and cpu consuming. Note that we have to complete our task before the event is allowed to do it’s intended action in the app’s interface.


we have to be almost instantaneous or we have to split our code flow into a different processing thread asynchronously, which might not be possible in the UIApplication’s subclass. Now let’s see if approach 2 is any better.


Approach II: Registering our own GestureRecognizers in AppDelegate and then taking the data without disturbing the regular flow of events 

From the start this seems less intrusive, a couple of lines in the app delegate and then voila, it should work.

I will post the details of Approach 2 is a separate post. 

Comments

Popular posts from this blog

Mundasupatti - a fun movie

I saw a movie the other day called Mundasupatti, I’m sure you’ve heard of it if you’re in Tamil Nadu. It was funny, they took a simple superstition which is around and made a fun movie out of it. It was a period film, exploring the 70’s of rural India. I was instantly reminded of swades, a great hindi film which again explores the development gap between cities and villages, it goes a bit further to compare development as seen by an Indian NASA engineer and his old house-hold nanny’s village.  While Swades was a serious film about self empowerment and braking society’s rules about casteism and encouraging education, Mundasupatti is just a funny movie about how stupid, people are.  The movie revolves around a village after which the film is named, the people in the village believe that taking a photograph causes people to get sick and die. The movie did a faithful representation of the rural India, with its proud people and crazy traditions which make no sense. People...

Don't go near cell phone towers...

AMCS/AT – Artificial Mind Control System / Artificial Telepathy Telepathy: Legilimency, Artificial Intelligence The March 23, 1991 ITV news brief "High-Tech Psychological Warfare Arrives in the Middle East" describes a US Psychological Operations (PsyOps) tactic directed against Iraqi troops in Kuwait during Operation Desert Storm. The maneuver consisted of a system in which subliminal mind-altering technology was carried on standard radio frequency broadcasts. The March 26, 1991 news brief states that among the standard military planning groups in the centre of US war planning operations at Riyadh was "an unbelievable and highly classified PsyOps program utilizing 'silent sound' techniques." The opportunity to use this method occurred when Saddam Hussein's military command-and-control system was destroyed. The Iraqi troops were then forced to use commercial FM radio stations to carry encoded commands, which were broadcast on the 100 MHz freque...

She is a very nice girl, I hate nice girls

The protagonist saves a dog from a traffic accident on his first day of high school but ends up breaking his legs. He misses the first couple of months of school and when he joins school again, the students have already settled in and have their own groups. Our protagonist once again becomes a loner. He is not complaining though, he is actually fond of it as it gives him more time to do his personal chores and improve his skills without having to help anyone out. He eventually meets the girl, Yuigahama Yui , whose dog he saved, but only the girl recognises him. Weeks later when he finds that out from someone else, he begins to suspect that Yui is nice to him because of her guilt over the accident which was caused by her dog. He confronts Yui the next day and says that she doesn’t have to feel guilty because of the accident, He did what he thought was right and that he would have been a loner even if the accident had not happened and there was nothing that she could do to ...