I have 2 iPhones and I’m testing Apple push notifications.
They perfectly work when my app is running in foreground on both devices. But if I close it, by clicking on the Home button, I don’t receive the notifications anymore.
The system doesn’t show the notification popup. And I think this doesn’t depend on my app code…
So far I’ve implemented
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
and it works great when the app is in foreground.
I’ve also implemented:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
but the launchOptions never contain the notification. However, this is correct, I guess, because the last method is invoked when I select a button of a notification alert that I never see…
thanks
When you call method
- (void)registerForRemoteNotificationTypes:(UIRemoteNotificationType)typesyou should indicate appropriate type of argument. If you want to display alert when system receive push-notification for your device then you should passUIRemoteNotificationTypeAlert.Also you can combine types and pass it in that argument:
UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeBadge.