@@ -40,6 +40,10 @@ class ViewController: UITableViewController {
4040 @IBOutlet weak var rewardPointsToRedeemTextField : UITextField !
4141 @IBOutlet weak var customEventNameTextField : UITextField !
4242 @IBOutlet weak var customEventMetadataTextView : UITextView !
43+ @IBOutlet weak var activeBranchKeyTextField : UITextField !
44+ @IBOutlet weak var activeSetDebugEnabledSwitch : UISwitch !
45+ @IBOutlet weak var pendingBranchKeyTextField : UITextField !
46+ @IBOutlet weak var pendingSetDebugEnabledSwitch : UISwitch !
4347
4448 var linkProperties = [ String: AnyObject] ( )
4549 var universalObjectProperties = [ String: AnyObject] ( )
@@ -90,25 +94,20 @@ class ViewController: UITableViewController {
9094 name: Notification . Name ( " BranchCallbackCompleted " ) ,
9195 object: nil )
9296
93-
94-
9597 linkTextField. text = " "
9698 refreshControlValues ( )
9799 refreshEnabledButtons ( )
98100 }
99101
100102 func applicationDidBecomeActive( ) {
101- loadLinkPropertiesButton. isEnabled = false
102- loadObjectPropertiesButton. isEnabled = false
103+ refreshEnabledButtons ( )
103104 }
104105
105106 func refreshEnabledButtons( ) {
106107 var enableButtons = false
107108
108109 if let clickedBranchLink = Branch . getInstance ( ) . getLatestReferringParams ( ) [ " +clicked_branch_link " ] as! Bool ? {
109110 enableButtons = clickedBranchLink
110-
111- print ( Branch . getInstance ( ) . getLatestReferringParams ( ) . JSONDescription ( ) )
112111 }
113112 if enableButtons == true {
114113 loadLinkPropertiesButton. isEnabled = true
@@ -174,6 +173,8 @@ class ViewController: UITableViewController {
174173 self . performSegue ( withIdentifier: " ShowContentView " , sender: " FirstReferringParams " )
175174 print ( " Branch TestBed: FirstReferringParams: \n " , content)
176175 }
176+ case ( 6 , 0 ) :
177+ self . performSegue ( withIdentifier: " ShowTextViewFormNavigationBar " , sender: " pendingBranchKey " )
177178 default : break
178179 }
179180 }
@@ -184,18 +185,20 @@ class ViewController: UITableViewController {
184185 setBranchLinkProperty ( key)
185186 }
186187
187- print ( universalObjectProperties [ " $canonical_identifier " ] )
188188 if let canonicalIdentifier = universalObjectProperties [ " $canonical_identifier " ] as? String {
189189 branchUniversalObject = BranchUniversalObject . init ( canonicalIdentifier: canonicalIdentifier)
190190 } else {
191- print ( universalObjectProperties [ " $canonical_identifier " ] )
192- branchUniversalObject = BranchUniversalObject . init ( canonicalIdentifier: " _ " )
191+ var canonicalIdentifier = " "
192+ for _ in 1 ... 18 {
193+ canonicalIdentifier. append ( String ( arc4random_uniform ( 10 ) ) )
194+ }
195+ branchUniversalObject = BranchUniversalObject . init ( canonicalIdentifier: canonicalIdentifier)
193196 }
194197
195198 for key in universalObjectProperties. keys {
196199 setBranchUniversalObjectProperty ( key)
197200 }
198-
201+
199202 branchUniversalObject. showShareSheet ( with: branchLinkProperties, andShareText: shareText, from: self , anchor: actionButton) { ( activityType, completed) in
200203 if ( completed) {
201204 print ( String ( format: " Branch TestBed: Completed sharing to %@ " , activityType!) )
@@ -216,7 +219,6 @@ class ViewController: UITableViewController {
216219 linkProperties [ key] = value as AnyObject ?
217220 }
218221 }
219-
220222 self . showAlert ( " Link Properties Loadded " , withDescription: " " )
221223 }
222224
@@ -245,7 +247,6 @@ class ViewController: UITableViewController {
245247 setBranchLinkProperty ( key)
246248 }
247249
248- print ( universalObjectProperties [ " $canonical_identifier " ] )
249250 if let canonicalIdentifier = universalObjectProperties [ " $canonical_identifier " ] as? String {
250251 branchUniversalObject = BranchUniversalObject . init ( canonicalIdentifier: canonicalIdentifier)
251252 } else {
@@ -332,28 +333,10 @@ class ViewController: UITableViewController {
332333 }
333334 }
334335
335- @IBAction func viewFirstReferringParamsButtonTouchUpInside( _ sender: AnyObject ) {
336- let branch = Branch . getInstance ( )
337- let params = branch? . getFirstReferringParams ( )
338- let content = String ( format: " FirstReferringParams: \n \n %@ " , ( params? . description) !)
339-
340- self . performSegue ( withIdentifier: " ShowContentView " , sender: content)
341- print ( " Branch TestBed: FirstReferringParams: \n " , content)
342- }
343-
344- @IBAction func viewLatestReferringParamsButtonTouchUpInside( _ sender: AnyObject ) {
345- let branch = Branch . getInstance ( )
346- let params = branch? . getFirstReferringParams ( )
347- let content = String ( format: " LatestReferringParams: \n \n %@ " , ( params? . description) !)
348-
349- self . performSegue ( withIdentifier: " ShowContentView " , sender: content)
350- print ( " Branch TestBed: LatestReferringParams: \n " , content)
336+ @IBAction func pendingSetDebugEnabledButtonValueChanged( _ sender: AnyObject ) {
337+ DataStore . setPendingPendingSetDebugEnabled ( self . pendingSetDebugEnabledSwitch. isOn)
351338 }
352339
353- @IBAction func simulateContentAccessButtonTouchUpInside( _ sender: AnyObject ) {
354- self . branchUniversalObject. registerView ( )
355- self . showAlert ( " Content Access Registered " , withDescription: " " )
356- }
357340
358341 func textFieldDidChange( _ sender: UITextField ) {
359342 sender. resignFirstResponder ( )
@@ -455,6 +438,15 @@ class ViewController: UITableViewController {
455438 } else {
456439 vc. contentType = " \n App has not yet been opened via a Branch link "
457440 }
441+ case " pendingBranchKey " :
442+ let nc = segue. destination as! UINavigationController
443+ let vc = nc. topViewController as! TextViewFormTableViewController
444+ vc. sender = sender as! String
445+ vc. viewTitle = " Branch Key "
446+ vc. header = " Branch Key "
447+ vc. footer = " This Branch key will be used the next time the application is closed (not merely backgrounded) and re-opened. "
448+ vc. keyboardType = UIKeyboardType . alphabet
449+ vc. incumbantValue = DataStore . getPendingBranchKey ( ) !
458450 default :
459451 break
460452 }
@@ -537,6 +529,14 @@ class ViewController: UITableViewController {
537529 DataStore . setCustomEventName ( customEventName)
538530 self . customEventNameTextField. text = customEventName
539531 }
532+ case " pendingBranchKey " :
533+ if let pendingBranchKey = vc. textView. text {
534+ guard self . pendingBranchKeyTextField. text != pendingBranchKey else {
535+ return
536+ }
537+ DataStore . setPendingBranchKey ( pendingBranchKey)
538+ self . pendingBranchKeyTextField. text = pendingBranchKey
539+ }
540540 default : break
541541 }
542542 }
@@ -668,6 +668,14 @@ class ViewController: UITableViewController {
668668 } else {
669669 customEventMetadataTextView. text = " "
670670 }
671+ activeBranchKeyTextField. text = DataStore . getActiveBranchKey ( )
672+ activeSetDebugEnabledSwitch. isOn = DataStore . getActiveSetDebugEnabled ( ) !
673+ pendingBranchKeyTextField. text = DataStore . getPendingBranchKey ( )
674+ pendingSetDebugEnabledSwitch. isOn = DataStore . getPendingSetDebugEnabled ( ) !
675+
676+ if activeBranchKeyTextField. text == " " {
677+ showAlert ( " Initialization Failure " , withDescription: " Close and re-open app to initialize Branch " )
678+ }
671679 }
672680
673681 func showAlert( _ alertTitle: String , withDescription message: String ) {
0 commit comments