Project: titanium
Issue TIMOB-17707: iOS8: change Ti.App.iOS event name from 'backgroundNotification' to 'localnotificationaction'
Change Ti.App.iOS event name from 'backgroundNotification' to 'localnotificationaction'. The current name of the event does not accurately reflect the purpose of the event. Because of this, it needs to be changed to something more meaningful. h5. Test Instructions 1. Run the code below 2. Click 'registerUserNotificationSettings' and then Allow 3. Click 'scheduleLocalNotification' 4. Background the app 5. Swipe down from the top of the device to see the notification center 6. Swipe the notification to the left and click one of the buttons 7. If 'localnotificationaction' is displayed in the device log, then the event was fired correctly {code} var rows = [ { title: 'currentUserNotificationSettings', onClick: function(){ // iOS 8 + var settings = Ti.App.iOS.currentUserNotificationSettings; logUserNotificationSettings(settings); } }, { title: 'registerUserNotificationSettings', onClick: function(){ // iOS 8 + // The following action launches the application in the foreground and requires the device to be unlocked var acceptAction = Ti.App.iOS.createUserNotificationAction({ identifier: "ACCEPT_IDENTIFIER", title: "Accept", activationMode: Ti.App.iOS.USER_NOTIFICATION_ACTIVATION_MODE_FOREGROUND, destructive: false, authenticationRequired: true }); var foregroundCategory = Ti.App.iOS.createUserNotificationCategory({ identifier: "FOREGROUND_CATEGORY", // The following actions will be displayed for an alert dialog actionsForDefaultContext: [acceptAction], // The following actions will be displayed for all other notifications actionsForMinimalContext: [acceptAction] }); Ti.App.iOS.registerUserNotificationSettings({ types: [Ti.App.iOS.USER_NOTIFICATION_TYPE_ALERT, // Ti.App.iOS.USER_NOTIFICATION_TYPE_SOUND, Ti.App.iOS.USER_NOTIFICATION_TYPE_BADGE], categories: [foregroundCategory] }); } }, { title: 'scheduleLocalNotification', onClick: function(){ Ti.App.iOS.scheduleLocalNotification({ date: new Date(new Date().getTime() + 3000), alertBody: "New content available! Download now?", badge: 1, userInfo: {"url": "http://www.download.com/resource/asset.json"}, category: "FOREGROUND_CATEGORY" }); } } ]; function logInApp(text) { textLog.value = textLog.value + '\n' + text; } function logUserNotificationSettings(settings) { logInApp('UserNotificationSettings: '); logInApp('types: ' + JSON.stringify(settings.types)); var categories = []; for (var i = 0, j = settings.categories.length; i < j; i++) { categories.push(settings.categories[i].identifier); } logInApp('categories: ' + JSON.stringify(categories)); } Ti.App.iOS.addEventListener('usernotificationsettings', function(e) { logInApp('Event: usernotificationsettings'); logUserNotificationSettings(e); }); Ti.App.iOS.addEventListener('localnotificationaction', function(e) { logInApp('localnotificationaction'); logInApp('- category: ' + e.category + ' identifier: ' + e.identifier); }); //////////////////////////////////////////////////////// // UI //////////////////////////////////////////////////////// var win = Ti.UI.createWindow({ backgroundColor: 'white' }); win.open(); var textLog = Ti.UI.createTextArea({ top: 0, height: '20%', width: '100%', borderWidth: '2', borderColor: '#000', value: 'AppLog: see device log for more info' }); win.add(textLog); var tableView = Ti.UI.createTableView({ top: '20%', data: rows }); tableView.addEventListener('click', function(e){ e.source.onClick && e.source.onClick(); }); win.add(tableView); {code}
Story points: 3