@@ -73,51 +73,54 @@ class ViewController: UIViewController {
7373 @IBAction func showInApp2Tap( _ sender: UIButton ) {
7474 ITBInfo ( )
7575
76- let networkSession = MockNetworkSession (
77- statusCode: 200 ,
78- json: [ " inAppMessages " : [ [
79- " content " : [ " html " : " <a href='https://www.google.com/q=something'>Click Here</a> " ] ,
80- " messageId " : " messageId " ,
81- " campaignId " : " campaignId " ] ] ] )
76+ let mockInAppSynchronizer = MockInAppSynchronizer ( )
77+ let mockInAppDelegate = MockInAppDelegate ( showInApp: . skip)
78+ let config = IterableConfig ( )
79+ config. inAppDelegate = mockInAppDelegate
80+ let payload = [ " inAppMessages " : [ [
81+ " content " : [ " html " : " <a href='https://www.google.com/q=something'>Click Here</a> " ] ,
82+ " messageId " : " messageId " ,
83+ " campaignId " : " campaignId " ] ]
84+ ]
8285 IterableAPI . initializeForTesting ( apiKey: " apiKey " ,
83- networkSession: networkSession)
84-
85- networkSession. callback = { ( _, _, _) in
86- networkSession. data = [ : ] . toData ( )
87- }
86+ config: config,
87+ inAppSynchronizer: mockInAppSynchronizer,
88+ inAppDisplayer: InAppDisplayer ( ) )
8889
89- IterableAPI . spawnInAppNotification { ( str) in
90- ITBInfo ( " callback: \( str ?? " <nil> " ) " )
90+ mockInAppSynchronizer. mockInAppPayloadFromServer ( payload)
91+ let message = IterableAPI . inAppManager. getMessages ( ) [ 0 ]
92+
93+ IterableAPI . inAppManager. show ( message: message, consume: true ) { ( str) in
9194 self . statusLbl. text = str
9295 }
9396 }
9497
9598 // Center
9699 @IBAction func showInApp3Tap( _ sender: UIButton ) {
97100 ITBInfo ( )
98-
99- // In app with Center display
100- // with left and right padding > 100
101- let networkSession = MockNetworkSession (
102- statusCode : 200 ,
103- json : [ " inAppMessages " : [ [
104- " content " : [
105- " html " : " <a href='https://www.google.com/q=something'>Click Here</a> " ,
106- " inAppDisplaySettings " : [ " backgroundAlpha " : 0.5 , " left " : [ " percentage " : 60 ] , " right " : [ " percentage " : 60 ] , " bottom " : [ " displayOption " : " AutoExpand " ] , " top " : [ " displayOption " : " AutoExpand " ] ]
107- ] ,
108- " messageId " : " messageId " ,
109- " campaignId " : " campaignId " ,
110- ]
111- ] ] )
101+
102+ let mockInAppSynchronizer = MockInAppSynchronizer ( )
103+ let mockInAppDelegate = MockInAppDelegate ( showInApp : . skip )
104+ let config = IterableConfig ( )
105+ config . inAppDelegate = mockInAppDelegate
106+ let payload = [ " inAppMessages " : [ [
107+ " content " : [
108+ " html " : " <a href='https://www.google.com/q=something'>Click Here</a> " ,
109+ " inAppDisplaySettings " : [ " backgroundAlpha " : 0.5 , " left " : [ " percentage " : 60 ] , " right " : [ " percentage " : 60 ] , " bottom " : [ " displayOption " : " AutoExpand " ] , " top " : [ " displayOption " : " AutoExpand " ] ]
110+ ] ,
111+ " messageId " : " messageId " ,
112+ " campaignId " : " campaignId " ,
113+ ] ]
114+ ]
112115 IterableAPI . initializeForTesting ( apiKey: " apiKey " ,
113- networkSession: networkSession)
116+ config: config,
117+ inAppSynchronizer: mockInAppSynchronizer,
118+ inAppDisplayer: InAppDisplayer ( ) )
114119
115- networkSession. callback = { ( _, _, _) in
116- networkSession. data = [ : ] . toData ( )
117- }
120+ mockInAppSynchronizer. mockInAppPayloadFromServer ( payload)
121+ let message = IterableAPI . inAppManager. getMessages ( ) [ 0 ]
118122
119- IterableAPI . spawnInAppNotification { ( str) in
120- ITBInfo ( " callback: \( str ?? " <nil> " ) " )
123+ IterableAPI . inAppManager. show ( message: message, consume: true ) { ( str) in
121124 self . statusLbl. text = str
122125 }
123126 }
0 commit comments