Skip to content

Instantly share code, notes, and snippets.

@hansemannn
Created September 22, 2015 22:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hansemannn/50477706c9e2445bd0a2 to your computer and use it in GitHub Desktop.
Save hansemannn/50477706c9e2445bd0a2 to your computer and use it in GitHub Desktop.
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,
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 John Doe!",
badge: 1,
category: "TEST_CATEGORY"
});
};
Ti.App.iOS.addEventListener('localnotificationaction', function(e) {
Ti.API.info(JSON.stringify(e));
});
win.add(btn);
win.open();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment