What i want : When my app goes in background and user opens any other app then i should be notified that some other app is opened.

How i am trying to do :
Run a thread in background say for 2 hrs, this thread will check what other app is opened.This does not happens always , only when certain condition is met.

How i am trying to achieve this : i am using

UIBackgroundTaskIdentifier & beginBackgroundTaskWithExpirationHandler

The thread runs endlessly but i dont think its the right way coz apple suggests it should not be done, threads gets killed after 10 mins, however this funda is woking fine for me still i wanna use more secure way to achieve this.

I also checked background modes and some new modes available in ios 7.0 but still cannot find which mode to be used to achieve this [for a particular session/condition, when app goes in background and remains there for 2 hrs i get notification that some other app is opened instead of homescreen].

Any idea how to achieve this.
Just wanna know how to achieve the background work to receive notifications that some other app is opened.

1 Answer
1

What are you using to be notified that your "other app" is running in the foreground ?

1- (UIBackgroundTaskIdentifier)beginBackgroundTaskWithExpirationHandler:(void(^)(void))handler NS_AVAILABLE_IOS(4_0);
So after about 600 seconds your handler Block will be called as your app will be killed soon,
in handler Block you can renew for an other 600 seconds with 'UIBackgroundTaskIdentifier & beginBackgroundTaskWithExpirationHandler' and so on…

BUT this might drain the Battery and Apple could not like it!

2- "...to receive notifications that some other app is opened." I DONT THINK APPLE (iOS) WILL LET ANY APP DO THIS!

BUT if "some other app" is an app you control then:
"one solution to transmit data from one to another app is via URL Schemes" !