title: push notification handling
body: <p>I'm reading Apple's docs on</p>
  
  <p><a href="http://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/IPhoneOSClientImp/IPhoneOSClientImp.html#//apple_ref/doc/uid/TP40008194-CH103-SW4" rel="noreferrer">Handling Local and Remote Notifications</a></p>
  
  <p>and it looks to me to have conflicting statements. Can someone clear up these confusion points? Let's speak strictly of remote notification (versus local) for now.</p>
  
  <p>The docs say that if the action button on the notification is pressed, it calls application:didFinishLaunchingWithOptions and passes in the notification payload. Later it says if the app is running in the foreground, it delivers the notification via application:didReceiveRemoteNotification:. This implies to me that when the app is backgrounded or not running, then application:didFinishLaunchingWithOptions is called. Otherwise, application:didReceiveRemoteNotification: is called.</p>
  
  <p>Later, there is an iOS Note saying the following:</p>
  
  <p>"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."</p>
  
  <p>This implies to me that application:didReceiveRemoteNotification: is called both when the app is already foregrounded and if the user presses the action button (or slides the action slider in iOS 5) to foreground/launch the app.</p>
  
  <p>The source of my confusion might be with the first portion where the docs imply the notification payload is sent with the application:didFinishLaunchingWithOptions: method or with a misunderstanding of what a "running" application is (is a backgrounded app considered "running"?).  The documentation for application:didReceiveRemoteNotification: states it is called for "running" applications.</p>
  
  <p>So, to summarize, could I get clarification on:</p>
  
  <p>1) Is application:didReceiveRemoteNotification: always called when the app is foregrounded or when the user selects to "act" on the notification?  If not, how do we make sense of the iOS Note on determining the Application State being active or inactive?</p>
  
  <p>2) Is a backgrounded app "running", at least in the sense of the docs claiming application:didReceiveRemoteNotification is called for running apps?</p>
  
  <p>3) For completion, is a backgrounded app UIApplicationStateInactive or Active?</p>