thej
thej

Reputation: 648

how to listen to notification in notification bar when application is in background in Iphone

In my application I want to listen to notification bar when my application is running in background. I want to do some action when I receive that notification. Can any one tell me how can I listen to notification bar changes. Thanks in advance.

Upvotes: 0

Views: 205

Answers (1)

Roger
Roger

Reputation: 15813

You can't.

Read and digest the documentation and note;

iOS Note: In iOS, you can determine whether an application is launched as a result of the user tapping the action button or whether the notification was delivered to the already-running application by examining the application state. In the delegate’s implementation of the application:didReceiveRemoteNotification: or application:didReceiveLocalNotification: method, get the value of the applicationState property and evaluate it. If the value is UIApplicationStateInactive, the user tapped the action button; if the value is UIApplicationStateActive, the application was frontmost when it received the notification.

Or to put it another way, if your application is in the background, you only find out about the notification if the user taps on the action button. This is by design.

Upvotes: 1

Related Questions