@@ -12,43 +12,77 @@ declare module PhonegapPluginPush {
12
12
* @param event
13
13
* @param callback
14
14
*/
15
- on ( event :"registration" , callback :( response :RegistrationEventResponse ) => any ) :void
15
+ on ( event : "registration" , callback : ( response : RegistrationEventResponse ) => any ) : void
16
16
/**
17
17
* The event notification will be triggered each time a push notification is received by a 3rd party push service on the device.
18
18
* @param event
19
19
* @param callback
20
20
*/
21
- on ( event :"notification" , callback :( response :NotificationEventResponse ) => any ) :void
21
+ on ( event : "notification" , callback : ( response : NotificationEventResponse ) => any ) : void
22
22
/**
23
23
* The event error will trigger when an internal error occurs and the cache is aborted.
24
24
* @param event
25
25
* @param callback
26
26
*/
27
- on ( event :"error" , callback :( response :Error ) => any ) :void
28
- /*Generic one, needed for the overloads*/
27
+ on ( event : "error" , callback : ( response : Error ) => any ) : void
29
28
/**
30
29
*
31
30
* @param event Name of the event to listen to. See below(above) for all the event names.
32
31
* @param callback is called when the event is triggered.
32
+ * @param event
33
+ * @param callback
34
+ */
35
+ on ( event : string , callback : ( response : EventResponse ) => any ) : void
36
+
37
+ off ( event : "registration" , callback : ( response : RegistrationEventResponse ) => any ) : void
38
+ off ( event : "notification" , callback : ( response : NotificationEventResponse ) => any ) : void
39
+ off ( event : "error" , callback : ( response : Error ) => any ) : void
40
+ /**
41
+ * As stated in the example, you will have to store your event handler if you are planning to remove it.
42
+ * @param event Name of the event type. The possible event names are the same as for the push.on function.
43
+ * @param callback handle to the function to get removed.
44
+ * @param event
45
+ * @param callback
33
46
*/
34
- on ( event :string , callback :( response :EventResponse ) => any ) :void
47
+ off ( event : string , callback : ( response : EventResponse ) => any ) : void
35
48
36
49
/**
37
50
* The unregister method is used when the application no longer wants to receive push notifications.
51
+ * Beware that this cleans up all event handlers previously registered,
52
+ * so you will need to re-register them if you want them to function again without an application reload.
38
53
* @param successHandler
39
54
* @param errorHandler
40
55
*/
41
- unregister ( successHandler :( ) => any , errorHandler ?:( ) => any ) :void
56
+ unregister ( successHandler : ( ) => any , errorHandler ?: ( ) => any ) : void
57
+
42
58
/*TODO according to js source code, "errorHandler" is optional, but is "count" also optional? I can't read objetive-C code (can anyone at all? I wonder...)*/
43
59
/**
44
60
* Set the badge count visible when the app is not running
45
61
*
46
- * The count is an integer indicating what number should show up in the badge. Passing 0 will clear the badge. Each notification event contains a data.count value which can be used to set the badge to correct number.
62
+ * The count is an integer indicating what number should show up in the badge.
63
+ * Passing 0 will clear the badge.
64
+ * Each notification event contains a data.count value which can be used to set the badge to correct number.
47
65
* @param successHandler
48
66
* @param errorHandler
49
67
* @param count
50
68
*/
51
- setApplicationIconBadgeNumber ( successHandler :( ) => any , errorHandler :( ) => any , count :number ) :void
69
+ setApplicationIconBadgeNumber ( successHandler : ( ) => any , errorHandler : ( ) => any , count : number ) : void
70
+ /**
71
+ * Get the current badge count visible when the app is not running
72
+ * successHandler gets called with an integer which is the current badge count
73
+ * @param successHandler
74
+ * @param errorHandler
75
+ */
76
+ getApplicationIconBadgeNumber ( successHandler : ( count : number ) => any , errorHandler : ( ) => any ) : void
77
+
78
+ /**
79
+ * iOS only
80
+ * Tells the OS that you are done processing a background push notification.
81
+ * successHandler gets called when background push processing is successfully completed.
82
+ * @param successHandler
83
+ * @param errorHandler
84
+ */
85
+ finish ( successHandler : ( ) => any , errorHandler : ( ) => any ) : void
52
86
}
53
87
54
88
/**
@@ -62,46 +96,66 @@ declare module PhonegapPluginPush {
62
96
/**
63
97
* Maps to the project number in the Google Developer Console.
64
98
*/
65
- senderID :string
99
+ senderID : string
66
100
/**
67
- * The name of a drawable resource to use as the small-icon.
101
+ * The name of a drawable resource to use as the small-icon. The name should not include the extension.
68
102
*/
69
- icon ?:string
103
+ icon ?: string
70
104
/**
71
- * Sets the background color of the small icon.
105
+ * Sets the background color of the small icon on Android 5.0 and greater .
72
106
* Supported Formats - http://developer.android.com/reference/android/graphics/Color.html#parseColor(java.lang.String)
73
107
*/
74
- iconColor ?:string
108
+ iconColor ?: string
75
109
/**
76
110
* If true it plays the sound specified in the push data or the default system sound. Default is true.
77
111
*/
78
- sound ?:boolean
112
+ sound ?: boolean
79
113
/**
80
114
* If true the device vibrates on receipt of notification. Default is true.
81
115
*/
82
- vibrate ?:boolean
116
+ vibrate ?: boolean
83
117
/**
84
118
* If true the app clears all pending notifications when it is closed. Default is true.
85
119
*/
86
- clearNotifications ?:boolean
120
+ clearNotifications ?: boolean
121
+ /**
122
+ * If true will always show a notification, even when the app is on the foreground. Default is false.
123
+ */
124
+ forceShow ?: boolean
87
125
}
88
126
89
127
/**
90
128
* iOS specific initialization options.
91
129
*/
92
130
ios ?: {
93
131
/**
94
- * If true the device shows an alert on receipt of notification. Default is false.
132
+ * If true|"true" the device sets the badge number on receipt of notification.
133
+ * Default is false|"false".
134
+ * Note: the value you set this option to the first time you call the init method will be how the application always acts.
135
+ * Once this is set programmatically in the init method it can only be changed manually by the user in Settings>Notifications>App Name.
136
+ * This is normal iOS behaviour.
95
137
*/
96
- badge ?: boolean
138
+ badge ?: boolean | string
97
139
/**
98
- * If true the device sets the badge number on receipt of notification. Default is false.
140
+ * If true|"true" the device plays a sound on receipt of notification.
141
+ * Default is false|"false".
142
+ * Note: the value you set this option to the first time you call the init method will be how the application always acts.
143
+ * Once this is set programmatically in the init method it can only be changed manually by the user in Settings>Notifications>App Name.
144
+ * This is normal iOS behaviour.
99
145
*/
100
- sound ?: boolean
146
+ sound ?: boolean | string
147
+ /**
148
+ * If true|"true" the device shows an alert on receipt of notification.
149
+ * Default is false|"false".
150
+ * Note: the value you set this option to the first time you call the init method will be how the application always acts.
151
+ * Once this is set programmatically in the init method it can only be changed manually by the user in Settings>Notifications>App Name.
152
+ * This is normal iOS behaviour.
153
+ */
154
+ alert ?: boolean | string
101
155
/**
102
- * If true the device plays a sound on receipt of notification . Default is false.
156
+ * If true|"true" the badge will be cleared on app startup . Default is false|"false" .
103
157
*/
104
- alert ?: boolean
158
+ clearBadge ?: boolean | string
105
159
}
106
160
107
161
/**
@@ -116,63 +170,64 @@ declare module PhonegapPluginPush {
116
170
/**
117
171
* The registration ID provided by the 3rd party remote push service.
118
172
*/
119
- registrationId :string
173
+ registrationId : string
120
174
}
121
175
122
176
interface NotificationEventResponse {
123
177
/**
124
178
* The text of the push message sent from the 3rd party service.
125
179
*/
126
- message :string
180
+ message : string
127
181
/**
128
182
* The optional title of the push message sent from the 3rd party service.
129
183
*/
130
- title ?:string
184
+ title ?: string
131
185
/**
132
186
* The number of messages to be displayed in the badge iOS or message count in the notification shade in Android.
133
187
* For windows, it represents the value in the badge notification which could be a number or a status glyph.
134
188
*/
135
- count :string
189
+ count : string
136
190
/**
137
191
* The name of the sound file to be played upon receipt of the notification.
138
192
*/
139
- sound :string
193
+ sound : string
140
194
/**
141
195
* The path of the image file to be displayed in the notification.
142
196
*/
143
- image :string
197
+ image : string
144
198
/**
145
199
* An optional collection of data sent by the 3rd party push service that does not fit in the above properties.
146
200
*/
147
201
additionalData : NotificationEventAdditionalData
148
202
}
149
203
204
+ /**
205
+ * TODO: document all possible properties (I only got the android ones)
206
+ *
207
+ * Loosened up with a dictionary notation, but all non-defined properties need to use (map['prop']) notation
208
+ *
209
+ * Ideally the developer would overload (merged declaration) this or create a new interface that would extend this one
210
+ * so that he could specify any custom code without having to use array notation (map['prop']) for all of them.
211
+ */
150
212
interface NotificationEventAdditionalData {
151
- /**
152
- * TODO: document all possible properties (I only got the android ones)
153
- *
154
- * Loosened up with a dictionary notation, but all non-defined properties need to use (map['prop']) notation
155
- *
156
- * Ideally the developer would overload (merged declaration) this or create a new interface that would extend this one
157
- * so that he could specify any custom code without having to use array notation (map['prop']) for all of them.
158
- */
159
213
[ name : string ] : any
214
+
160
215
/**
161
216
* Whether the notification was received while the app was in the foreground
162
217
*/
163
- foreground ?:boolean
164
- collapse_key ?:string
165
- from ?:string
166
- notId ?:string
218
+ foreground ?: boolean
219
+ collapse_key ?: string
220
+ from ?: string
221
+ notId ?: string
167
222
}
168
223
169
224
interface PushNotificationStatic {
170
- init ( options :InitOptions ) :PushNotification
171
- new ( options :InitOptions ) :PushNotification
225
+ init ( options : InitOptions ) : PushNotification
226
+ new ( options : InitOptions ) : PushNotification
172
227
}
173
228
}
174
229
175
230
interface Window {
176
- PushNotification :PhonegapPluginPush . PushNotificationStatic
231
+ PushNotification : PhonegapPluginPush . PushNotificationStatic
177
232
}
178
- declare var PushNotification :PhonegapPluginPush . PushNotificationStatic ;
233
+ declare var PushNotification : PhonegapPluginPush . PushNotificationStatic ;
0 commit comments