[TIMOB-19184] iOS9: Add behavior property to userNotificationAction
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2015-10-19T16:03:28.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 5.1.0 |
Components | iOS |
Labels | notification, pushnotification |
Reporter | Chee Kiat Ng |
Assignee | Hans Knöchel |
Created | 2015-07-07T08:11:02.000+0000 |
Updated | 2016-03-11T12:20:35.000+0000 |
Description
Via the userNotificationAction new property behavior, iOS9 now allows keyboard input as an action on the lock screen.
Reference:
https://developer.apple.com/library/prerelease/ios/releasenotes/General/iOS90APIDiffs/frameworks/UIKit.html
Sample code:
var win = Ti.UI.createWindow({
backgroundColor: "#fff"
});
var btn = Ti.UI.createButton({
title: "Schedule local notification!"
});
btn.addEventListener("click", scheduleLocalNotification);
function scheduleLocalNotification() {
var acceptAction = Ti.App.iOS.createUserNotificationAction({
identifier: "ACCEPT_IDENTIFIER",
title: "Reply",
activationMode: Ti.App.iOS.USER_NOTIFICATION_ACTIVATION_MODE_FOREGROUND,
destructive: false,
behavior: Ti.App.iOS.USER_NOTIFICATION_BEHAVIOR_TEXTINPUT, // Ti.App.iOS.USER_NOTIFICATION_BEHAVIOR_DEFAULT,
authenticationRequired: true
});
var invitationCategory = Ti.App.iOS.createUserNotificationCategory({
identifier: "TEST_CATEGORY",
actionsForDefaultContext: [acceptAction],
actionsForMinimalContext: [acceptAction]
});
Ti.App.iOS.registerUserNotificationSettings({
types: [Ti.App.iOS.USER_NOTIFICATION_TYPE_ALERT, Ti.App.iOS.USER_NOTIFICATION_TYPE_BADGE],
categories: [invitationCategory]
});
Ti.App.iOS.scheduleLocalNotification({
date: new Date(new Date().getTime() + 3000),
alertBody: "New message from Hans! Reply?",
badge: 1,
category: "TEST_CATEGORY"
});
};
Ti.App.iOS.addEventListener('localnotificationaction', function(e) {
Ti.API.info(JSON.stringify(e));
if (e.typedText && e.typedText.length > 0) {
alert(e.typedText);
}
});
win.add(btn);
win.open();
Attachments
File | Date | Size |
---|---|---|
Screen Shot 2015-09-02 at 13.01.44.png | 2015-09-02T20:05:15.000+0000 | 242127 |
[~cng] Implemented two new constants
Ti.App.iOS.USER_NOTIFICATION_BEHAVIOR_DEFAULT
andTi.App.iOS.USER_NOTIFICATION_BEHAVIOR_TEXTINPUT
, added the new propertybehavior
to our proxy. Looks fine so far (see attached screen). Docs and sample are coming! Changed from 5.0.2 to 5.0.1, ok?Sample code added. PR: https://github.com/appcelerator/titanium_mobile/pull/7120
PR Merged.
PR to fix backward compatibility with Xcode 6.4 here: https://github.com/appcelerator/titanium_mobile/pull/7165 PR merged
Verified fixed, using: MacOS 10.11 (15A284) Studio 4.4.0.201510092420 Ti SDK 5.1.0.v20151013151603 Appc NPM 4.2.1-1 Appc CLI 5.1.0-38 Ti CLI 5.0.5 Alloy 1.7.16 Arrow 1.3.13 Xcode 7.0.1 (7A1001) Node v4.1.0 Java 1.7.0_80 production Able to successfully send, receive, and reply to user notifications in app, on the home screen, and on the lock screen. Used the provided sample code and made modifications to test the different scenarios.
Reopening to address push notifications
Spent my day to reproduce the outstanding issue with remote notifications. They work. We need to supply a category in the aps like done natively and proposed by Apple:
The text fields appears and the callback works. [~ewieber] please confirm and close the issue.
Verified fixed using: MacOS 10.11 (15A284) Studio 4.4.0.201510161811 Ti SDK 5.1.0.v20151016172827 Appc NPM 4.2.1-5 Appc CLI 5.1.0-38 Ti CLI 5.0.5 Alloy 1.7.16 Arrow 1.3.13 Xcode 7.0.1 (7A1001) Node v0.12.7 Java 1.7.0_80 production Remote notifications work as well. Push notifications sent can be interacted with via buttons and text input on the home and lock screens.