@@ -18,6 +18,7 @@ const Countly = {};
18
18
Countly . serverUrl = "" ;
19
19
Countly . appKey = "" ;
20
20
_isInitialized = false ;
21
+ _isPushInitialized = false ;
21
22
/*
22
23
* Listener for rating widget callback, when callback recieve we will remove the callback using listener.
23
24
*/
@@ -200,6 +201,7 @@ Countly.askForNotificationPermission = function(customSoundPath = "null"){
200
201
return message ;
201
202
}
202
203
CountlyReactNative . askForNotificationPermission ( [ customSoundPath ] ) ;
204
+ _isPushInitialized = true ;
203
205
}
204
206
205
207
/**
@@ -212,6 +214,54 @@ Countly.registerForNotification = function(theListener){
212
214
CountlyReactNative . registerForNotification ( [ ] ) ;
213
215
return event ;
214
216
} ;
217
+
218
+ /**
219
+ *
220
+ * Configure intent redirection checks for push notification
221
+ * Should be called before Countly "askForNotificationPermission"
222
+ *
223
+ * @param {array of allowed class names } allowedIntentClassNames set allowed intent class names
224
+ * @param {array of allowed package names } allowedIntentClassNames set allowed intent package names
225
+ * @param {bool to check additional intent checks } useAdditionalIntentRedirectionChecks by default its true
226
+ */
227
+ Countly . configureIntentRedirectionCheck = function ( allowedIntentClassNames = [ ] , allowedIntentPackageNames = [ ] , useAdditionalIntentRedirectionChecks = true ) {
228
+ if ( Platform . OS . match ( "ios" ) ) return "configureIntentRedirectionCheck : not required for iOS" ;
229
+
230
+ if ( _isPushInitialized ) {
231
+ var message = "'configureIntentRedirectionCheck' must be called before 'askForNotificationPermission'" ;
232
+ Countly . logError ( "configureIntentRedirectionCheck" , message ) ;
233
+ return message ;
234
+ }
235
+ if ( ! Array . isArray ( allowedIntentClassNames ) ) {
236
+ var message = "Ignoring, unsupported data type '" + ( typeof allowedIntentClassNames ) + "' 'allowedIntentClassNames' should be an array of String" ;
237
+ Countly . logWarning ( "configureIntentRedirectionCheck" , message ) ;
238
+ allowedIntentClassNames = [ ]
239
+ }
240
+ if ( ! Array . isArray ( allowedIntentPackageNames ) ) {
241
+ var message = "Ignoring, unsupported data type '" + ( typeof allowedIntentPackageNames ) + "' 'allowedIntentPackageNames' should be an array of String" ;
242
+ Countly . logWarning ( "configureIntentRedirectionCheck" , message ) ;
243
+ allowedIntentPackageNames = [ ]
244
+ }
245
+
246
+ if ( typeof useAdditionalIntentRedirectionChecks != "boolean" ) {
247
+ var message = "Ignoring, unsupported data type '" + ( typeof useAdditionalIntentRedirectionChecks ) + "' 'useAdditionalIntentRedirectionChecks' should be a boolean" ;
248
+ Countly . logWarning ( "configureIntentRedirectionCheck" , message ) ;
249
+ useAdditionalIntentRedirectionChecks = true
250
+ }
251
+
252
+ var _allowedIntentClassNames = [ ] ;
253
+ for ( var className of allowedIntentClassNames ) {
254
+ _allowedIntentClassNames . push ( className . toString ( ) ) ;
255
+ }
256
+
257
+ var _allowedIntentPackageNames = [ ] ;
258
+ for ( var packageName of allowedIntentPackageNames ) {
259
+ _allowedIntentPackageNames . push ( packageName . toString ( ) ) ;
260
+ }
261
+
262
+ CountlyReactNative . configureIntentRedirectionCheck ( _allowedIntentClassNames , _allowedIntentPackageNames , useAdditionalIntentRedirectionChecks ) ;
263
+ }
264
+
215
265
// countly start for android
216
266
Countly . start = function ( ) {
217
267
if ( ! _isInitialized ) {
0 commit comments