appcelerator/titanium_mobile — pull request #5988 by cheekiatng (2014-08-26 06:37:18+00:00)
Title: Timob 17238 - iOS 8 Interactive Local Notifications

For iOS 8 or newer only.
Added new feature:
Support for iOS 8 Interactive Local Notifications. Apple has added notification action support so that user can immediately handle notifications in the home screen or lock screen, without the user having to enter the app. To enable this for both local and remote notifications, the following steps have to followed:
1. Create and Configure Notification Actions
2. Create and assign Notification Actions to Notification Categories
3. Register the Notification Categories and Notification Types
4. After which, add event listeners for notifications received while the app is active, or in background.

Example:
1. Create and Configure Notification Actions

var acceptAction = Ti.App.iOS.createUserNotificationAction({
identifier: "ACCEPT_IDENTIFIER",
title: "Accept",
activationMode: Ti.App.iOS.NOTIFICATION_ACTIVATION_MODE_BACKGROUND,
destructive: false,
authenticationRequired: false
}) ;

2. Create and assign Notification Actions to Notification Categories

var backgroundCategory = Ti.App.iOS.createUserNotificationCategory({
identifier: "BACKGROUND_CATEGORY",
actionsForDefaultContext: [acceptAction, maybeAction, declineAction],
actionsForMinimalContext: [acceptAction, declineAction]
});

3. Register the Notification Categories and Notification Types

Ti.App.iOS.registerForLocalNotifications({
types: Ti.App.iOS.NOTIFICATION_TYPE_SOUND | Ti.App.iOS.NOTIFICATION_TYPE_ALERT,
categories: [backgroundCategory,backgroundLockCategory,foregroundCategory]
});

4. Add event listeners
// for notifications received while app is in foreground
Ti.App.iOS.addEventListener('notification',function(e)
{
var content = e.userInfo.content;
//do stuff with notification received
});

//for notifications received while app is in background
Ti.App.iOS.addEventListener('backgroundNotification',function(e)
{
var content = e.userInfo.content;
var identifier = e.identifier;
//do stuff with notification received
});

Note: To enable interactive remote notifications, steps 1 to 3 should be done as well. Followed by Ti.Network.registerForPushNotifications. Require ACS to add additional field "category" to aps push packet, so that we can enable this for remote notifications.