-
Notifications
You must be signed in to change notification settings - Fork 3
/
localnotifications.html
98 lines (81 loc) · 4.14 KB
/
localnotifications.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<html>
<head>
<meta name = "viewport" content = "initial-scale = 1.0, user-scalable = no" />
<link rel="stylesheet" href="style.css" type="text/css">
<script type="text/javascript" src="NKit.js"></script>
</head>
<body>
<script>
var navController = new NKNavigationController();
navController.setTitle("Local Notifications");
NKSetPageOpaque('localnotifications.html', 'NO');
function notify() {
// =====================================================================================================
// PARAMETERS:
// =====================================================================================================
// body: The Body of the notification. (Title is your app's name)
// -----------------------------------------------------------------------------------------------------
// action: The alert action is title of the r/h button of alert or the value of unlock slider.
// The value replaces “unlock” in the “slide to unlock” dialogue.
// -----------------------------------------------------------------------------------------------------
// badgeNum: The number to display as the application’s icon badge.
// -----------------------------------------------------------------------------------------------------
// fire: The date and time when the system should deliver the notification.
// Currently accepts the format: 2012-07-31 17:14:30
// You can tweak the NSDateFormatter to accept other formats if you so desire.
// -----------------------------------------------------------------------------------------------------
// id: Set a unique ID for the notification // TODO
// -----------------------------------------------------------------------------------------------------
// sound: Leave Blank for no sound, use "UILocalNotificationDefaultSoundName" (default value), or
// you can specify a custom sound file in the applications bundle.
// Must be less than 30secs, otherwise the standard system sound will play instead.
// -----------------------------------------------------------------------------------------------------
// repeat: When to repeat the notification. Default of "0" is never, other options are:
// 1 = NSMinuteCalendarUnit
// 2 = NSHourCalendarUnit
// 3 = NSDayCalendarUnit
// 4 = NSWeekCalendarUnit
// 5 = NSMonthCalendarUnit
// -----------------------------------------------------------------------------------------------------
//
// MISCELLANEOUS:
// Each application on a device is limited to the soonest-firing 64 scheduled local notifications.
// iOS discards notifications that exceed this limit (although recurring notifications are considered
// to be a single notification).
//
// -----------------------------------------------------------------------------------------------------
// Register The Notification Class
NKRegisterClass("localNotification");
var bc = new NKApplication();
bc.setBadgeCount("0");
// TESTING 123... Set a future date to use for notification
//var dateFire = new Date();
//dateFire = dateFire.getTime() + 60*1000; //1 minute from now
//dateFire = new Date(dateFire);
body = 'Lovely Great Message';
action = 'Show';
badgeNum = '123';
fireAt = '2012-02-19 14:09:30';
id = 'ABC123';
sound = 'UILocalNotificationDefaultSoundName';
repeat = '1';
CallNKitAction("addNotification?className=localNotification&body="+body+"&action="+action+"&sound="+sound+"&badgeNum="+badgeNum+"&fire="+fireAt+"&id="+id+"&repInt="+repeat);
}
//function cancel() {
// CallNKitAction("cancelNotification?className=localNotification");
//}
function cancelAll() {
CallNKitAction("cancelAllNotifications?className=localNotification");
// Set Badge count to zero...
}
</script>
<div class="infobox">
<h3>ToDo:</h3>
<p>Implement dictionary for setting notification ID's, to allow for notification management</p>
<p>Improve date & time handling - more flexibility needed</p>
</div>
<div class="greybutton" onClick="notify()">Set Notification</a></div>
<div class="greybutton" onClick="cancelAll()">Cancel All Notifications</a></div>
<!-- <div class="greybutton" onClick="cancel()">Cancel Specific Notification</a></div> -->
</body>
</html>