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/* eslint-disable tsdoc/syntax */
2831/**
2932 * The main class for the Iterable React Native SDK.
@@ -46,7 +49,7 @@ export class Iterable {
4649 /**
4750 * Current configuration of the Iterable SDK
4851 */
49- static savedConfig : IterableConfig = new IterableConfig ( ) ;
52+ static savedConfig : IterableConfig = defaultConfig ;
5053
5154 /**
5255 * In-app message manager for the current user.
@@ -98,8 +101,9 @@ export class Iterable {
98101 * });
99102 * ```
100103 */
101- static embeddedManager : IterableEmbeddedManager =
102- new IterableEmbeddedManager ( ) ;
104+ static embeddedManager : IterableEmbeddedManager = new IterableEmbeddedManager (
105+ defaultConfig
106+ ) ;
103107
104108 /**
105109 * Initializes the Iterable React Native SDK in your app's Javascript or Typescript code.
@@ -177,6 +181,8 @@ export class Iterable {
177181
178182 IterableLogger . setLoggingEnabled ( config . logReactNativeSdkCalls ?? true ) ;
179183 IterableLogger . setLogLevel ( config . logLevel ) ;
184+
185+ Iterable . embeddedManager = new IterableEmbeddedManager ( config ) ;
180186 }
181187
182188 this . setupEventHandlers ( ) ;
@@ -933,10 +939,10 @@ export class Iterable {
933939 if ( Platform . OS === 'android' ) {
934940 //Give enough time for Activity to wake up.
935941 setTimeout ( ( ) => {
936- callUrlHandler ( url , context ) ;
942+ callUrlHandler ( Iterable . savedConfig , url , context ) ;
937943 } , 1000 ) ;
938944 } else {
939- callUrlHandler ( url , context ) ;
945+ callUrlHandler ( Iterable . savedConfig , url , context ) ;
940946 }
941947 } ) ;
942948 }
@@ -1031,22 +1037,6 @@ export class Iterable {
10311037 }
10321038 ) ;
10331039 }
1034-
1035- function callUrlHandler ( url : string , context : IterableActionContext ) {
1036- // MOB-10424: Figure out if this is purposeful
1037- // eslint-disable-next-line eqeqeq
1038- if ( Iterable . savedConfig . urlHandler ?.( url , context ) == false ) {
1039- Linking . canOpenURL ( url )
1040- . then ( ( canOpen ) => {
1041- if ( canOpen ) {
1042- Linking . openURL ( url ) ;
1043- }
1044- } )
1045- . catch ( ( reason ) => {
1046- IterableLogger ?. log ( 'could not open url: ' + reason ) ;
1047- } ) ;
1048- }
1049- }
10501040 }
10511041
10521042 /**
0 commit comments