How to make interactive notifications in iOS 8 app?

IOS 8 has a new notification feature where you can slide over it and take an action. For example, when you receive a message from iMessage and slide off the notification, you can enter a quick reply.

I went through the docs on how to do this, but I couldn't find them. Does anyone know where I can find out how to do this / where is this in the docs?

+3


source to share


3 answers


take a look at

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

for details on widgets in the action center, and



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

where UIMutableUserNotification is what you are looking for.

Please note that this documentation is a preview release, so it can be changed whenever production takes place.

0


source


Note : - This is step 1

NSString * const NotificationCategoryIdent  = @"ACTIONABLE";
NSString * const NotificationActionOneIdent = @"ACTION_ONE";
NSString * const NotificationActionTwoIdent = @"ACTION_TWO";

- (void)registerForNotification {

UIMutableUserNotificationAction *action1;
action1 = [[UIMutableUserNotificationAction alloc] init];
[action1 setActivationMode:UIUserNotificationActivationModeBackground];
[action1 setTitle:@"Action 1"];
[action1 setIdentifier:NotificationActionOneIdent];
[action1 setDestructive:NO];
[action1 setAuthenticationRequired:NO];

UIMutableUserNotificationAction *action2;
action2 = [[UIMutableUserNotificationAction alloc] init];
[action2 setActivationMode:UIUserNotificationActivationModeBackground];
[action2 setTitle:@"Action 2"];
[action2 setIdentifier:NotificationActionTwoIdent];
[action2 setDestructive:NO];
[action2 setAuthenticationRequired:NO];

UIMutableUserNotificationCategory *actionCategory;
actionCategory = [[UIMutableUserNotificationCategory alloc] init];
[actionCategory setIdentifier:NotificationCategoryIdent];
[actionCategory setActions:@[action1, action2] 
                forContext:UIUserNotificationActionContextDefault];

NSSet *categories = [NSSet setWithObject:actionCategory];
UIUserNotificationType types = (UIUserNotificationTypeAlert|
                                UIUserNotificationTypeSound|
                                UIUserNotificationTypeBadge);

UIUserNotificationSettings *settings;
settings = [UIUserNotificationSettings settingsForTypes:types
                                             categories:categories];

[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
}

      

Note : - This is step 2



- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void (^)())completionHandler {

if ([identifier isEqualToString:NotificationActionOneIdent]) {

    NSLog(@"You chose action 1.");
}
else if ([identifier isEqualToString:NotificationActionTwoIdent]) {   

    NSLog(@"You chose action 2.");
}    
if (completionHandler) {

    completionHandler();
}
}

      

Note : - If you want to know more, please follow this link. https://nrj.io/simple-interactive-notifications-in-ios-8/

+3


source


I don't take responsibility for this answer, I just found it online, but it was very helpful for me to help my understanding of iOS8 interactive notifications:

http://docs.appcelerator.com/titanium/3.0/#!/guide/iOS_Interactive_Notifications-section-40930452_iOSInteractiveNotifications-CreateaNotificationAction

-1


source







All Articles