You should not use didReceiveRemoteNotification
method for getting local notification.
You should use didReceiveRemoteNotification
method for getting push notification.
We must know the below things
When app is not running or when app is closed state
If the app is not frontmost and visible, the system displays
the alert
message,
badges
the app, and plays a sound—whatever is specified in the notification.
If the notification is an alert and the user taps
the action button (or, if the device is locked, drags open the action
slider), the app is woken up or launched. (If the user taps one of the
custom actions you specify using the category property, the app is
woken up or launched into the background.) In its
application:didFinishLaunchingWithOptions: method, the app delegate
can obtain the UILocalNotification object from the launch options
dictionary using the UIApplicationLaunchOptionsLocalNotificationKey
key. The delegate can inspect the properties of the notification and,
if the notification includes custom data in its userInfo dictionary,
it can access that data and process it accordingly. On the other hand,
if the local notification only badges the app icon, and the user in
response launches the app, the
application:didFinishLaunchingWithOptions: method is called, but no
UILocalNotification object is included in the options dictionary. When
the user selects a custom action, the app delegate’s
application:handleActionWithIdentifier:forLocalNotification:completionHandler:
method is called to handle the action.
Apple API reference
When Applicaton is Running in Foreground State
If the app is foremost and visible when the system delivers the
notification, the app delegate’s
application:didReceiveLocalNotification: is called to process the
notification. Use the information in the provided UILocalNotification
object to decide what action to take. The system does not display any
alerts, badge the app’s icon, or play any sounds when the app is
already frontmost.
applicationDidReciveLocalNotification
Also
iOS: If app is in background and local notification is arrived; which method will called automatically?