forked from phonegap/phonegap
/
phonegap_notification_notification.md.html
554 lines (476 loc) · 19.6 KB
/
phonegap_notification_notification.md.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width">
<meta name="generator" content="joDoc">
<title>PhoneGap API Documentation</title>
<link rel="stylesheet" type="text/css" href="index.css">
<link rel="stylesheet" type="text/css" href="mobile.css" media="only screen and (max-device-width: 1024px)">
<link rel="stylesheet" type="text/css" href="prettify/prettify.css">
</head>
<body>
<div id="header">
<h1><a href="index.html">Phone<strong>Gap</strong> Documentation</a></h1>
<small>
<select><optgroup label="English" value="en">
<option value="edge">edge</option>
<option value="1.5.0rc1">1.5.0rc1</option>
<option selected value="1.5.0">1.5.0</option>
<option value="1.4.1">1.4.1</option>
<option value="1.4.0rc1">1.4.0rc1</option>
<option value="1.4.0">1.4.0</option>
<option value="1.3.0">1.3.0</option>
<option value="1.2.0">1.2.0</option>
<option value="1.1.0">1.1.0</option>
<option value="1.0.0rc3">1.0.0rc3</option>
<option value="1.0.0rc2">1.0.0rc2</option>
<option value="1.0.0rc1">1.0.0rc1</option>
<option value="1.0.0">1.0.0</option>
<option value="0.9.6">0.9.6</option>
<option value="0.9.5.1">0.9.5.1</option>
<option value="0.9.5">0.9.5</option>
<option value="0.9.4">0.9.4</option>
<option value="0.9.3">0.9.3</option>
<option value="0.9.2">0.9.2</option>
</optgroup>
<optgroup label="Español" value="es"><option value="1.0.0">1.0.0</option></optgroup>
<optgroup label="Français" value="fr">
<option value="1.3.0">1.3.0</option>
<option value="1.2.0">1.2.0</option>
<option value="1.1.0">1.1.0</option>
</optgroup>
<optgroup label="Japanese" value="jp"><option value="0.9.5">0.9.5</option></optgroup></select></small>
</div>
<div id="subheader">
<h1>Notification</h1>
<small><select><option value="Notification">Notification</option>
<option value="Notification_methods"> - Methods</option>
<option value="notification.alert">notification.alert</option>
<option value="notification.alert_description"> - Description</option>
<option value="notification.alert_supported_platforms"> - Supported Platforms</option>
<option value="notification.alert_quick_example"> - Quick Example</option>
<option value="notification.alert_full_example"> - Full Example</option>
<option value="notification.alert_windows_phone_7_quirks"> - Windows Phone 7 Quirks</option>
<option value="notification.confirm">notification.confirm</option>
<option value="notification.confirm_description"> - Description</option>
<option value="notification.confirm_supported_platforms"> - Supported Platforms</option>
<option value="notification.confirm_quick_example"> - Quick Example</option>
<option value="notification.confirm_full_example"> - Full Example</option>
<option value="notification.confirm_windows_phone_7_quirks"> - Windows Phone 7 Quirks</option>
<option value="notification.beep">notification.beep</option>
<option value="notification.beep_supported_platforms"> - Supported Platforms</option>
<option value="notification.beep_quick_example"> - Quick Example</option>
<option value="notification.beep_full_example"> - Full Example</option>
<option value="notification.beep_android_quirks"> - Android Quirks</option>
<option value="notification.beep_iphone_quirks"> - iPhone Quirks</option>
<option value="notification.beep_windows_phone_7_quirks"> - Windows Phone 7 Quirks</option>
<option value="notification.vibrate">notification.vibrate</option>
<option value="notification.vibrate_supported_platforms"> - Supported Platforms</option>
<option value="notification.vibrate_quick_example"> - Quick Example</option>
<option value="notification.vibrate_full_example"> - Full Example</option>
<option value="notification.vibrate_iphone_quirks"> - iPhone Quirks</option></select></small>
</div>
<div id="sidebar">
<div class="vertical_divider"></div>
<h1>API Reference</h1>
<ul>
<li><a href="phonegap_accelerometer_accelerometer.md.html#Accelerometer">Accelerometer</a></li>
<li><a href="phonegap_camera_camera.md.html#Camera">Camera</a></li>
<li><a href="phonegap_media_capture_capture.md.html#Capture">Capture</a></li>
<li><a href="phonegap_compass_compass.md.html#Compass">Compass</a></li>
<li><a href="phonegap_connection_connection.md.html#Connection">Connection</a></li>
<li><a href="phonegap_contacts_contacts.md.html#Contacts">Contacts</a></li>
<li><a href="phonegap_device_device.md.html#Device">Device</a></li>
<li><a href="phonegap_events_events.md.html#Events">Events</a></li>
<li><a href="phonegap_file_file.md.html#File">File</a></li>
<li><a href="phonegap_geolocation_geolocation.md.html#Geolocation">Geolocation</a></li>
<li><a href="phonegap_media_media.md.html#Media">Media</a></li>
<li><a href="phonegap_notification_notification.md.html#Notification">Notification</a></li>
<li><a href="phonegap_storage_storage.md.html#Storage">Storage</a></li>
</ul>
<h1>Guides</h1>
<ul>
<li><a href="guide_getting-started_index.md.html#Getting%20Started%20Guides">Getting Started Guides</a></li>
<li><a href="_index.html">Keyword Index</a></li>
</ul>
</div>
<div id="scrollable">
<div id="content">
<h1><a name="Notification">Notification</a></h1>
<blockquote>
<p>Visual, audible, and tactile device notifications.</p>
</blockquote>
<h2>
<a name="Notification_methods">Methods</a>
</h2>
<ul>
<li><a href="phonegap_notification_notification.md.html#notification.alert">notification.alert</a></li>
<li><a href="phonegap_notification_notification.md.html#notification.confirm">notification.confirm</a></li>
<li><a href="phonegap_notification_notification.md.html#notification.beep">notification.beep</a></li>
<li><a href="phonegap_notification_notification.md.html#notification.vibrate">notification.vibrate</a></li>
</ul>
<hr>
<h1><a name="notification.alert">notification.alert</a></h1>
<p>Shows a custom alert or dialog box.</p>
<pre class="prettyprint"><code>navigator.<a href="phonegap_notification_notification.md.html#notification.alert">notification.alert</a>(message, alertCallback, [title], [buttonName])
</code></pre>
<ul>
<li>
<strong>message:</strong> Dialog message (<code>String</code>)</li>
<li>
<strong>alertCallback:</strong> Callback to invoke when alert dialog is dismissed. (<code>Function</code>)</li>
<li>
<strong>title:</strong> Dialog title (<code>String</code>) (Optional, Default: "Alert")</li>
<li>
<strong>buttonName:</strong> Button <a href="phonegap_storage_storage.md.html#name">name</a> (<code>String</code>) (Optional, Default: "OK")</li>
</ul>
<h2>
<a name="notification.alert_description">Description</a>
</h2>
<p>Most PhoneGap implementations use a native dialog box for this feature. However, some platforms simply use the browser's <code>alert</code> function, which is typically less customizable.</p>
<h2>
<a name="notification.alert_supported_platforms">Supported Platforms</a>
</h2>
<ul>
<li>Android</li>
<li>BlackBerry (OS 4.6)</li>
<li>BlackBerry WebWorks (OS 5.0 and higher)</li>
<li>iPhone</li>
<li>Windows Phone 7 ( Mango )</li>
</ul>
<h2>
<a name="notification.alert_quick_example">Quick Example</a>
</h2>
<pre class="prettyprint"><code>// Android / BlackBerry WebWorks (OS 5.0 and higher) / iPhone
//
function alertDismissed() {
// do something
}
navigator.<a href="phonegap_notification_notification.md.html#notification.alert">notification.alert</a>(
'You are the winner!', // message
alertDismissed, // callback
'Game Over', // title
'Done' // buttonName
);
// BlackBerry (OS 4.6) / webOS
//
navigator.<a href="phonegap_notification_notification.md.html#notification.alert">notification.alert</a>('You are the winner!');
</code></pre>
<h2>
<a name="notification.alert_full_example">Full Example</a>
</h2>
<pre class="prettyprint"><code><!DOCTYPE html>
<html>
<head>
<title><a href="phonegap_notification_notification.md.html#Notification">Notification</a> Example</title>
<script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for PhoneGap to load
//
document.addEventListener("<a href="phonegap_events_events.md.html#deviceready">deviceready</a>", onDeviceReady, false);
// PhoneGap is ready
//
function onDeviceReady() {
// Empty
}
// alert dialog dismissed
function alertDismissed() {
// do something
}
// Show a custom alert
//
function showAlert() {
navigator.<a href="phonegap_notification_notification.md.html#notification.alert">notification.alert</a>(
'You are the winner!', // message
alertDismissed, // callback
'Game Over', // title
'Done' // buttonName
);
}
</script>
</head>
<body>
<p><a href="#" onclick="showAlert(); return false;">Show Alert</a></p>
</body>
</html>
</code></pre>
<h2>
<a name="notification.alert_windows_phone_7_quirks">Windows Phone 7 Quirks</a>
</h2>
<ul>
<li>Ignores button names, always uses 'OK'</li>
</ul>
<hr>
<h1><a name="notification.confirm">notification.confirm</a></h1>
<p>Shows a customizable confirmation dialog box.</p>
<pre class="prettyprint"><code>navigator.<a href="phonegap_notification_notification.md.html#notification.confirm">notification.confirm</a>(message, confirmCallback, [title], [buttonLabels])
</code></pre>
<ul>
<li>
<strong>message:</strong> Dialog message (<code>String</code>)</li>
<li>
<strong>confirmCallback:</strong> - Callback to invoke with index of button pressed (1, 2 or 3). (<code>Number</code>)</li>
<li>
<strong>title:</strong> Dialog title (<code>String</code>) (Optional, Default: "Confirm")</li>
<li>
<strong>buttonLabels:</strong> Comma separated string with button labels (<code>String</code>) (Optional, Default: "OK,Cancel")</li>
</ul>
<h2>
<a name="notification.confirm_description">Description</a>
</h2>
<p>Function <code><a href="phonegap_notification_notification.md.html#notification.confirm">notification.confirm</a></code> displays a native dialog box that is more customizable than the browser's <code>confirm</code> function.</p>
<h2>
<a name="notification.confirm_supported_platforms">Supported Platforms</a>
</h2>
<ul>
<li>Android</li>
<li>BlackBerry WebWorks (OS 5.0 and higher)</li>
<li>iPhone</li>
<li>Windows Phone 7 ( Mango )</li>
</ul>
<h2>
<a name="notification.confirm_quick_example">Quick Example</a>
</h2>
<pre class="prettyprint"><code>// process the confirmation dialog result
function onConfirm(button) {
alert('You selected button ' + button);
}
// Show a custom confirmation dialog
//
function showConfirm() {
navigator.<a href="phonegap_notification_notification.md.html#notification.confirm">notification.confirm</a>(
'You are the winner!', // message
onConfirm, // callback to invoke with index of button pressed
'Game Over', // title
'Restart,Exit' // buttonLabels
);
}
</code></pre>
<h2>
<a name="notification.confirm_full_example">Full Example</a>
</h2>
<pre class="prettyprint"><code><!DOCTYPE html>
<html>
<head>
<title><a href="phonegap_notification_notification.md.html#Notification">Notification</a> Example</title>
<script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for PhoneGap to load
//
document.addEventListener("<a href="phonegap_events_events.md.html#deviceready">deviceready</a>", onDeviceReady, false);
// PhoneGap is ready
//
function onDeviceReady() {
// Empty
}
// process the confirmation dialog result
function onConfirm(button) {
alert('You selected button ' + button);
}
// Show a custom confirmation dialog
//
function showConfirm() {
navigator.<a href="phonegap_notification_notification.md.html#notification.confirm">notification.confirm</a>(
'You are the winner!', // message
onConfirm, // callback to invoke with index of button pressed
'Game Over', // title
'Restart,Exit' // buttonLabels
);
}
</script>
</head>
<body>
<p><a href="#" onclick="showConfirm(); return false;">Show Confirm</a></p>
</body>
</html>
</code></pre>
<h2>
<a name="notification.confirm_windows_phone_7_quirks">Windows Phone 7 Quirks</a>
</h2>
<ul>
<li>Ignores button names, always 'OK|Cancel'</li>
</ul>
<hr>
<h1><a name="notification.beep">notification.beep</a></h1>
<p>The device will play a beep sound.</p>
<pre class="prettyprint"><code>navigator.<a href="phonegap_notification_notification.md.html#notification.beep">notification.beep</a>(times);
</code></pre>
<ul>
<li>
<strong>times:</strong> The number of times to repeat the beep (<code>Number</code>)</li>
</ul>
<h2>
<a name="notification.beep_supported_platforms">Supported Platforms</a>
</h2>
<ul>
<li>Android</li>
<li>BlackBerry (OS 4.6)</li>
<li>BlackBerry WebWorks (OS 5.0 and higher)</li>
<li>iPhone</li>
<li>Windows Phone 7 ( Mango )</li>
</ul>
<h2>
<a name="notification.beep_quick_example">Quick Example</a>
</h2>
<pre class="prettyprint"><code>// Beep twice!
navigator.<a href="phonegap_notification_notification.md.html#notification.beep">notification.beep</a>(2);
</code></pre>
<h2>
<a name="notification.beep_full_example">Full Example</a>
</h2>
<pre class="prettyprint"><code><!DOCTYPE html>
<html>
<head>
<title><a href="phonegap_notification_notification.md.html#Notification">Notification</a> Example</title>
<script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for PhoneGap to load
//
document.addEventListener("<a href="phonegap_events_events.md.html#deviceready">deviceready</a>", onDeviceReady, false);
// PhoneGap is ready
//
function onDeviceReady() {
// Empty
}
// Show a custom alert
//
function showAlert() {
navigator.<a href="phonegap_notification_notification.md.html#notification.alert">notification.alert</a>(
'You are the winner!', // message
'Game Over', // title
'Done' // buttonName
);
}
// Beep three times
//
function playBeep() {
navigator.<a href="phonegap_notification_notification.md.html#notification.beep">notification.beep</a>(3);
}
// Vibrate for 2 seconds
//
function vibrate() {
navigator.<a href="phonegap_notification_notification.md.html#notification.vibrate">notification.vibrate</a>(2000);
}
</script>
</head>
<body>
<p><a href="#" onclick="showAlert(); return false;">Show Alert</a></p>
<p><a href="#" onclick="playBeep(); return false;">Play Beep</a></p>
<p><a href="#" onclick="vibrate(); return false;">Vibrate</a></p>
</body>
</html>
</code></pre>
<h2>
<a name="notification.beep_android_quirks">Android Quirks</a>
</h2>
<ul>
<li>Android plays the default "<a href="phonegap_notification_notification.md.html#Notification">Notification</a> ringtone" specified under the "Settings/Sound & Display" panel.</li>
</ul>
<h2>
<a name="notification.beep_iphone_quirks">iPhone Quirks</a>
</h2>
<ul>
<li>Ignores the beep count argument.</li>
<li>There is no native beep API for iPhone.
<ul>
<li>PhoneGap implements beep by playing an audio file via the media API.</li>
<li>The user must provide a file with the desired beep tone.</li>
<li>This file must be less than 30 seconds long, located in the www/ root, and must be named <code>beep.wav</code>.</li>
</ul>
</li>
</ul>
<h2>
<a name="notification.beep_windows_phone_7_quirks">Windows Phone 7 Quirks</a>
</h2>
<ul>
<li>WP7 PhoneGap lib includes a generic beep file that is used.</li>
</ul>
<hr>
<h1><a name="notification.vibrate">notification.vibrate</a></h1>
<p>Vibrates the device for the specified amount of time.</p>
<pre class="prettyprint"><code>navigator.<a href="phonegap_notification_notification.md.html#notification.vibrate">notification.vibrate</a>(milliseconds)
</code></pre>
<ul>
<li>
<strong>time:</strong> Milliseconds to vibrate the device. 1000 milliseconds equals 1 second (<code>Number</code>)</li>
</ul>
<h2>
<a name="notification.vibrate_supported_platforms">Supported Platforms</a>
</h2>
<ul>
<li>Android</li>
<li>BlackBerry (OS 4.6)</li>
<li>BlackBerry WebWorks (OS 5.0 and higher)</li>
<li>iPhone</li>
<li>Windows Phone 7</li>
</ul>
<h2>
<a name="notification.vibrate_quick_example">Quick Example</a>
</h2>
<pre class="prettyprint"><code>// Vibrate for 2.5 seconds
//
navigator.<a href="phonegap_notification_notification.md.html#notification.vibrate">notification.vibrate</a>(2500);
</code></pre>
<h2>
<a name="notification.vibrate_full_example">Full Example</a>
</h2>
<pre class="prettyprint"><code><!DOCTYPE html>
<html>
<head>
<title><a href="phonegap_notification_notification.md.html#Notification">Notification</a> Example</title>
<script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for PhoneGap to load
//
document.addEventListener("<a href="phonegap_events_events.md.html#deviceready">deviceready</a>", onDeviceReady, false);
// PhoneGap is ready
//
function onDeviceReady() {
// Empty
}
// Show a custom alert
//
function showAlert() {
navigator.<a href="phonegap_notification_notification.md.html#notification.alert">notification.alert</a>(
'You are the winner!', // message
'Game Over', // title
'Done' // buttonName
);
}
// Beep three times
//
function playBeep() {
navigator.<a href="phonegap_notification_notification.md.html#notification.beep">notification.beep</a>(3);
}
// Vibrate for 2 seconds
//
function vibrate() {
navigator.<a href="phonegap_notification_notification.md.html#notification.vibrate">notification.vibrate</a>(2000);
}
</script>
</head>
<body>
<p><a href="#" onclick="showAlert(); return false;">Show Alert</a></p>
<p><a href="#" onclick="playBeep(); return false;">Play Beep</a></p>
<p><a href="#" onclick="vibrate(); return false;">Vibrate</a></p>
</body>
</html>
</code></pre>
<h2>
<a name="notification.vibrate_iphone_quirks">iPhone Quirks</a>
</h2>
<ul>
<li>
<p><strong>time:</strong> Ignores the time and vibrates for a pre-set amount of time.</p>
<pre class="prettyprint"><code>navigator.<a href="phonegap_notification_notification.md.html#notification.vibrate">notification.vibrate</a>();
navigator.<a href="phonegap_notification_notification.md.html#notification.vibrate">notification.vibrate</a>(2500); // 2500 is ignored
</code></pre>
</li>
</ul>
</div>
</div>
<!-- Functionality and Syntax Highlighting -->
<script type="text/javascript" src="index.js"></script><script type="text/javascript" src="prettify/prettify.js"></script>
</body>
</html>