{"id":3058,"url":"https://github.com/smartlook/ios-consent-sdk","last_synced_at":"2025-08-18T09:30:35.929Z","repository":{"id":55013267,"uuid":"170864122","full_name":"smartlook/ios-consent-sdk","owner":"smartlook","description":"Configurable consent SDK for iOS","archived":false,"fork":false,"pushed_at":"2021-01-20T08:07:48.000Z","size":13094,"stargazers_count":179,"open_issues_count":2,"forks_count":9,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-04-24T18:58:36.656Z","etag":null,"topics":["analytics","consent","ios","sdk"],"latest_commit_sha":null,"homepage":"https://www.smartlook.com","language":"Swift","has_issues":true,"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/smartlook.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-15T12:49:09.000Z","updated_at":"2024-04-19T14:09:01.000Z","dependencies_parsed_at":"2022-08-14T09:01:10.293Z","dependency_job_id":null,"html_url":"https://github.com/smartlook/ios-consent-sdk","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartlook%2Fios-consent-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartlook%2Fios-consent-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartlook%2Fios-consent-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartlook%2Fios-consent-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smartlook","download_url":"https://codeload.github.com/smartlook/ios-consent-sdk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230219857,"owners_count":18192180,"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":["analytics","consent","ios","sdk"],"created_at":"2024-01-05T20:16:30.192Z","updated_at":"2024-12-18T05:16:30.140Z","avatar_url":"https://github.com/smartlook.png","language":"Swift","funding_links":[],"categories":["User Consent"],"sub_categories":["Web View"],"readme":"# SmartlookConsentSDK for iOS\n\nGetting explicit user consent with gathering analytics data in an app, or with processing the user’s personal data, is an important part of establishing user trust and seamless user experience.\n\nIt is also an obligation of an app developer stated in [App Store Guidelines](https://developer.apple.com/app-store/review/guidelines/) (2.5.14 and 5.1.2), necessary to fulfil to get your app approved for distribution.\n\nPer the guidelines, if an app uses a 3rd party tool for analytics, it is the sole responsibility of the app developer, not of the 3rd party tool provider, to verify that the analytics tool does not register events in the app without user explicit consent.\n\nAlthough implementing a simple dialog to obtain user consents and store them for further reference seems like a straightforward process — digging into it reveals (as it is usual with “simple tasks”) that many programming and design details should be respected. \n\nSince implementing the consent goes beyond core functionality and the intended design of the app, it is likely that this consent necessity will bring further annoyances, impact time and disrupt existing developing processes. \nSo why not use or reuse some ready-made SDK?\n\nThe SmartlookConsentSDK:\n- provides a configurable control panel where user can select their privacy options\n- stores the selected user preferences for the app\n- enables all texts to be fully localized \n- enables linking to privacy policies which may be provided by an external web page and presenting them without leaving the app\n\nSmartlookConsentSDK works well with both Swift and Objective-C apps.\n\n\u0026nbsp;\n\u0026nbsp;\n\n\n  ![iPad Screenshot](https://github.com/smartlook/ios-consent-sdk/raw/master/readme-media/SmartlookConsentSDKDemo2.gif) \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;  ![iPhone SettingsScreenshot](https://github.com/smartlook/ios-consent-sdk/raw/master/readme-media/ConsentSDK-Settings.png)  \n\n## Code examples\n### Simple example \nThe most straightforward use that utilises default settings:\n```swift\nSmartlookConsentSDK.check() {\n      if SmartlookConsentSDK.consentState(for: .analytics) == .provided {\n          // Start analytics tools\n      }\n}\n```\n\nThis method first checks if the user already provided/rejected consent for both `privacy` and `analytics`. If not, the privacy control panel is shown with build-in defaults (consent is provided for both). When user agrees, the callback is called to let you handle the user preferences. \n\nIn the case user previously went though these settings, the control panel is not show and the callback is called straight away.\n\n### Complex example \n\nIn this example, only consent for analytics is sought for with the consent provided by default.\n\n```swift\nvar consentsSettingsDefaults = SmartlookConsentSDK.ConsentsSettings()\n// consentsSettingsDefaults.append((.privacy, .notProvided)) \nconsentsSettingsDefaults.append((.analytics, .provided))\n\nSmartlookConsentSDK.check(with: consentsSettingsDefaults) {\n    if SmartlookConsentSDK.consentState(for: .analytics) == .provided {\n        // Start analytics tools\n    }\n}\n```\n\n## Installation\n\n### Swift Package Manager\nIntegration into the application using [Swift Package Manager](https://swift.org/package-manager/) is fully supported.\n\n### Direct framework embedding\nFramwork is ready for direct embedding in your app, e.g. the way it is embedded into the demo apps here. For detailed descriptions see this Apple Developer Portal document [Embedding Frameworks In An App](https://developer.apple.com/library/archive/technotes/tn2435/_index.html)\n\n### Cocoapods (deprecated)\nAdd cocoapod `SmartlookConsentSDK` into your Podfile.\n\n## Adding SmartlookConsentSDK to app code\n\nGenerally, you want `SmartlookConsentSDK.check()` be called at the very beginning of the app life-cycle. Where exactly, it depends on your app architecture. If you don't want integrate this SDK into the standard app Settings, then `viewDidLoad()` of the root view controller is enough. If you want more comprehensive solution, then see our demo apps `AppDelegate` and `ViewController` for an inpiration.\n\n## Objective-C\nThe SDK is fully compatible with `Objective-C`. For code examples see the respective demo app.\n\n## API\n\n### Consent\nConsent is identified by a string constant. For convenience, SDK provides a `String` alias with two predefined constants, `.privacy` a `.analytics` together with the respective text placeholders in demo app `Localizable.strings`. However, any string works, and the name convention used in `Localizable.strings` is obvious.\n\n### ConsentState\nIs a standard enumaration and indicates whether user seen and provided consent to a policy.\n- `.unknown` state indicates that the user did not reviewed the policy\n- `.notProvided` state indicates that the user explicitely refused consent to the policy\n- `.provided` state indicates that the user explicitely provided consent to the policy \n```swift\n@objc(SLCConsentState) public enum ConsentState: Int {\n      case unknown = -2\n      case notProvided = -1\n      case provided = 1\n}\n```\n### SmartlookConsentSDK.check()\nIs the key method of the SDK. It comes in two versions:\n\n```swift\n@objc public static func check(callback: @escaping RequestIdCallback)\n``` \na straigth one w/out consents configuration that can be used when both `.privacy` and `.analytics` policies consents are required with `.provided` as the default value. \n\n```swift\npublic static func check(with consentsSettings: ConsentsSettings, callback: @escaping RequestIdCallback)\n```  \na version with configuration that allows fine-tuning required consents (adding, removing, chaning order of or their default values) \n\n### SmartlookConsentSDK.show()\nTwo variants much like `check()`, it **always** opens the Control Panel for the user to review their current privacy settings.\n\n### Content Touched Notification\nWhenever user closes the panel opened by a call to `check()` or `show()`, `SmartlookConsentSDK.consentsTouchedNotification` notification is broadcased (regardless whether the consents were changed or not). This provides an alternative way to the `callback` block to let the app know there might be a change in consents.\n\nIn ObjC, the notification identifier is `SLCConsentsTouchedNotification`.\n\n## Localisation\nThe texts shown in the control panel are configured using the standard `Localizable.strings` mechanism. `Localizable.strings`  are also used to provide an optional URL of a detailed policy information (thus the link is localised as well).\n\nThe keys used in the `Localizable.strings` are listed in the table below, or you can simply reuse [the file in our demo app](https://github.com/smartlook/ios-consent-sdk/raw/master/Consents%20Demo/ConsentsDemo/Base.lproj/Localizable.strings) .\n\nLocalization follows a name conventions. If a new consent type is added (on top of the predefined convenience types `.privacy` a `.analytics`), the respective keys must be added to localized files following the pattern\n\n```\n\"smartlook-consent-sdk-*consent-key*-consent\" = \"My special consent...\";\n\"smartlook-consent-sdk-*consent-key*-consent-url\" = \"https://www.my-company.com/consent-policy-details?lang=de\"; //optional\n```\n\nwhere `*consent-key*` is simply the text string constant used to identify the policy.\n\n## iOS Settings\n\nThe Consents SDK can be straigthforwardly integrated into the iOS Settings app so the user can also review their consents there. To do this, some manual work is needed even if the SDK is integrated using Cocoapods. If you are not familiar with adding system settings panel into your app, have a look at [Implementing an iOS Settings Bundle](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/UserDefaults/Preferences/Preferences.html) or just copy the `Settings.bundle` from one of our Demo apps to start.\n\nThe key for SDK integration here is using the same names for your settings items as you use for localised strings, i.e., in order to add the most basic consent settings to iOS settings:\n\n1. Add `Settings.bundle` if it is not there\n2. Into it, add a `Toggle Switch` for each consent.\n3. To connect it with a consent, set the toggle identifier to the same string you use for it in `Localizable.strings`, e.g., `smartlook-consent-sdk-analytics-consent`\n4. Do not forget that `Settings.bundle` localisation is separated from the app localisation (the respective `.strings` file is inside the `Settings.bundle`, in the demo apps it is named `Root.strings`) \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmartlook%2Fios-consent-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmartlook%2Fios-consent-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmartlook%2Fios-consent-sdk/lists"}