{"id":19777945,"url":"https://github.com/datadome/iossdk-example","last_synced_at":"2025-07-14T21:34:09.390Z","repository":{"id":113111042,"uuid":"187181077","full_name":"DataDome/IOSSDK-Example","owner":"DataDome","description":"Sample application integrating DataDome","archived":false,"fork":false,"pushed_at":"2022-01-31T11:34:26.000Z","size":1320,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-28T12:21:39.094Z","etag":null,"topics":["ios","mobile-sdk"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DataDome.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-17T08:48:01.000Z","updated_at":"2025-01-02T10:05:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"191f8686-6120-4d9c-8171-476f6569f9aa","html_url":"https://github.com/DataDome/IOSSDK-Example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/DataDome/IOSSDK-Example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DataDome%2FIOSSDK-Example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DataDome%2FIOSSDK-Example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DataDome%2FIOSSDK-Example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DataDome%2FIOSSDK-Example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DataDome","download_url":"https://codeload.github.com/DataDome/IOSSDK-Example/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DataDome%2FIOSSDK-Example/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265352470,"owners_count":23751925,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ios","mobile-sdk"],"created_at":"2024-11-12T05:27:12.672Z","updated_at":"2025-07-14T21:34:09.229Z","avatar_url":"https://github.com/DataDome.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DataDome\n\n[![Version](https://img.shields.io/cocoapods/v/DataDomeSDK.svg?style=flat)](http://cocoapods.org/pods/DataDomeSDK)\n[![License](https://img.shields.io/cocoapods/l/DataDomeSDK.svg?style=flat)](http://cocoapods.org/pods/DataDomeSDK)\n[![Platform](https://img.shields.io/cocoapods/p/DataDomeSDK.svg?style=flat)](http://cocoapods.org/pods/DataDomeSDK)\n\n## Installation\n\nDataDomeSDK is available on [CocoaPods](http://cocoapods.org). To get the SDK integrated to your project, simply add the following line to your Podfile:\n\n```ruby\npod \"DataDomeSDK\"\n```\n\nRun `pod install` to download and integrate the framework to your project.\n\n## Getting started\n\n1. Run your application. It is going to crash with the following log\n```\nFatal error: [DataDome] Missing DataDomeKey (Your client side key) in your Info.plist\n```\n2. In your Info.plist, add a new entry with String type, use **DataDomeKey** as key and your actual client side key as value.\n3. You can run now the app, it won't crash. You should see a log confirming the SDK is running\n```\n[DataDome] Version x.y.z\n```\n\nCongrats, the DataDome framework is well integrated\n\n## Logging\nIf you need to see the logs produced by the framework, you can set the log level to control the detail of logs you get\n\n```swift\nimport DataDomeSDK\nDataDomeSDK.setLogLevel(level: .verbose)\n```\n\nBy default, the framework is completely silent.\n\nThe following table contains different logging levels that you may consider using\n\n\n Level            \t\t\t| Description\n---------------------------\t|----------------------------------------------\n__verbose__      \t\t\t| Everything is logged\n__info__      \t\t\t\t| Info messages, warnings and errors are shown\n__warning__      \t\t\t| Only warning and errors messages are printed \n__error__      \t\t\t\t| Only errors are printed\n__none__      \t\t\t\t| Silent mode (default)\n\n\n## Force a captcha display\nYou can simulate a captcha display using the framework by providing a user agent with the value **BLOCKUA**\n\nTo do so:\n\n1. Edit your app scheme\n2. Under Run (Debug) \u003e Arguments \u003e Environment Variables, create a new variable\n3. Set the name to **DATADOME\\_USER\\_AGENT** and the value to **BLOCKUA**\n\nThe DataDome framework will inject the specified user agent in the requests the app will be sending. Using the **BLOCKUA** user agent value will hint our remote protection module installed on your servers to treat this request as if it is coming from a bot. Which will block it with a captcha response.\n\nSince the DataDome framework retains the cookies after resolving the captcha, this test can be done only the first time you used the BLOCKUA user agent. To reproduce the test case, you can use the following code snippet to manually clear the cookies stored in your app\n\n```swift\nfor cookie in HTTPCookieStorage.shared.cookies ?? [] {\n\tHTTPCookieStorage.shared.deleteCookie(cookie)\n}\n```\n\n## Disable method swizzling\nThe DataDome Framework is using method swizzling to setup a `proxy` listening to all `URLRequests` performed by the app. The framework will then detect automatically blocked requests, lookup dynamically the top view controller in your app hierarchy and attach a captcha view controller to it. Once resolved, the framework will dismiss the captcha view controller and retry the blocked request with a new generate cookie. All this is done under the hood.\n\nIf you want to disable the method swizzling and manually tell the framework which request to monitor instead of monitoring all the traffic or / and you want to manually present and dismiss the captcha controller, please consider the following steps:\n\n1. In your Info.plist, add a new entry with Boolean type, use **DataDomeProxyEnabled** as key and **NO** as value. This will disable method swizzling in the framework.\n2. For each request to protect with DataDome, use the following methods to create the data task\n\n```swift\nfunc protectedDataTask(with url: URL,\n\t\t\t\t\t captchaDelegate: CaptchaDelegate?,\n\t\t\t\t\t completionHandler: @escaping (Data?, URLResponse?, Error?) -\u003e Void) \n-\u003e URLSessionDataTask\n```\n\n```swift\nfunc protectedDataTask(with request: URLSessionRequest,\n\t\t\t\t\t captchaDelegate: CaptchaDelegate?,\n\t\t\t\t\t completionHandler: @escaping (Data?, URLResponse?, Error?) -\u003e Void) \n-\u003e URLSessionDataTask\n```\n\nOnly the `URLSessionDataTasks` created by the above two methods are monitored and protected by DataDome. \n\nHere a sample code to create and execute a data task\n\n```swift\nimport DataDomeSDK\n\n\nguard let url = URL(string: \"https://datadome.co\") else {\n\treturn\n}\n\nlet task = URLSession.shared.protectedDataTask(with: url, captchaDelegate: self, completionHandler: { _, _, _ in\n\tprint(\"Request completed\")\n})\n        \ntask.resume()\n```\n\n\nTo manually manage the presentation of the captcha view controller, implement the `CaptchaDelegate` protocol\n\n```swift\nextension MyViewController: CaptchaDelegate {\n    func present(captchaController controller: UIViewController) {\n        self.navigationController?.present(controller, animated: true, completion: nil)\n    }\n    \n    func dismiss(captchaController controller: UIViewController) {\n        controller.dismiss(animated: true, completion: nil)\n    }\n}\n```\n\nVisit the [official documentation](https://docs.datadome.co/docs/sdk-ios) for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatadome%2Fiossdk-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdatadome%2Fiossdk-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatadome%2Fiossdk-example/lists"}