Created
September 22, 2015 22:06
-
-
Save hansemannn/50477706c9e2445bd0a2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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