@@ -12,24 +12,18 @@ import UIKit
12
12
13
13
class ViewController : UIViewController {
14
14
@IBOutlet var logTextView : UITextView !
15
-
15
+ internal var dcbCompletion : DCBUserManagerCheckCompletion ?
16
16
override func viewDidLoad( ) {
17
17
super. viewDidLoad ( )
18
18
19
19
setupLogging ( )
20
20
21
- DCBUserManager ( client: Credential . dcbClient, loggingIsEnabled: Credential . logging) . checkFlowDCB ( isActive: false ) { date in
22
- if let _ = DCBUserManager . dcbUser {
23
- print ( " User Docomo Digital " )
24
- if let date = date {
25
- print ( " User is subscribed in date \( date) " )
26
- } else {
27
- print ( " User expired, not subscribed. User must pay again to access the product " )
28
- }
29
- } else {
30
- print ( " Normal user discover the app from AppStore " )
31
- }
21
+ guard let dcbCompletion = dcbCompletion else {
22
+ print ( " the callback is nil. Please, assign it " )
23
+ return
32
24
}
25
+
26
+ DCBUserManager ( client: Credential . dcbClient, loggingIsEnabled: Credential . logging) . checkFlowDCB ( isActive: false , completion: dcbCompletion)
33
27
}
34
28
}
35
29
@@ -43,12 +37,19 @@ extension ViewController {
43
37
44
38
logTextView. insertText ( " DCB FLOW \n " )
45
39
46
- let _: DCBUserManagerCheckCompletion = { date in
47
- guard let date = date else {
48
- self . logTextView. insertText ( " \n \n DCB FLOW FINISHED WITHOUT EXPIRATION TIME " )
49
- return
40
+ dcbCompletion = { date in
41
+
42
+ if let _ = DCBUserManager . dcbUser {
43
+ self . logTextView. insertText ( " \n ● User Docomo Digital \n " )
44
+
45
+ if let date = date {
46
+ self . logTextView. insertText ( " \n ● DCB FLOW FINISHED WITHOUT EXPIRATION TIME WITH DATE: \( date) \n " )
47
+ } else {
48
+ self . logTextView. insertText ( " \n ● User expired, not subscribed. User must pay again to access the product \n " )
49
+ }
50
+ } else {
51
+ self . logTextView. insertText ( " \n ● Normal user discover the app from AppStore \n " )
50
52
}
51
- self . logTextView. insertText ( " DCB FLOW FINISHED WITHOUT EXPIRATION TIME WITH DATE: \( date) " )
52
53
}
53
54
}
54
55
0 commit comments