I'm face the problem after upgraded to iOS 10 about push notification (I am using Swift3).
In normal case when application open or application still in background everything work as well (can receive push notification and update data as my logic).
But when application is terminated i can't handle push notification when application become active.
Here is my test case.
- Edit Scheme to Wait for executable to be launched.
- Double press home button and swipe application up.
- Run Xcode wait until "Wait for application to launch" shown.
- Test send push notification from server.
- Device received push notification.
- Start application from application icon.
After that application start and didFinishLaunchingWithOptions being called but launchOptions aways null so i can't handle push notification (But if i open application from notification in notification center or popup notification launchOptions is not null)
Does anybody has any idea to check this problem ?
Thank you in advance.
You need to open the application by tapping the push notification in the notification tray.
When you launch the application from the icon, launchOptions will be nil. Launching from the push notification will provide you launchOptions.
https://developer.apple.com/reference/uikit/uiapplicationdelegate/1622921-application
Try this:
Add delegate on AppDelegate.
And..