@@ -108,6 +108,10 @@ class PushNotificationIOS {
108
108
* See https://reactnative.dev/docs/pushnotificationios.html#cancelalllocalnotifications
109
109
*/
110
110
static cancelAllLocalNotifications ( ) {
111
+ invariant (
112
+ RNCPushNotificationIOS ,
113
+ 'PushNotificationManager is not available.' ,
114
+ ) ;
111
115
RNCPushNotificationIOS . cancelAllLocalNotifications ( ) ;
112
116
}
113
117
@@ -117,6 +121,10 @@ class PushNotificationIOS {
117
121
* See https://reactnative.dev/docs/pushnotificationios.html#removealldeliverednotifications
118
122
*/
119
123
static removeAllDeliveredNotifications ( ) : void {
124
+ invariant (
125
+ RNCPushNotificationIOS ,
126
+ 'PushNotificationManager is not available.' ,
127
+ ) ;
120
128
RNCPushNotificationIOS . removeAllDeliveredNotifications ( ) ;
121
129
}
122
130
@@ -128,6 +136,10 @@ class PushNotificationIOS {
128
136
static getDeliveredNotifications (
129
137
callback : ( notifications : Array < Object > ) => void ,
130
138
) : void {
139
+ invariant (
140
+ RNCPushNotificationIOS ,
141
+ 'PushNotificationManager is not available.' ,
142
+ ) ;
131
143
RNCPushNotificationIOS . getDeliveredNotifications ( callback ) ;
132
144
}
133
145
@@ -137,6 +149,10 @@ class PushNotificationIOS {
137
149
* See https://reactnative.dev/docs/pushnotificationios.html#removedeliverednotifications
138
150
*/
139
151
static removeDeliveredNotifications ( identifiers : Array < string > ) : void {
152
+ invariant (
153
+ RNCPushNotificationIOS ,
154
+ 'PushNotificationManager is not available.' ,
155
+ ) ;
140
156
RNCPushNotificationIOS . removeDeliveredNotifications ( identifiers ) ;
141
157
}
142
158
@@ -146,6 +162,10 @@ class PushNotificationIOS {
146
162
* See https://reactnative.dev/docs/pushnotificationios.html#setapplicationiconbadgenumber
147
163
*/
148
164
static setApplicationIconBadgeNumber ( number : number ) {
165
+ invariant (
166
+ RNCPushNotificationIOS ,
167
+ 'PushNotificationManager is not available.' ,
168
+ ) ;
149
169
RNCPushNotificationIOS . setApplicationIconBadgeNumber ( number ) ;
150
170
}
151
171
@@ -155,6 +175,10 @@ class PushNotificationIOS {
155
175
* See https://reactnative.dev/docs/pushnotificationios.html#getapplicationiconbadgenumber
156
176
*/
157
177
static getApplicationIconBadgeNumber ( callback : Function ) {
178
+ invariant (
179
+ RNCPushNotificationIOS ,
180
+ 'PushNotificationManager is not available.' ,
181
+ ) ;
158
182
RNCPushNotificationIOS . getApplicationIconBadgeNumber ( callback ) ;
159
183
}
160
184
@@ -164,6 +188,10 @@ class PushNotificationIOS {
164
188
* See https://reactnative.dev/docs/pushnotificationios.html#cancellocalnotification
165
189
*/
166
190
static cancelLocalNotifications ( userInfo : Object ) {
191
+ invariant (
192
+ RNCPushNotificationIOS ,
193
+ 'PushNotificationManager is not available.' ,
194
+ ) ;
167
195
RNCPushNotificationIOS . cancelLocalNotifications ( userInfo ) ;
168
196
}
169
197
@@ -173,6 +201,10 @@ class PushNotificationIOS {
173
201
* See https://reactnative.dev/docs/pushnotificationios.html#getscheduledlocalnotifications
174
202
*/
175
203
static getScheduledLocalNotifications ( callback : Function ) {
204
+ invariant (
205
+ RNCPushNotificationIOS ,
206
+ 'PushNotificationManager is not available.' ,
207
+ ) ;
176
208
RNCPushNotificationIOS . getScheduledLocalNotifications ( callback ) ;
177
209
}
178
210
@@ -265,20 +297,22 @@ class PushNotificationIOS {
265
297
badge : boolean ,
266
298
sound : boolean ,
267
299
} > {
268
- let requestedPermissions = { } ;
300
+ let requestedPermissions = {
301
+ alert : true ,
302
+ badge : true ,
303
+ sound : true ,
304
+ } ;
269
305
if ( permissions ) {
270
306
requestedPermissions = {
271
307
alert : ! ! permissions . alert ,
272
308
badge : ! ! permissions . badge ,
273
309
sound : ! ! permissions . sound ,
274
310
} ;
275
- } else {
276
- requestedPermissions = {
277
- alert : true ,
278
- badge : true ,
279
- sound : true ,
280
- } ;
281
311
}
312
+ invariant (
313
+ RNCPushNotificationIOS ,
314
+ 'PushNotificationManager is not available.' ,
315
+ ) ;
282
316
return RNCPushNotificationIOS . requestPermissions ( requestedPermissions ) ;
283
317
}
284
318
@@ -288,6 +322,10 @@ class PushNotificationIOS {
288
322
* See https://reactnative.dev/docs/pushnotificationios.html#abandonpermissions
289
323
*/
290
324
static abandonPermissions ( ) {
325
+ invariant (
326
+ RNCPushNotificationIOS ,
327
+ 'PushNotificationManager is not available . ',
328
+ ) ;
291
329
RNCPushNotificationIOS . abandonPermissions ( ) ;
292
330
}
293
331
@@ -299,6 +337,10 @@ class PushNotificationIOS {
299
337
*/
300
338
static checkPermissions ( callback : Function ) {
301
339
invariant ( typeof callback === 'function ', 'Must provide a valid callback ') ;
340
+ invariant (
341
+ RNCPushNotificationIOS ,
342
+ 'PushNotificationManager is not available.' ,
343
+ ) ;
302
344
RNCPushNotificationIOS . checkPermissions ( callback ) ;
303
345
}
304
346
@@ -309,6 +351,10 @@ class PushNotificationIOS {
309
351
* See https://reactnative.dev/docs/pushnotificationios.html#getinitialnotification
310
352
*/
311
353
static getInitialNotification ( ) : Promise < ?PushNotificationIOS > {
354
+ invariant (
355
+ RNCPushNotificationIOS ,
356
+ 'PushNotificationManager is not available.' ,
357
+ ) ;
312
358
return RNCPushNotificationIOS . getInitialNotification ( ) . then (
313
359
( notification ) => {
314
360
return notification && new PushNotificationIOS ( notification ) ;
@@ -372,6 +418,10 @@ class PushNotificationIOS {
372
418
}
373
419
this . _remoteNotificationCompleteCallbackCalled = true ;
374
420
421
+ invariant (
422
+ RNCPushNotificationIOS ,
423
+ 'PushNotificationManager is not available.' ,
424
+ ) ;
375
425
RNCPushNotificationIOS . onFinishRemoteNotification (
376
426
this . _notificationId ,
377
427
fetchResult ,
0 commit comments