From 296cc69cfeb9d7288d81dcdd75f986641fb8d9bb Mon Sep 17 00:00:00 2001 From: NidhiDixit09 <93544270+NidhiDixit09@users.noreply.github.com> Date: Thu, 21 Mar 2024 19:18:36 -0700 Subject: [PATCH 01/17] Initial Checkin for testing. --- .../DeepLinkDemo.xcodeproj/project.pbxproj | 56 ++++--- .../xcschemes/DeepLinkDemo.xcscheme | 6 + DeepLinkDemo/DeepLinkDemo/AppDelegate.swift | 5 +- .../DeepLinkDemo/Base.lproj/Main.storyboard | 138 +++++++++++------- .../Controllers/GenerateURLVC.swift | 17 ++- .../Controllers/HomeViewController.swift | 130 ++++++++++++++++- .../Controllers/TextViewController.swift | 14 +- .../DeepLinkDemo/NSURLSessionBranch.m | 33 +++-- 8 files changed, 293 insertions(+), 106 deletions(-) diff --git a/DeepLinkDemo/DeepLinkDemo.xcodeproj/project.pbxproj b/DeepLinkDemo/DeepLinkDemo.xcodeproj/project.pbxproj index 81a553764..5820cf513 100644 --- a/DeepLinkDemo/DeepLinkDemo.xcodeproj/project.pbxproj +++ b/DeepLinkDemo/DeepLinkDemo.xcodeproj/project.pbxproj @@ -15,6 +15,7 @@ 1877918A283C8D2400229CD5 /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18779189283C8D2400229CD5 /* Utils.swift */; }; 1889ACED283BE1C9009E3601 /* NSURLSessionBranch.m in Sources */ = {isa = PBXBuildFile; fileRef = 1889ACEC283BE1C9009E3601 /* NSURLSessionBranch.m */; }; 18AC5ADE283F61430098736E /* LogFileListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18AC5ADD283F61430098736E /* LogFileListViewController.swift */; }; + 2A2347C154C6746FA55C3649 /* Pods_DeepLinkDemo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DDBB5A837B0C008CA5BEC1EF /* Pods_DeepLinkDemo.framework */; }; 7E1A39D42818289B002B302D /* DispalyVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E1A39D32818289B002B302D /* DispalyVC.swift */; }; 7E2AE639280ED92800142446 /* CreateObjectReferenceObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E2AE638280ED92800142446 /* CreateObjectReferenceObject.swift */; }; 7E2AE63B280EE1F700142446 /* GenerateURLVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E2AE63A280EE1F700142446 /* GenerateURLVC.swift */; }; @@ -33,8 +34,6 @@ 7EE84374281CDFAE00A1561C /* StartupOptionsData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7EE84373281CDFAE00A1561C /* StartupOptionsData.swift */; }; 7EF58D5B2812CF2300BA92D5 /* WebViewVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7EF58D5A2812CF2300BA92D5 /* WebViewVC.swift */; }; B7B7DC2A2859974E00D45FC5 /* TextViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7B7DC292859974E00D45FC5 /* TextViewController.swift */; }; - E70E80C22A0E22C1008007B6 /* BranchSDK.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = E70E80C12A0E22C1008007B6 /* BranchSDK.xcframework */; }; - E71086B529D2423100BDC598 /* Pods_DeepLinkDemo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CA28D389F8D830715B437AAD /* Pods_DeepLinkDemo.framework */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -47,8 +46,6 @@ 1889ACEB283BE1C9009E3601 /* NSURLSessionBranch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSURLSessionBranch.h; sourceTree = ""; }; 1889ACEC283BE1C9009E3601 /* NSURLSessionBranch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSURLSessionBranch.m; sourceTree = ""; }; 18AC5ADD283F61430098736E /* LogFileListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogFileListViewController.swift; sourceTree = ""; }; - 3ED981AAAEF5ECFF371D65F1 /* Pods-DeepLinkDemo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DeepLinkDemo.debug.xcconfig"; path = "Target Support Files/Pods-DeepLinkDemo/Pods-DeepLinkDemo.debug.xcconfig"; sourceTree = ""; }; - 7A19807506A47A88AF290FBF /* Pods-DeepLinkDemo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DeepLinkDemo.release.xcconfig"; path = "Target Support Files/Pods-DeepLinkDemo/Pods-DeepLinkDemo.release.xcconfig"; sourceTree = ""; }; 7E1A39D32818289B002B302D /* DispalyVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DispalyVC.swift; sourceTree = ""; }; 7E2AE638280ED92800142446 /* CreateObjectReferenceObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateObjectReferenceObject.swift; sourceTree = ""; }; 7E2AE63A280EE1F700142446 /* GenerateURLVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GenerateURLVC.swift; sourceTree = ""; }; @@ -72,8 +69,10 @@ 7EE84373281CDFAE00A1561C /* StartupOptionsData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StartupOptionsData.swift; sourceTree = ""; }; 7EF58D5A2812CF2300BA92D5 /* WebViewVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebViewVC.swift; sourceTree = ""; }; 7EF58D5C2816D14700BA92D5 /* DeepLinkDemo.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DeepLinkDemo.entitlements; sourceTree = ""; }; + 88EDCA13B444CE5565DC92FA /* Pods-DeepLinkDemo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DeepLinkDemo.release.xcconfig"; path = "Target Support Files/Pods-DeepLinkDemo/Pods-DeepLinkDemo.release.xcconfig"; sourceTree = ""; }; B7B7DC292859974E00D45FC5 /* TextViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextViewController.swift; sourceTree = ""; }; - CA28D389F8D830715B437AAD /* Pods_DeepLinkDemo.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_DeepLinkDemo.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + C06885D21868B25319262FC1 /* Pods-DeepLinkDemo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DeepLinkDemo.debug.xcconfig"; path = "Target Support Files/Pods-DeepLinkDemo/Pods-DeepLinkDemo.debug.xcconfig"; sourceTree = ""; }; + DDBB5A837B0C008CA5BEC1EF /* Pods_DeepLinkDemo.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_DeepLinkDemo.framework; sourceTree = BUILT_PRODUCTS_DIR; }; E70E80C12A0E22C1008007B6 /* BranchSDK.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = BranchSDK.xcframework; path = Framework/BranchSDK.xcframework; sourceTree = ""; }; /* End PBXFileReference section */ @@ -82,8 +81,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - E70E80C22A0E22C1008007B6 /* BranchSDK.xcframework in Frameworks */, - E71086B529D2423100BDC598 /* Pods_DeepLinkDemo.framework in Frameworks */, + 2A2347C154C6746FA55C3649 /* Pods_DeepLinkDemo.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -104,7 +102,7 @@ isa = PBXGroup; children = ( E70E80C12A0E22C1008007B6 /* BranchSDK.xcframework */, - CA28D389F8D830715B437AAD /* Pods_DeepLinkDemo.framework */, + DDBB5A837B0C008CA5BEC1EF /* Pods_DeepLinkDemo.framework */, ); name = Frameworks; sourceTree = ""; @@ -183,8 +181,8 @@ DB9F65A595474F5DA261D89A /* Pods */ = { isa = PBXGroup; children = ( - 3ED981AAAEF5ECFF371D65F1 /* Pods-DeepLinkDemo.debug.xcconfig */, - 7A19807506A47A88AF290FBF /* Pods-DeepLinkDemo.release.xcconfig */, + C06885D21868B25319262FC1 /* Pods-DeepLinkDemo.debug.xcconfig */, + 88EDCA13B444CE5565DC92FA /* Pods-DeepLinkDemo.release.xcconfig */, ); path = Pods; sourceTree = ""; @@ -196,11 +194,11 @@ isa = PBXNativeTarget; buildConfigurationList = 7E7477DA2809C46D0088A7D3 /* Build configuration list for PBXNativeTarget "DeepLinkDemo" */; buildPhases = ( - 4E20F2B3A080FBA467F97C22 /* [CP] Check Pods Manifest.lock */, + 8C8C5B24F34C07814525F311 /* [CP] Check Pods Manifest.lock */, 7E7477C22809C46C0088A7D3 /* Sources */, 7E7477C32809C46C0088A7D3 /* Frameworks */, 7E7477C42809C46C0088A7D3 /* Resources */, - 27F53A44E6856F363E13DC32 /* [CP] Embed Pods Frameworks */, + 9086714B33BB3D176E3DED70 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -261,43 +259,43 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 27F53A44E6856F363E13DC32 /* [CP] Embed Pods Frameworks */ = { + 8C8C5B24F34C07814525F311 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-DeepLinkDemo/Pods-DeepLinkDemo-frameworks-${CONFIGURATION}-input-files.xcfilelist", ); - name = "[CP] Embed Pods Frameworks"; + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-DeepLinkDemo/Pods-DeepLinkDemo-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-DeepLinkDemo-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-DeepLinkDemo/Pods-DeepLinkDemo-frameworks.sh\"\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 4E20F2B3A080FBA467F97C22 /* [CP] Check Pods Manifest.lock */ = { + 9086714B33BB3D176E3DED70 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-DeepLinkDemo/Pods-DeepLinkDemo-frameworks-${CONFIGURATION}-input-files.xcfilelist", ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; + name = "[CP] Embed Pods Frameworks"; outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-DeepLinkDemo-checkManifestLockResult.txt", + "${PODS_ROOT}/Target Support Files/Pods-DeepLinkDemo/Pods-DeepLinkDemo-frameworks-${CONFIGURATION}-output-files.xcfilelist", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-DeepLinkDemo/Pods-DeepLinkDemo-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ @@ -469,7 +467,7 @@ }; 7E7477DB2809C46D0088A7D3 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 3ED981AAAEF5ECFF371D65F1 /* Pods-DeepLinkDemo.debug.xcconfig */; + baseConfigurationReference = C06885D21868B25319262FC1 /* Pods-DeepLinkDemo.debug.xcconfig */; buildSettings = { ARCHS = "$(ARCHS_STANDARD)"; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; @@ -517,7 +515,7 @@ }; 7E7477DC2809C46D0088A7D3 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 7A19807506A47A88AF290FBF /* Pods-DeepLinkDemo.release.xcconfig */; + baseConfigurationReference = 88EDCA13B444CE5565DC92FA /* Pods-DeepLinkDemo.release.xcconfig */; buildSettings = { ARCHS = "$(ARCHS_STANDARD)"; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; diff --git a/DeepLinkDemo/DeepLinkDemo.xcodeproj/xcshareddata/xcschemes/DeepLinkDemo.xcscheme b/DeepLinkDemo/DeepLinkDemo.xcodeproj/xcshareddata/xcschemes/DeepLinkDemo.xcscheme index a2671aeb8..7be9cdc5f 100644 --- a/DeepLinkDemo/DeepLinkDemo.xcodeproj/xcshareddata/xcschemes/DeepLinkDemo.xcscheme +++ b/DeepLinkDemo/DeepLinkDemo.xcodeproj/xcshareddata/xcschemes/DeepLinkDemo.xcscheme @@ -50,6 +50,12 @@ ReferencedContainer = "container:DeepLinkDemo.xcodeproj"> + + + + - + - + @@ -887,11 +887,11 @@ - - + + - + - - - - - - - - + + + + + + + + + + - + - - - - - + + + - - + + + @@ -1131,11 +1157,18 @@ + + + + - + + + + @@ -1159,6 +1192,8 @@ + + @@ -1169,7 +1204,7 @@ - + @@ -2218,6 +2253,7 @@ + @@ -2610,7 +2646,7 @@ - + diff --git a/DeepLinkDemo/DeepLinkDemo/Controllers/GenerateURLVC.swift b/DeepLinkDemo/DeepLinkDemo/Controllers/GenerateURLVC.swift index f96afadd0..0e308ee18 100644 --- a/DeepLinkDemo/DeepLinkDemo/Controllers/GenerateURLVC.swift +++ b/DeepLinkDemo/DeepLinkDemo/Controllers/GenerateURLVC.swift @@ -185,12 +185,21 @@ class GenerateURLVC: ParentViewController { } - CommonMethod.sharedInstance.branchUniversalObject.getShortUrl(with: linkProperties, andCallback: {[weak self] url, error in + CommonMethod.sharedInstance.branchUniversalObject.getShortUrl(with: linkProperties, andCallback: {url, error in + var strDes = error?.localizedDescription + let alert = UIAlertController(title: "Error", message: strDes, preferredStyle: .alert) + alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in + UserDefaults.standard.set("buo", forKey: "isStatus") + UserDefaults.standard.set(true, forKey: "isCreatedBUO") + // self.handleOkBtnAction(dict: dict, alertMessage: "") + })) + //self.present(alert, animated: true, completion: nil) if error == nil { - self?.responseStatus = "Success" - self?.processShortURLGenerated(url) + self.responseStatus = "Success" + self.present(alert, animated: true, completion: nil) + self.processShortURLGenerated(url) } else { - self?.responseStatus = "Failure" + self.responseStatus = "Failure" } }) diff --git a/DeepLinkDemo/DeepLinkDemo/Controllers/HomeViewController.swift b/DeepLinkDemo/DeepLinkDemo/Controllers/HomeViewController.swift index 9062ef322..48d199c6a 100644 --- a/DeepLinkDemo/DeepLinkDemo/Controllers/HomeViewController.swift +++ b/DeepLinkDemo/DeepLinkDemo/Controllers/HomeViewController.swift @@ -19,12 +19,16 @@ class HomeViewController: UITableViewController { @IBOutlet weak var btnNavigateToContent: UIButton! @IBOutlet weak var btnDisplayContent: UIButton! @IBOutlet weak var btnReadLog: UIButton! + @IBOutlet weak var btnSetDMAParams: UIButton! + @IBOutlet weak var btnSendV2Event: UIButton! @IBOutlet weak var switchControl: UISwitch! @IBOutlet weak var labelStatus: UILabel! let branchObj:Branch! = nil + var logData: String! = "" + var branchSDKInitialized = false; override func viewDidLoad() { super.viewDidLoad() @@ -41,6 +45,8 @@ class HomeViewController: UITableViewController { btnNavigateToContent.layer.cornerRadius = 8.0 btnReadLog.layer.cornerRadius = 8.0 btnLoadWebView.layer.cornerRadius = 8.0 + btnSetDMAParams.layer.cornerRadius = 8.0 + btnSendV2Event.layer.cornerRadius = 8.0 NotificationCenter.default.addObserver(self, selector: #selector(self.methodOfReceivedNotification(notification:)), name: Notification.Name("NotificationIdentifier"), object: nil) @@ -65,28 +71,37 @@ class HomeViewController: UITableViewController { CommonMethod.sharedInstance.contentMetaData = nil reachability = Reachability()! reachability!.whenReachable = { reachability in - + Branch.setBranchKey("key_test_om2EWe1WBeBYmpz9Z1mdpopouDmoN72T") DispatchQueue.main.async { if textValue == "displayContent" { + self.initBranch() self.launchBUOVC(mode: 8) } else if textValue == "navigatetoContent" { + self.initBranch() self.launchBUOVC(mode: 3) } else if textValue == "sendNotification" { + self.initBranch() self.launchBUOVC(mode: 6) } else if textValue == "loadUrlInWeb" { + self.initBranch() self.launchBUOVC(mode: 4) } else if textValue == "createDeep" { + self.initBranch() self.launchBUOVC(mode: 5) } else if textValue == "shareDeeplinking" { + self.initBranch() self.launchBUOVC(mode: 2) } else if textValue == "readDeeplinking" { + self.initBranch() self.launchBUOVC(mode: 1) } else if textValue == "trackContent" { + self.initBranch() let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil) if let vc = storyBoard.instantiateViewController(withIdentifier: "TrackContentVC") as? TrackContentVC { self.navigationController?.pushViewController(vc, animated: true) } } else if textValue == "trackUser" { + self.initBranch() Branch.getInstance().setIdentity("qentelli_test_user") { params, error in if let referringParams = params as? [String :AnyObject] { @@ -104,13 +119,84 @@ class HomeViewController: UITableViewController { } else if textValue == "swichAction" { } else if textValue == "createObject" { + self.initBranch() self.launchBUOVC(mode: 0) } else if textValue == "readSystemLog" { + self.initBranch() let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil) if let vc = storyBoard.instantiateViewController(withIdentifier: "LogFileListViewController") as? LogFileListViewController { self.navigationController?.pushViewController(vc, animated: true) } - } + } else if textValue == "setDMAParams" { + self.logData = "Error: Missing testData.\n" + + let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil) + let vc = storyBoard.instantiateViewController(withIdentifier: "TextViewController") as? TextViewController + vc?.isSetDMAParams = true + + do { + let argCount = ProcessInfo.processInfo.arguments.count + if argCount >= 2 { + + for i in (1 ..< argCount) { + let data = ProcessInfo.processInfo.arguments[i].data(using: .utf8)! + + if let jsonObject = try JSONSerialization.jsonObject(with: data, options : .allowFragments) as? [String:AnyObject] + { + if ((jsonObject["dma_eea"] != nil) && (jsonObject["dma_eea"] != nil) && (jsonObject["dma_eea"] != nil)) { + let dma_eea = (jsonObject["dma_eea"] as! String).lowercased() == "yes" ? true : false + let dma_ad_personalization = (jsonObject["dma_ad_personalization"] as! String).lowercased() == "yes" ? true : false + let dma_ad_user_data = (jsonObject["dma_ad_user_data"] as! String).lowercased() == "yes" ? true : false + self.logData = "" + self.enableBranchLogging(){(msg:String,msg2:BranchLogLevel,msg3:Error?)->() in + if (msg.contains("BranchSDK")){ + self.logData = self.logData + msg + "\n" + } + vc?.updateText(msg: self.logData) + } + if(self.branchSDKInitialized){ + Branch.getInstance().resetUserSession() + } + + Branch.setDMAParamsForEEA(dma_eea, adPersonalizationConsent: dma_ad_personalization, adUserDataUsageConsent: dma_ad_user_data) + AppDelegate.shared.getBranchData(AppDelegate.shared.launchOption) + self.branchSDKInitialized = true + } else { + self.logData = "Missing params from JSON Object: \n" + jsonObject.description + } + } else { + self.logData = "Bad JSON : \n" + ProcessInfo.processInfo.arguments[i] + } + } + + + } + } catch let error as NSError { + print(error) + self.logData += error.localizedDescription + } + vc?.updateText(msg: self.logData) + self.navigationController?.pushViewController(vc!, animated: true) + + } else if textValue == "sendV2Event" { + self.logData = "" + + let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil) + let vc = storyBoard.instantiateViewController(withIdentifier: "TextViewController") as? TextViewController + + self.enableBranchLogging(){(msg:String,msg2:BranchLogLevel,msg3:Error?)->() in + if (msg.contains("BranchSDK")){ + self.logData = self.logData + msg + "\n" + vc?.updateText(msg: self.logData) + } + } + self.logEvent() + self.navigationController?.pushViewController(vc!, animated: true) + vc?.isSendV2Event = true + vc?.updateText(msg: self.logData) + self.branchSDKInitialized = true + + } } } @@ -137,6 +223,38 @@ class HomeViewController: UITableViewController { CommonAlert.shared.showActionAlertView(title: "Failure", message: "Your internet/network connection appears to be offline. Please check your internet/network connection.", actions: [], preferredStyle: .alert, viewController: self) } + func enableBranchLogging(callback: @escaping BranchLogCallback){ + BranchLogger.shared().loggingEnabled = true + BranchLogger.shared().logLevelThreshold = .verbose + BranchLogger.shared().logCallback = callback + } + func initBranch(){ + if branchSDKInitialized { + return + } + Branch.getInstance().enableLogging() + AppDelegate.shared.getBranchData(AppDelegate.shared.launchOption) + branchSDKInitialized = true + } + + func logEvent(){ + let event = BranchEvent.standardEvent(.purchase) + // Add a populated `BranchUniversalObject` to the event + let buo = BranchUniversalObject(canonicalIdentifier: "item/12345") + event.contentItems = [ buo ] + // Add additional event data + event.alias = "my custom alias" + event.transactionID = "12344555" + event.eventDescription = "event_description" + event.searchQuery = "item 123" + event.customData = [ + "Custom_Event_Property_Key1": "Custom_Event_Property_val1", + "Custom_Event_Property_Key2": "Custom_Event_Property_val2" + ] + // Log the event + event.logEvent() + } + @IBAction func sendNotificationAction(_ sender: Any) { reachabilityCheck(textValue: "sendNotification") } @@ -230,6 +348,14 @@ class HomeViewController: UITableViewController { } + + @IBAction func setDMAParams(){ + reachabilityCheck(textValue: "setDMAParams") + } + + @IBAction func sendV2Event(){ + reachabilityCheck(textValue: "sendV2Event") + } } extension UITextField { diff --git a/DeepLinkDemo/DeepLinkDemo/Controllers/TextViewController.swift b/DeepLinkDemo/DeepLinkDemo/Controllers/TextViewController.swift index 4d70738a3..375a29036 100644 --- a/DeepLinkDemo/DeepLinkDemo/Controllers/TextViewController.swift +++ b/DeepLinkDemo/DeepLinkDemo/Controllers/TextViewController.swift @@ -21,6 +21,8 @@ class TextViewController: UIViewController { var isCreateDeepLink = false var forNotification = false var isTrackUser = false + var isSetDMAParams = false + var isSendV2Event = false var url = "" var responseStatus = "" @@ -62,7 +64,12 @@ class TextViewController: UIViewController { launchWebView() } else if self.isNavigateToContent || self.isDisplayContent || self.handleLinkInWebview { launchReadVC() - } else { + } else if self.isSetDMAParams == true { + self.navigationController?.popToRootViewController(animated: true) + } else if self.isSendV2Event == true { + self.navigationController?.popToRootViewController(animated: true) + } + else { launchReadVC() } } @@ -83,4 +90,9 @@ class TextViewController: UIViewController { } } + func updateText(msg: String) -> () { + DispatchQueue.main.async() { + self.logDataTextView?.text = msg + } + } } diff --git a/DeepLinkDemo/DeepLinkDemo/NSURLSessionBranch.m b/DeepLinkDemo/DeepLinkDemo/NSURLSessionBranch.m index ec5c0d3e1..0fc12390d 100644 --- a/DeepLinkDemo/DeepLinkDemo/NSURLSessionBranch.m +++ b/DeepLinkDemo/DeepLinkDemo/NSURLSessionBranch.m @@ -7,6 +7,7 @@ #import "NSURLSessionBranch.h" #import +#import "BranchLogger.h" @implementation NSURLSession (Branch) @@ -29,29 +30,31 @@ + (void)swizzleSelector:(SEL)originalSelector withSelector:(SEL)swizzledSelector } - (void)logNetworkTrafficRequest:(NSURLRequest *)request data:(NSData *)data response:(NSURLResponse *)response { - NSLog(@"BranchSDK API LOG START OF FILE"); - NSLog(@"[LogEntryStart]\n\n"); - NSLog(@"---------------------------------------------------------------------BranchSDK LOG START ---------------------------------------------------------------------" ); - NSLog(@"[LogEntryStart]\n\n"); - NSLog(@"BranchSDK Request log: %@", request); + [[BranchLogger shared] logDebug: @"BranchSDK API LOG START OF FILE"]; + + [[BranchLogger shared] logDebug:(@"[LogEntryStart]\n\n")]; + [[BranchLogger shared] logDebug:(@"---------------------------------------------------------------------BranchSDK LOG START ---------------------------------------------------------------------" )]; + [[BranchLogger shared] logDebug:(@"[LogEntryStart]\n\n")]; + [[BranchLogger shared] logDebug:([NSString stringWithFormat: @"BranchSDK Request log: %@", request])]; NSData *body = [request HTTPBody]; if (body) { - NSLog(@"[LogEntryStart]\n\n"); - NSLog(@"BranchSDK Request Body: %@", [NSString stringWithUTF8String:body.bytes]); + [[BranchLogger shared] logDebug:(@"[LogEntryStart]\n\n")]; + [[BranchLogger shared] logDebug:[NSString stringWithFormat:@"BranchSDK Request Body: %@", [NSString stringWithUTF8String:body.bytes]]]; } - NSLog(@"[LogEntryStart]\n\n"); - NSLog(@"BranchSDK Response: %@", response); + [[BranchLogger shared] logDebug:(@"[LogEntryStart]\n\n")]; + [[BranchLogger shared] logDebug:[NSString stringWithFormat:@"BranchSDK Response: %@", response]]; if (data.bytes) { - NSLog(@"\n\n"); - NSLog(@"BranchSDK Response Data: %@", [NSString stringWithUTF8String:data.bytes]); + [[BranchLogger shared] logDebug:(@"\n\n")]; + [[BranchLogger shared] logDebug:[NSString stringWithFormat:@"BranchSDK Response Data: %@", [NSString stringWithUTF8String:data.bytes]]]; } - NSLog(@"[LogEntryStart]\n\n"); - NSLog(@"---------------------------------------------------------------------BranchSDK LOG END ---------------------------------------------------------------------" ); - NSLog(@"[LogEntryStart]\n\n"); - NSLog(@"BranchSDK API LOG END OF FILE"); + [[BranchLogger shared] logDebug:(@"[LogEntryStart]\n\n")]; + [[BranchLogger shared] logDebug:(@"---------------------------------------------------------------------BranchSDK LOG END ---------------------------------------------------------------------" )]; + [[BranchLogger shared] logDebug:(@"[LogEntryStart]\n\n")]; + [[BranchLogger shared] logDebug:(@"BranchSDK API LOG END OF FILE")]; + } // replacement method for dataTaskWithRequest From 7962cc082cb186f535d723d50023dbd82908b13e Mon Sep 17 00:00:00 2001 From: NidhiDixit09 <93544270+NidhiDixit09@users.noreply.github.com> Date: Thu, 21 Mar 2024 19:23:26 -0700 Subject: [PATCH 02/17] Temp Debug Message Added --- .../Controllers/GenerateURLVC.swift | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/DeepLinkDemo/DeepLinkDemo/Controllers/GenerateURLVC.swift b/DeepLinkDemo/DeepLinkDemo/Controllers/GenerateURLVC.swift index 0e308ee18..cdc93cefa 100644 --- a/DeepLinkDemo/DeepLinkDemo/Controllers/GenerateURLVC.swift +++ b/DeepLinkDemo/DeepLinkDemo/Controllers/GenerateURLVC.swift @@ -88,7 +88,14 @@ class GenerateURLVC: ParentViewController { UserDefaults.standard.set("createdeeplinking", forKey: "isStatus") UserDefaults.standard.set(true, forKey: "isCreatedDeepLink") UserDefaults.standard.set("\(url ?? "")", forKey: "link") - + var strDes = "processShortURLGenerated" + let alert = UIAlertController(title: "Error", message: strDes, preferredStyle: .alert) + alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in + UserDefaults.standard.set("buo", forKey: "isStatus") + UserDefaults.standard.set(true, forKey: "isCreatedBUO") + // self.handleOkBtnAction(dict: dict, alertMessage: "") + })) + self.present(alert, animated: true, completion: nil) if self.forNotification == true { self.fireLocalNotification(linkurl: "\(url ?? "")") self.launchTextViewController(url: "\(url ?? "")", message: alertMessage, forNotification: true) @@ -186,17 +193,9 @@ class GenerateURLVC: ParentViewController { CommonMethod.sharedInstance.branchUniversalObject.getShortUrl(with: linkProperties, andCallback: {url, error in - var strDes = error?.localizedDescription - let alert = UIAlertController(title: "Error", message: strDes, preferredStyle: .alert) - alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in - UserDefaults.standard.set("buo", forKey: "isStatus") - UserDefaults.standard.set(true, forKey: "isCreatedBUO") - // self.handleOkBtnAction(dict: dict, alertMessage: "") - })) - //self.present(alert, animated: true, completion: nil) + if error == nil { self.responseStatus = "Success" - self.present(alert, animated: true, completion: nil) self.processShortURLGenerated(url) } else { self.responseStatus = "Failure" From 713bd3b8659725992d55cdebc4b6f205ed2f5ced Mon Sep 17 00:00:00 2001 From: NidhiDixit09 <93544270+NidhiDixit09@users.noreply.github.com> Date: Thu, 21 Mar 2024 19:27:38 -0700 Subject: [PATCH 03/17] Update Podfile --- DeepLinkDemo/Podfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/DeepLinkDemo/Podfile b/DeepLinkDemo/Podfile index 80f3473a4..b7266ceb5 100644 --- a/DeepLinkDemo/Podfile +++ b/DeepLinkDemo/Podfile @@ -5,6 +5,8 @@ target 'DeepLinkDemo' do # Comment the next line if you don't want to use dynamic frameworks use_frameworks! pod 'IQKeyboardManager' + pod 'BranchSDK', :path => './../' + # Pods for DeepLinkDemo end From 978551ac466e304e4c73cc2183ff208756fa247d Mon Sep 17 00:00:00 2001 From: NidhiDixit09 <93544270+NidhiDixit09@users.noreply.github.com> Date: Fri, 22 Mar 2024 00:15:29 -0700 Subject: [PATCH 04/17] Fixed Crash for Empty log File. --- .../DeepLinkDemo/Controllers/GenerateURLVC.swift | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/DeepLinkDemo/DeepLinkDemo/Controllers/GenerateURLVC.swift b/DeepLinkDemo/DeepLinkDemo/Controllers/GenerateURLVC.swift index cdc93cefa..7d943c6bd 100644 --- a/DeepLinkDemo/DeepLinkDemo/Controllers/GenerateURLVC.swift +++ b/DeepLinkDemo/DeepLinkDemo/Controllers/GenerateURLVC.swift @@ -88,14 +88,6 @@ class GenerateURLVC: ParentViewController { UserDefaults.standard.set("createdeeplinking", forKey: "isStatus") UserDefaults.standard.set(true, forKey: "isCreatedDeepLink") UserDefaults.standard.set("\(url ?? "")", forKey: "link") - var strDes = "processShortURLGenerated" - let alert = UIAlertController(title: "Error", message: strDes, preferredStyle: .alert) - alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in - UserDefaults.standard.set("buo", forKey: "isStatus") - UserDefaults.standard.set(true, forKey: "isCreatedBUO") - // self.handleOkBtnAction(dict: dict, alertMessage: "") - })) - self.present(alert, animated: true, completion: nil) if self.forNotification == true { self.fireLocalNotification(linkurl: "\(url ?? "")") self.launchTextViewController(url: "\(url ?? "")", message: alertMessage, forNotification: true) @@ -161,8 +153,10 @@ class GenerateURLVC: ParentViewController { if let fileContent = self.loadTextWithFileName(fileName), !fileContent.isEmpty { let startlocation = fileContent.range(of: "BranchSDK API LOG START OF FILE") let endlocation = fileContent.range(of: "BranchSDK API LOG END OF FILE") - let apiResponse = fileContent[startlocation!.lowerBound.. Date: Fri, 22 Mar 2024 00:19:12 -0700 Subject: [PATCH 05/17] Reverted Code --- .../DeepLinkDemo/Controllers/GenerateURLVC.swift | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/DeepLinkDemo/DeepLinkDemo/Controllers/GenerateURLVC.swift b/DeepLinkDemo/DeepLinkDemo/Controllers/GenerateURLVC.swift index 7d943c6bd..4db44e6a1 100644 --- a/DeepLinkDemo/DeepLinkDemo/Controllers/GenerateURLVC.swift +++ b/DeepLinkDemo/DeepLinkDemo/Controllers/GenerateURLVC.swift @@ -88,6 +88,7 @@ class GenerateURLVC: ParentViewController { UserDefaults.standard.set("createdeeplinking", forKey: "isStatus") UserDefaults.standard.set(true, forKey: "isCreatedDeepLink") UserDefaults.standard.set("\(url ?? "")", forKey: "link") + if self.forNotification == true { self.fireLocalNotification(linkurl: "\(url ?? "")") self.launchTextViewController(url: "\(url ?? "")", message: alertMessage, forNotification: true) @@ -186,13 +187,13 @@ class GenerateURLVC: ParentViewController { } - CommonMethod.sharedInstance.branchUniversalObject.getShortUrl(with: linkProperties, andCallback: {url, error in + CommonMethod.sharedInstance.branchUniversalObject.getShortUrl(with: linkProperties, andCallback: {[weak self] url, error in if error == nil { - self.responseStatus = "Success" - self.processShortURLGenerated(url) + self?.responseStatus = "Success" + self?.processShortURLGenerated(url) } else { - self.responseStatus = "Failure" + self?.responseStatus = "Failure" } }) From 87430ee6982763c0cc133aa057c98ddaf38ff255 Mon Sep 17 00:00:00 2001 From: NidhiDixit09 <93544270+NidhiDixit09@users.noreply.github.com> Date: Fri, 22 Mar 2024 00:25:18 -0700 Subject: [PATCH 06/17] Rmoved extra line --- DeepLinkDemo/DeepLinkDemo/Controllers/GenerateURLVC.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/DeepLinkDemo/DeepLinkDemo/Controllers/GenerateURLVC.swift b/DeepLinkDemo/DeepLinkDemo/Controllers/GenerateURLVC.swift index 4db44e6a1..a1db4f8f6 100644 --- a/DeepLinkDemo/DeepLinkDemo/Controllers/GenerateURLVC.swift +++ b/DeepLinkDemo/DeepLinkDemo/Controllers/GenerateURLVC.swift @@ -88,7 +88,6 @@ class GenerateURLVC: ParentViewController { UserDefaults.standard.set("createdeeplinking", forKey: "isStatus") UserDefaults.standard.set(true, forKey: "isCreatedDeepLink") UserDefaults.standard.set("\(url ?? "")", forKey: "link") - if self.forNotification == true { self.fireLocalNotification(linkurl: "\(url ?? "")") self.launchTextViewController(url: "\(url ?? "")", message: alertMessage, forNotification: true) From 945e96428e580baad866e7f40a0cff693e593cce Mon Sep 17 00:00:00 2001 From: NidhiDixit09 <93544270+NidhiDixit09@users.noreply.github.com> Date: Fri, 22 Mar 2024 09:48:17 -0700 Subject: [PATCH 07/17] Updated workflow to use local pod --- .github/workflows/automation-trigger-test.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/automation-trigger-test.yml b/.github/workflows/automation-trigger-test.yml index ae39e1c37..212c30e18 100644 --- a/.github/workflows/automation-trigger-test.yml +++ b/.github/workflows/automation-trigger-test.yml @@ -55,10 +55,7 @@ jobs: - name: Create and export DeepLinkDemo IPA file run: | - ./scripts/prep_static_xcframework.sh cd ./DeepLinkDemo - mkdir Framework - unzip ../Branch_static.zip -d ./Framework/ pod install xcodebuild -workspace DeepLinkDemo.xcworkspace -scheme DeepLinkDemo -sdk iphoneos archive -archivePath ./IPA/DeepLinkDemo.xcarchive xcodebuild -exportArchive -archivePath ./IPA/DeepLinkDemo.xcarchive -exportOptionsPlist IPA/Info.plist -exportPath IPA/ From b6ebd4ae5a61d3db9d29bf9b0916ad366cd315a5 Mon Sep 17 00:00:00 2001 From: NidhiDixit09 <93544270+NidhiDixit09@users.noreply.github.com> Date: Fri, 22 Mar 2024 09:57:55 -0700 Subject: [PATCH 08/17] (Temp Change) - Added ref to non-master branch for testing. Must be reverted back. --- .github/workflows/automation-trigger-test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/automation-trigger-test.yml b/.github/workflows/automation-trigger-test.yml index 212c30e18..d07bd2a5c 100644 --- a/.github/workflows/automation-trigger-test.yml +++ b/.github/workflows/automation-trigger-test.yml @@ -70,6 +70,7 @@ jobs: with: repository: BranchMetrics/qentelli-saas-sdk-testing-automation token: ${{ secrets.BRANCHLET_ACCESS_TOKEN_PUBLIC }} + ref: SDK-2228-iOS-DMA-Compliance-Automation - name: Set up JDK 11 uses: actions/setup-java@v4 with: From ec875ad5dd5607d9401a3469068677bb88bdff32 Mon Sep 17 00:00:00 2001 From: NidhiDixit09 <93544270+NidhiDixit09@users.noreply.github.com> Date: Tue, 26 Mar 2024 10:27:15 -0700 Subject: [PATCH 09/17] Removed Command line arguments (were added temp. for testing). --- .../xcshareddata/xcschemes/DeepLinkDemo.xcscheme | 6 ------ 1 file changed, 6 deletions(-) diff --git a/DeepLinkDemo/DeepLinkDemo.xcodeproj/xcshareddata/xcschemes/DeepLinkDemo.xcscheme b/DeepLinkDemo/DeepLinkDemo.xcodeproj/xcshareddata/xcschemes/DeepLinkDemo.xcscheme index 7be9cdc5f..a2671aeb8 100644 --- a/DeepLinkDemo/DeepLinkDemo.xcodeproj/xcshareddata/xcschemes/DeepLinkDemo.xcscheme +++ b/DeepLinkDemo/DeepLinkDemo.xcodeproj/xcshareddata/xcschemes/DeepLinkDemo.xcscheme @@ -50,12 +50,6 @@ ReferencedContainer = "container:DeepLinkDemo.xcodeproj"> - - - - Date: Tue, 7 May 2024 16:29:32 -0700 Subject: [PATCH 10/17] Fixed code format issue - moved long if/else cases to helper method. --- .../Controllers/HomeViewController.swift | 140 +++++++++--------- 1 file changed, 73 insertions(+), 67 deletions(-) diff --git a/DeepLinkDemo/DeepLinkDemo/Controllers/HomeViewController.swift b/DeepLinkDemo/DeepLinkDemo/Controllers/HomeViewController.swift index 48d199c6a..4ca6b97bc 100644 --- a/DeepLinkDemo/DeepLinkDemo/Controllers/HomeViewController.swift +++ b/DeepLinkDemo/DeepLinkDemo/Controllers/HomeViewController.swift @@ -128,74 +128,9 @@ class HomeViewController: UITableViewController { self.navigationController?.pushViewController(vc, animated: true) } } else if textValue == "setDMAParams" { - self.logData = "Error: Missing testData.\n" - - let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil) - let vc = storyBoard.instantiateViewController(withIdentifier: "TextViewController") as? TextViewController - vc?.isSetDMAParams = true - - do { - let argCount = ProcessInfo.processInfo.arguments.count - if argCount >= 2 { - - for i in (1 ..< argCount) { - let data = ProcessInfo.processInfo.arguments[i].data(using: .utf8)! - - if let jsonObject = try JSONSerialization.jsonObject(with: data, options : .allowFragments) as? [String:AnyObject] - { - if ((jsonObject["dma_eea"] != nil) && (jsonObject["dma_eea"] != nil) && (jsonObject["dma_eea"] != nil)) { - let dma_eea = (jsonObject["dma_eea"] as! String).lowercased() == "yes" ? true : false - let dma_ad_personalization = (jsonObject["dma_ad_personalization"] as! String).lowercased() == "yes" ? true : false - let dma_ad_user_data = (jsonObject["dma_ad_user_data"] as! String).lowercased() == "yes" ? true : false - self.logData = "" - self.enableBranchLogging(){(msg:String,msg2:BranchLogLevel,msg3:Error?)->() in - if (msg.contains("BranchSDK")){ - self.logData = self.logData + msg + "\n" - } - vc?.updateText(msg: self.logData) - } - if(self.branchSDKInitialized){ - Branch.getInstance().resetUserSession() - } - - Branch.setDMAParamsForEEA(dma_eea, adPersonalizationConsent: dma_ad_personalization, adUserDataUsageConsent: dma_ad_user_data) - AppDelegate.shared.getBranchData(AppDelegate.shared.launchOption) - self.branchSDKInitialized = true - } else { - self.logData = "Missing params from JSON Object: \n" + jsonObject.description - } - } else { - self.logData = "Bad JSON : \n" + ProcessInfo.processInfo.arguments[i] - } - } - - - } - } catch let error as NSError { - print(error) - self.logData += error.localizedDescription - } - vc?.updateText(msg: self.logData) - self.navigationController?.pushViewController(vc!, animated: true) - + self.setDMAParams() } else if textValue == "sendV2Event" { - self.logData = "" - - let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil) - let vc = storyBoard.instantiateViewController(withIdentifier: "TextViewController") as? TextViewController - - self.enableBranchLogging(){(msg:String,msg2:BranchLogLevel,msg3:Error?)->() in - if (msg.contains("BranchSDK")){ - self.logData = self.logData + msg + "\n" - vc?.updateText(msg: self.logData) - } - } - self.logEvent() - self.navigationController?.pushViewController(vc!, animated: true) - vc?.isSendV2Event = true - vc?.updateText(msg: self.logData) - self.branchSDKInitialized = true - + self.sendV2EventWrapper() } } } @@ -255,6 +190,77 @@ class HomeViewController: UITableViewController { event.logEvent() } + func setDMAParamsWrapper() { + self.logData = "Error: Missing testData.\n" + + let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil) + let vc = storyBoard.instantiateViewController(withIdentifier: "TextViewController") as? TextViewController + vc?.isSetDMAParams = true + + do { + let argCount = ProcessInfo.processInfo.arguments.count + if argCount >= 2 { + + for i in (1 ..< argCount) { + let data = ProcessInfo.processInfo.arguments[i].data(using: .utf8)! + + if let jsonObject = try JSONSerialization.jsonObject(with: data, options : .allowFragments) as? [String:AnyObject] + { + if ((jsonObject["dma_eea"] != nil) && (jsonObject["dma_eea"] != nil) && (jsonObject["dma_eea"] != nil)) { + let dma_eea = (jsonObject["dma_eea"] as! String).lowercased() == "yes" ? true : false + let dma_ad_personalization = (jsonObject["dma_ad_personalization"] as! String).lowercased() == "yes" ? true : false + let dma_ad_user_data = (jsonObject["dma_ad_user_data"] as! String).lowercased() == "yes" ? true : false + self.logData = "" + self.enableBranchLogging(){(msg:String,msg2:BranchLogLevel,msg3:Error?)->() in + if (msg.contains("BranchSDK")){ + self.logData = self.logData + msg + "\n" + } + vc?.updateText(msg: self.logData) + } + if(self.branchSDKInitialized){ + Branch.getInstance().resetUserSession() + } + + Branch.setDMAParamsForEEA(dma_eea, adPersonalizationConsent: dma_ad_personalization, adUserDataUsageConsent: dma_ad_user_data) + AppDelegate.shared.getBranchData(AppDelegate.shared.launchOption) + self.branchSDKInitialized = true + } else { + self.logData = "Missing params from JSON Object: \n" + jsonObject.description + } + } else { + self.logData = "Bad JSON : \n" + ProcessInfo.processInfo.arguments[i] + } + } + + + } + } catch let error as NSError { + print(error) + self.logData += error.localizedDescription + } + vc?.updateText(msg: self.logData) + self.navigationController?.pushViewController(vc!, animated: true) + } + + func sendV2EventWrapper(){ + self.logData = "" + + let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil) + let vc = storyBoard.instantiateViewController(withIdentifier: "TextViewController") as? TextViewController + + self.enableBranchLogging(){(msg:String,msg2:BranchLogLevel,msg3:Error?)->() in + if (msg.contains("BranchSDK")){ + self.logData = self.logData + msg + "\n" + vc?.updateText(msg: self.logData) + } + } + self.logEvent() + self.navigationController?.pushViewController(vc!, animated: true) + vc?.isSendV2Event = true + vc?.updateText(msg: self.logData) + self.branchSDKInitialized = true + } + @IBAction func sendNotificationAction(_ sender: Any) { reachabilityCheck(textValue: "sendNotification") } From 774c52abbbfaf2647fdae73f678496b8047ae6ff Mon Sep 17 00:00:00 2001 From: NidhiDixit09 <93544270+NidhiDixit09@users.noreply.github.com> Date: Wed, 8 May 2024 12:28:21 -0700 Subject: [PATCH 11/17] Updated logging API. --- .../DeepLinkDemo/NSURLSessionBranch.m | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/DeepLinkDemo/DeepLinkDemo/NSURLSessionBranch.m b/DeepLinkDemo/DeepLinkDemo/NSURLSessionBranch.m index 0fc12390d..379c8e752 100644 --- a/DeepLinkDemo/DeepLinkDemo/NSURLSessionBranch.m +++ b/DeepLinkDemo/DeepLinkDemo/NSURLSessionBranch.m @@ -30,30 +30,30 @@ + (void)swizzleSelector:(SEL)originalSelector withSelector:(SEL)swizzledSelector } - (void)logNetworkTrafficRequest:(NSURLRequest *)request data:(NSData *)data response:(NSURLResponse *)response { - [[BranchLogger shared] logDebug: @"BranchSDK API LOG START OF FILE"]; + [[BranchLogger shared] logDebug: @"BranchSDK API LOG START OF FILE" error:nil]; - [[BranchLogger shared] logDebug:(@"[LogEntryStart]\n\n")]; - [[BranchLogger shared] logDebug:(@"---------------------------------------------------------------------BranchSDK LOG START ---------------------------------------------------------------------" )]; - [[BranchLogger shared] logDebug:(@"[LogEntryStart]\n\n")]; - [[BranchLogger shared] logDebug:([NSString stringWithFormat: @"BranchSDK Request log: %@", request])]; + [[BranchLogger shared] logDebug:(@"[LogEntryStart]\n\n") error:nil]; + [[BranchLogger shared] logDebug:(@"---------------------------------------------------------------------BranchSDK LOG START ---------------------------------------------------------------------" ) error:nil]; + [[BranchLogger shared] logDebug:(@"[LogEntryStart]\n\n") error:nil]; + [[BranchLogger shared] logDebug:([NSString stringWithFormat: @"BranchSDK Request log: %@", request]) error:nil]; NSData *body = [request HTTPBody]; if (body) { - [[BranchLogger shared] logDebug:(@"[LogEntryStart]\n\n")]; - [[BranchLogger shared] logDebug:[NSString stringWithFormat:@"BranchSDK Request Body: %@", [NSString stringWithUTF8String:body.bytes]]]; + [[BranchLogger shared] logDebug:(@"[LogEntryStart]\n\n") error:nil]; + [[BranchLogger shared] logDebug:[NSString stringWithFormat:@"BranchSDK Request Body: %@", [NSString stringWithUTF8String:body.bytes]] error:nil]; } - [[BranchLogger shared] logDebug:(@"[LogEntryStart]\n\n")]; - [[BranchLogger shared] logDebug:[NSString stringWithFormat:@"BranchSDK Response: %@", response]]; + [[BranchLogger shared] logDebug:(@"[LogEntryStart]\n\n") error:nil]; + [[BranchLogger shared] logDebug:[NSString stringWithFormat:@"BranchSDK Response: %@", response] error:nil]; if (data.bytes) { - [[BranchLogger shared] logDebug:(@"\n\n")]; - [[BranchLogger shared] logDebug:[NSString stringWithFormat:@"BranchSDK Response Data: %@", [NSString stringWithUTF8String:data.bytes]]]; + [[BranchLogger shared] logDebug:(@"\n\n") error:nil]; + [[BranchLogger shared] logDebug:[NSString stringWithFormat:@"BranchSDK Response Data: %@", [NSString stringWithUTF8String:data.bytes]] error:nil]; } - [[BranchLogger shared] logDebug:(@"[LogEntryStart]\n\n")]; - [[BranchLogger shared] logDebug:(@"---------------------------------------------------------------------BranchSDK LOG END ---------------------------------------------------------------------" )]; - [[BranchLogger shared] logDebug:(@"[LogEntryStart]\n\n")]; - [[BranchLogger shared] logDebug:(@"BranchSDK API LOG END OF FILE")]; + [[BranchLogger shared] logDebug:(@"[LogEntryStart]\n\n") error:nil]; + [[BranchLogger shared] logDebug:(@"---------------------------------------------------------------------BranchSDK LOG END ---------------------------------------------------------------------" ) error:nil]; + [[BranchLogger shared] logDebug:(@"[LogEntryStart]\n\n") error:nil]; + [[BranchLogger shared] logDebug:(@"BranchSDK API LOG END OF FILE") error:nil]; } From 33b8074476d57f54ea2141e78a5232e26a654a01 Mon Sep 17 00:00:00 2001 From: NidhiDixit09 <93544270+NidhiDixit09@users.noreply.github.com> Date: Thu, 9 May 2024 12:21:45 -0700 Subject: [PATCH 12/17] Updated branch ref for testing --- .github/workflows/automation-trigger-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/automation-trigger-test.yml b/.github/workflows/automation-trigger-test.yml index d07bd2a5c..960d5ad95 100644 --- a/.github/workflows/automation-trigger-test.yml +++ b/.github/workflows/automation-trigger-test.yml @@ -70,7 +70,7 @@ jobs: with: repository: BranchMetrics/qentelli-saas-sdk-testing-automation token: ${{ secrets.BRANCHLET_ACCESS_TOKEN_PUBLIC }} - ref: SDK-2228-iOS-DMA-Compliance-Automation + ref: Improvements - name: Set up JDK 11 uses: actions/setup-java@v4 with: From e9417c9c706bea9d825bf32595571a8dcbf606ba Mon Sep 17 00:00:00 2001 From: NidhiDixit09 <93544270+NidhiDixit09@users.noreply.github.com> Date: Thu, 9 May 2024 19:18:00 -0700 Subject: [PATCH 13/17] Fix for failing DMA test --- .../DeepLinkDemo/Controllers/HomeViewController.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/DeepLinkDemo/DeepLinkDemo/Controllers/HomeViewController.swift b/DeepLinkDemo/DeepLinkDemo/Controllers/HomeViewController.swift index 4ca6b97bc..d5b469ffd 100644 --- a/DeepLinkDemo/DeepLinkDemo/Controllers/HomeViewController.swift +++ b/DeepLinkDemo/DeepLinkDemo/Controllers/HomeViewController.swift @@ -129,6 +129,7 @@ class HomeViewController: UITableViewController { } } else if textValue == "setDMAParams" { self.setDMAParams() + self.setDMAParamsWrapper() } else if textValue == "sendV2Event" { self.sendV2EventWrapper() } @@ -167,7 +168,8 @@ class HomeViewController: UITableViewController { if branchSDKInitialized { return } - Branch.getInstance().enableLogging() + Branch.enableLogging(); + Branch.getInstance(); AppDelegate.shared.getBranchData(AppDelegate.shared.launchOption) branchSDKInitialized = true } From 559e03bc9a527ee4600d4a5355c30a704cee2095 Mon Sep 17 00:00:00 2001 From: NidhiDixit09 <93544270+NidhiDixit09@users.noreply.github.com> Date: Thu, 9 May 2024 20:45:30 -0700 Subject: [PATCH 14/17] Fixed data type issue in json file --- .../DeepLinkDemo/Controllers/HomeViewController.swift | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/DeepLinkDemo/DeepLinkDemo/Controllers/HomeViewController.swift b/DeepLinkDemo/DeepLinkDemo/Controllers/HomeViewController.swift index d5b469ffd..db09ef092 100644 --- a/DeepLinkDemo/DeepLinkDemo/Controllers/HomeViewController.swift +++ b/DeepLinkDemo/DeepLinkDemo/Controllers/HomeViewController.swift @@ -128,7 +128,6 @@ class HomeViewController: UITableViewController { self.navigationController?.pushViewController(vc, animated: true) } } else if textValue == "setDMAParams" { - self.setDMAParams() self.setDMAParamsWrapper() } else if textValue == "sendV2Event" { self.sendV2EventWrapper() @@ -209,9 +208,9 @@ class HomeViewController: UITableViewController { if let jsonObject = try JSONSerialization.jsonObject(with: data, options : .allowFragments) as? [String:AnyObject] { if ((jsonObject["dma_eea"] != nil) && (jsonObject["dma_eea"] != nil) && (jsonObject["dma_eea"] != nil)) { - let dma_eea = (jsonObject["dma_eea"] as! String).lowercased() == "yes" ? true : false - let dma_ad_personalization = (jsonObject["dma_ad_personalization"] as! String).lowercased() == "yes" ? true : false - let dma_ad_user_data = (jsonObject["dma_ad_user_data"] as! String).lowercased() == "yes" ? true : false + let dma_eea = jsonObject["dma_eea"] as! Bool + let dma_ad_personalization = jsonObject["dma_ad_personalization"] as! Bool + let dma_ad_user_data = jsonObject["dma_ad_user_data"] as! Bool self.logData = "" self.enableBranchLogging(){(msg:String,msg2:BranchLogLevel,msg3:Error?)->() in if (msg.contains("BranchSDK")){ From ba842abe6d2c9192e1ebe43f60039c7f4ec8645c Mon Sep 17 00:00:00 2001 From: NidhiDixit09 <93544270+NidhiDixit09@users.noreply.github.com> Date: Tue, 14 May 2024 10:21:21 -0700 Subject: [PATCH 15/17] Added logging callback function for writing into text files --- .../DeepLinkDemo/Constants/Utils.swift | 23 +++++++++++++++++++ .../Controllers/HomeViewController.swift | 8 +++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/DeepLinkDemo/DeepLinkDemo/Constants/Utils.swift b/DeepLinkDemo/DeepLinkDemo/Constants/Utils.swift index 137d498d9..87b6394c3 100644 --- a/DeepLinkDemo/DeepLinkDemo/Constants/Utils.swift +++ b/DeepLinkDemo/DeepLinkDemo/Constants/Utils.swift @@ -57,5 +57,28 @@ class Utils: NSObject { freopen(cstr, "a+", stderr) } + + func printLogMessage(_ message: String) { + do { + print(message) // print to console + + if !FileManager.default.fileExists(atPath: logFileName!) { // does it exits? + FileManager.default.createFile(atPath: logFileName!, contents: nil) + } + + if let data = message.data(using: .utf8) { + let fileHandle = try FileHandle(forWritingTo: URL(fileURLWithPath: logFileName!)) + if #available(iOS 13.4, *) { + try fileHandle.seekToEnd() + try fileHandle.write(contentsOf: data) + try fileHandle.close() + } else { + print("Unable to write log: iOS Version not supported") + } + } + } catch let error as NSError { // something wrong + print("Unable to write log: \(error.debugDescription)") // debug printout + } + } } diff --git a/DeepLinkDemo/DeepLinkDemo/Controllers/HomeViewController.swift b/DeepLinkDemo/DeepLinkDemo/Controllers/HomeViewController.swift index db09ef092..ba4fadea3 100644 --- a/DeepLinkDemo/DeepLinkDemo/Controllers/HomeViewController.swift +++ b/DeepLinkDemo/DeepLinkDemo/Controllers/HomeViewController.swift @@ -167,8 +167,12 @@ class HomeViewController: UITableViewController { if branchSDKInitialized { return } - Branch.enableLogging(); - Branch.getInstance(); + self.enableBranchLogging(){(message:String, loglevel:BranchLogLevel, error:Error?)->() in + if (message.contains("BranchSDK")){ + self.logData = self.logData + message + "\n" + Utils.shared.printLogMessage(message + "\n") + } + } AppDelegate.shared.getBranchData(AppDelegate.shared.launchOption) branchSDKInitialized = true } From e15fff649b1c34658f9c9e5745b9a292f57930a8 Mon Sep 17 00:00:00 2001 From: NidhiDixit09 <93544270+NidhiDixit09@users.noreply.github.com> Date: Tue, 14 May 2024 17:45:38 -0700 Subject: [PATCH 16/17] Fixed print function - Added locks and removed extra setLogFile call. --- .../DeepLinkDemo/Constants/Utils.swift | 45 ++++++++++--------- .../Controllers/TrackContentVC.swift | 1 - 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/DeepLinkDemo/DeepLinkDemo/Constants/Utils.swift b/DeepLinkDemo/DeepLinkDemo/Constants/Utils.swift index 87b6394c3..b0182457b 100644 --- a/DeepLinkDemo/DeepLinkDemo/Constants/Utils.swift +++ b/DeepLinkDemo/DeepLinkDemo/Constants/Utils.swift @@ -58,27 +58,30 @@ class Utils: NSObject { } - func printLogMessage(_ message: String) { - do { - print(message) // print to console - - if !FileManager.default.fileExists(atPath: logFileName!) { // does it exits? - FileManager.default.createFile(atPath: logFileName!, contents: nil) - } - - if let data = message.data(using: .utf8) { - let fileHandle = try FileHandle(forWritingTo: URL(fileURLWithPath: logFileName!)) - if #available(iOS 13.4, *) { - try fileHandle.seekToEnd() - try fileHandle.write(contentsOf: data) - try fileHandle.close() - } else { - print("Unable to write log: iOS Version not supported") - } - } - } catch let error as NSError { // something wrong - print("Unable to write log: \(error.debugDescription)") // debug printout - } + func printLogMessage(_ message: String) { + objc_sync_enter(self) + do { + print(message) // print to console + + if !FileManager.default.fileExists(atPath: logFileName!) { // does it exits? + FileManager.default.createFile(atPath: logFileName!, contents: nil) + } + + if let data = message.data(using: .utf8) { + let fileHandle = try FileHandle(forWritingTo: URL(fileURLWithPath: logFileName!)) + if #available(iOS 13.4, *) { + print(" ============= ********** Writing in file " + logFileName!) + try fileHandle.seekToEnd() + try fileHandle.write(contentsOf: data) + try fileHandle.close() + } else { + print("Unable to write log: iOS Version not supported") + } + } + } catch let error as NSError { // something wrong + print("Unable to write log: \(error.debugDescription)") // debug printout + } + objc_sync_exit(self) } } diff --git a/DeepLinkDemo/DeepLinkDemo/Controllers/TrackContentVC.swift b/DeepLinkDemo/DeepLinkDemo/Controllers/TrackContentVC.swift index 2289d6b7a..9efe7653d 100644 --- a/DeepLinkDemo/DeepLinkDemo/Controllers/TrackContentVC.swift +++ b/DeepLinkDemo/DeepLinkDemo/Controllers/TrackContentVC.swift @@ -38,7 +38,6 @@ class TrackContentVC: ParentViewController { override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) - Utils.shared.setLogFile("TrackContent") } From 5b8a90314437dcdd4477b44bb03c1ab6bccc31be Mon Sep 17 00:00:00 2001 From: NidhiDixit09 <93544270+NidhiDixit09@users.noreply.github.com> Date: Wed, 29 May 2024 17:53:21 -0700 Subject: [PATCH 17/17] Removed Ref to "Improvements" branch which was added for testing. --- .github/workflows/automation-trigger-test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/automation-trigger-test.yml b/.github/workflows/automation-trigger-test.yml index 960d5ad95..212c30e18 100644 --- a/.github/workflows/automation-trigger-test.yml +++ b/.github/workflows/automation-trigger-test.yml @@ -70,7 +70,6 @@ jobs: with: repository: BranchMetrics/qentelli-saas-sdk-testing-automation token: ${{ secrets.BRANCHLET_ACCESS_TOKEN_PUBLIC }} - ref: Improvements - name: Set up JDK 11 uses: actions/setup-java@v4 with: