0

I've added functionality for receiving remote notifications yet the behaviour is really weird. When the application is in a foreground, the method

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {

is being called. Although when the app is in the background — nothing shows up. I do not see the banner with incoming notification's message and nothing appears in Notifications swipe down list.

One more weird thing — the application doesn't show up in device's Settings --> Notification apps list. Is it ok that I receive them at all? Even if it is only when in the background?

Has anyone faced similar issues?

Solomiya
  • 310
  • 4
  • 15

2 Answers2

1

When your app is open, the didReceiveRemoteNotification method will be called in your app delegate, but an alert will not be shown. The alert is only shown when your app is in background/inactive. You can though create a UIAlertView in your app easily enough and show it when the app is active and a push notification is received.

Josh Gafni
  • 2,831
  • 2
  • 19
  • 32
  • Btw.. this is intentional. Think about all the apps out there that receive a push when new content is available. Think about the facebook app for example. When new content is available, you don't necessarily want to push a message to the user. You might want to include a badge in the app, or show somehow that more content is available to the user if they tap a button. When the app is inactive, you get the message that your friend commented on a post, etc – Josh Gafni Jan 05 '15 at 23:25
  • I have got the idea that the alert won't show up on foreground but the point is that it doesn't show up in background either. Thus, I do no get any reflection by the system when I send the notification. – Solomiya Jan 05 '15 at 23:36
0

Solved that stuff myself finally — I didn't call registerUserNotificationSettings, so no types of notifications were allowed. Now I do this:

[application registerForRemoteNotifications];
UIUserNotificationType types = UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert;
UIUserNotificationSettings *mySettings = [UIUserNotificationSettings settingsForTypes:types categories:nil];
[application registerUserNotificationSettings:mySettings];

Works perfectly!

Solomiya
  • 310
  • 4
  • 15