forked from CaliLuke/NativeContacts
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Notification.js
63 lines (60 loc) · 1.82 KB
/
Notification.js
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
/**
* Provides a cross device way to show notifications. There are three different implementations:
*
* - Sencha Packager
* - PhoneGap
* - Simulator
*
* When this singleton is instantiated, it will automatically use the correct implementation depending on the current device.
*
* Both the Sencha Packager and PhoneGap versions will use the native implementations to display the notification. The
* Simulator implementation will use {@link Ext.MessageBox} for {@link #show} and a simply animation when you call {@link #vibrate}.
*
* ## Examples
*
* To show a simple notification:
*
* Ext.device.Notification.show({
* title: 'Verification',
* message: 'Is your email address: test@sencha.com',
* buttons: Ext.MessageBox.OKCANCEL,
* callback: function(button) {
* if (button === "ok") {
* console.log('Verified');
* } else {
* console.log('Nope');
* }
* }
* });
*
* To make the device vibrate:
*
* Ext.device.Notification.vibrate();
*
* @mixins Ext.device.notification.Abstract
*
* @aside guide native_apis
*/
Ext.define('Ext.device.Notification', {
singleton: true,
requires: [
'Ext.device.Communicator',
'Ext.device.notification.PhoneGap',
'Ext.device.notification.Sencha',
'Ext.device.notification.Simulator'
],
constructor: function() {
var browserEnv = Ext.browser.is;
if (browserEnv.WebView) {
if (browserEnv.PhoneGap) {
return Ext.create('Ext.device.notification.PhoneGap');
}
else {
return Ext.create('Ext.device.notification.Sencha');
}
}
else {
return Ext.create('Ext.device.notification.Simulator');
}
}
});