How to Set Interactive Push Notifications on iOS8

Not able to set Interactive Push Notifications on iOS8

You need to pass categories while registering for APNS.

Look at my sample :

   var replyAction : UIMutableUserNotificationAction = UIMutableUserNotificationAction()
replyAction.identifier = "REPLY_ACTION"
replyAction.title = "Yes, I need!"

replyAction.activationMode = UIUserNotificationActivationMode.Background
replyAction.authenticationRequired = false

var replyCategory : UIMutableUserNotificationCategory = UIMutableUserNotificationCategory()
replyCategory.identifier = "REPLY_CATEGORY"

let replyActions:NSArray = [replyAction]

replyCategory.setActions(replyActions, forContext: UIUserNotificationActionContext.Default)
replyCategory.setActions(replyActions, forContext: UIUserNotificationActionContext.Minimal)

let categories = NSSet(object: replyCategory)

let settings : UIUserNotificationType = UIUserNotificationType.Sound | UIUserNotificationType.Alert | UIUserNotificationType.Badge
UIApplication.sharedApplication().registerUserNotificationSettings(UIUserNotificationSettings(forTypes: settings, categories: categories))
UIApplication.sharedApplication().registerForRemoteNotifications()

How do I make interactive notifications in iOS 8 app?

take a look at

https://developer.apple.com/library/prerelease/ios/documentation/General/Conceptual/ExtensibilityPG/NotificationCenter.html

for details on widgets on the notification center as well as

https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIMutableUserNotificationCategory_class/index.html#//apple_ref/doc/uid/TP40014610

where UIMutableUserNotification is what you're looking for.

Note that this documentation is pre-release so it can be changed whenever production is pushed.

How to Implement iOS8 Interactive Notification

  1. First you need to create the notification Action.
  2. Second you need to create the notification category and set its actions.You can set for two contexts. UIUserNotificationActionContextDefault or UIUserNotificationActionContextMinimal
  3. Third you need to create the notification setting and assign the above categories
  4. Fourth step would be to create local notification and assign it the identifier of the category.

UIMutableUserNotificationAction *notificationAction1 = [[UIMutableUserNotificationAction alloc] init];
notificationAction1.identifier = @"Accept";
notificationAction1.title = @"Accept";
notificationAction1.activationMode = UIUserNotificationActivationModeBackground;
notificationAction1.destructive = NO;
notificationAction1.authenticationRequired = NO;

UIMutableUserNotificationAction *notificationAction2 = [[UIMutableUserNotificationAction alloc] init];
notificationAction2.identifier = @"Reject";
notificationAction2.title = @"Reject";
notificationAction2.activationMode = UIUserNotificationActivationModeBackground;
notificationAction2.destructive = YES;
notificationAction2.authenticationRequired = YES;

UIMutableUserNotificationAction *notificationAction3 = [[UIMutableUserNotificationAction alloc] init];
notificationAction3.identifier = @"Reply";
notificationAction3.title = @"Reply";
notificationAction3.activationMode = UIUserNotificationActivationModeForeground;
notificationAction3.destructive = NO;
notificationAction3.authenticationRequired = YES;

UIMutableUserNotificationCategory *notificationCategory = [[UIMutableUserNotificationCategory alloc] init];
notificationCategory.identifier = @"Email";
[notificationCategory setActions:@[notificationAction1,notificationAction2,notificationAction3] forContext:UIUserNotificationActionContextDefault];
[notificationCategory setActions:@[notificationAction1,notificationAction2] forContext:UIUserNotificationActionContextMinimal];

NSSet *categories = [NSSet setWithObjects:notificationCategory, nil];

UIUserNotificationType notificationType = UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert;
UIUserNotificationSettings *notificationSettings = [UIUserNotificationSettings settingsForTypes:notificationType categories:categories];

[[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];

UILocalNotification* localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:10];
localNotification.alertBody = @"Testing";
localNotification.category = @"Email"; // Same as category identifier
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];

how to register and use multiple interactive push categories with ios 8

Simply use the setWithObjects method on NSSet to include both of your categories in one set object:

NSSet *set = [NSSet setWithObjects:yesNoButtonBackground, acceptDeclineBackground];

Then you only need to call registerUserNotificationSettings once:

[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:types
categories:set]];

How to implement interactive notifications ios8

In order to know more about interactive notifications- a new feature in iOS 8 go to the below link

https://developer.apple.com/videos/wwdc/2014/

and then go to the section "What's New in iOS Notifications"

Call web service with interactive push notification iOS 8

This is worked for me.

let data = NSURLConnection.sendSynchronousRequest(request, returningResponse: response, error: error)


Related Topics



Leave a reply



Submit