0
votes

I want to make a game that tests out local notifications. In iOS 8, the code involves these steps:

  1. Make a UIMutableUserNotificationCategory object that is the category of custom actions you want to implement.
  2. Make up to 4 custom actions by using UIMutableUserNotificationAction instances.
  3. Call setActions:forContext: to set up custom actions.
  4. Make a UIUserNotificationSettings object and call settingsForTypes:categories: on it.
  5. Register the application's user notification settings by calling registerUserNotificationSettings: on the shared UIApplication instance.

My question is, for the UIUserNotificationSettings mentioned in Step 4, how would you register an application for more that one category? The values that can be set for it are:

  • UIUserNotificationTypeAlert (show just the alert)
  • UIUserNotificationTypeBadge (show just a badge)
  • UIUserNotificationTypeSound (only play a sound)
  • UIUserNotificationTypeNone (do nothing)

It sounds like an application should be easily able to show an alert, display a badge, and display a sound. However, before the notification fires, it has to be registered for all of the three. The parameter takes an NSUInteger.

My question is, how would one make it so it had access to all three of the permissions? You can't pass an NSArray to it, so there should be another way I'm not seeing...

2

2 Answers

2
votes

Take this as an example of how to add multiple categories

UIUserNotificationSettings* notificationSettings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:nil];
1
votes

Take this as an example:

[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];

[[UIApplication sharedApplication] registerForRemoteNotifications];