1- import { Linking , NativeEventEmitter , Platform } from 'react-native' ;
1+ import { NativeEventEmitter , Platform } from 'react-native' ;
22
33import { buildInfo } from '../../itblBuildInfo' ;
44
55import { RNIterableAPI } from '../../api' ;
6+ import { IterableEmbeddedManager } from '../../embedded/classes/IterableEmbeddedManager' ;
67import { IterableInAppManager } from '../../inApp/classes/IterableInAppManager' ;
78import { IterableInAppMessage } from '../../inApp/classes/IterableInAppMessage' ;
89import { IterableInAppCloseSource } from '../../inApp/enums/IterableInAppCloseSource' ;
@@ -11,6 +12,7 @@ import { IterableInAppLocation } from '../../inApp/enums/IterableInAppLocation';
1112import { IterableAuthResponseResult } from '../enums/IterableAuthResponseResult' ;
1213import { IterableEventName } from '../enums/IterableEventName' ;
1314import type { IterableAuthFailure } from '../types/IterableAuthFailure' ;
15+ import { callUrlHandler } from '../utils/callUrlHandler' ;
1416import { IterableAction } from './IterableAction' ;
1517import { IterableActionContext } from './IterableActionContext' ;
1618import { IterableApi } from './IterableApi' ;
@@ -20,10 +22,11 @@ import { IterableAuthResponse } from './IterableAuthResponse';
2022import type { IterableCommerceItem } from './IterableCommerceItem' ;
2123import { IterableConfig } from './IterableConfig' ;
2224import { IterableLogger } from './IterableLogger' ;
23- import { IterableEmbeddedManager } from '../../embedded/classes/IterableEmbeddedManager' ;
2425
2526const RNEventEmitter = new NativeEventEmitter ( RNIterableAPI ) ;
2627
28+ const defaultConfig = new IterableConfig ( ) ;
29+
2730/**
2831 * Checks if the response is an IterableAuthResponse
2932 */
@@ -63,7 +66,7 @@ export class Iterable {
6366 /**
6467 * Current configuration of the Iterable SDK
6568 */
66- static savedConfig : IterableConfig = new IterableConfig ( ) ;
69+ static savedConfig : IterableConfig = defaultConfig ;
6770
6871 /**
6972 * In-app message manager for the current user.
@@ -115,8 +118,9 @@ export class Iterable {
115118 * });
116119 * ```
117120 */
118- static embeddedManager : IterableEmbeddedManager =
119- new IterableEmbeddedManager ( ) ;
121+ static embeddedManager : IterableEmbeddedManager = new IterableEmbeddedManager (
122+ defaultConfig
123+ ) ;
120124
121125 /**
122126 * Initializes the Iterable React Native SDK in your app's Javascript or Typescript code.
@@ -195,9 +199,7 @@ export class Iterable {
195199 IterableLogger . setLoggingEnabled ( config . logReactNativeSdkCalls ?? true ) ;
196200 IterableLogger . setLogLevel ( config . logLevel ) ;
197201
198- Iterable . embeddedManager . setEnabled (
199- config . enableEmbeddedMessaging ?? false
200- ) ;
202+ Iterable . embeddedManager = new IterableEmbeddedManager ( config ) ;
201203 }
202204
203205 this . setupEventHandlers ( ) ;
@@ -983,10 +985,10 @@ export class Iterable {
983985 if ( Platform . OS === 'android' ) {
984986 //Give enough time for Activity to wake up.
985987 setTimeout ( ( ) => {
986- callUrlHandler ( url , context ) ;
988+ callUrlHandler ( Iterable . savedConfig , url , context ) ;
987989 } , 1000 ) ;
988990 } else {
989- callUrlHandler ( url , context ) ;
991+ callUrlHandler ( Iterable . savedConfig , url , context ) ;
990992 }
991993 } ) ;
992994 }
@@ -1081,22 +1083,6 @@ export class Iterable {
10811083 }
10821084 ) ;
10831085 }
1084-
1085- function callUrlHandler ( url : string , context : IterableActionContext ) {
1086- // MOB-10424: Figure out if this is purposeful
1087- // eslint-disable-next-line eqeqeq
1088- if ( Iterable . savedConfig . urlHandler ?.( url , context ) == false ) {
1089- Linking . canOpenURL ( url )
1090- . then ( ( canOpen ) => {
1091- if ( canOpen ) {
1092- Linking . openURL ( url ) ;
1093- }
1094- } )
1095- . catch ( ( reason ) => {
1096- IterableLogger ?. log ( 'could not open url: ' + reason ) ;
1097- } ) ;
1098- }
1099- }
11001086 }
11011087
11021088 /**
0 commit comments