@@ -18,6 +18,7 @@ const Countly = {};
1818Countly . serverUrl = "" ;
1919Countly . appKey = "" ;
2020_isInitialized = false ;
21+ _isPushInitialized = false ;
2122/*
2223* Listener for rating widget callback, when callback recieve we will remove the callback using listener.
2324*/
@@ -200,6 +201,7 @@ Countly.askForNotificationPermission = function(customSoundPath = "null"){
200201 return message ;
201202 }
202203 CountlyReactNative . askForNotificationPermission ( [ customSoundPath ] ) ;
204+ _isPushInitialized = true ;
203205}
204206
205207/**
@@ -212,6 +214,54 @@ Countly.registerForNotification = function(theListener){
212214 CountlyReactNative . registerForNotification ( [ ] ) ;
213215 return event ;
214216} ;
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+
215265// countly start for android
216266Countly . start = function ( ) {
217267 if ( ! _isInitialized ) {
0 commit comments