Swiftpack.co -  allaboutapps/gdpr-ios as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
allaboutapps/gdpr-ios
A GDPR framework for iOS
.package(url: "https://github.com/allaboutapps/gdpr-ios.git", from: "1.2.3")

Policy Manager Library

Swift 5 SPM

To support GDPR requirements this library helps manage settings for different tracking services and supports multiple flows to manage when a user agrees to the terms of service and the privacy policy. The Views were written using SwiftUI but they can easily be integrated in projects that use UIKit using UIHostingController.

Usage

An example app is included demonstrating the library's functionality.

Getting Started

Start with setting up the terms and privacy policy urls of your app, and setting third-party services. Each service must have a unique id in order to track its changes.

let gdprManager = GDPRManager.shared
        GDPRManager.shared.setURLs(termsURL: Bundle.main.url(forResource: "terms_of_service", withExtension: "html")!, privacyPolicyURL: Bundle.main.url(forResource: "privacy_policy", withExtension: "html")!)
        gdprManager.delegate = self
        
        gdprManager.setService(id: "S1", name: "Service Example 1", description: "Description", supportDeletion: true)
        gdprManager.setService(id: "S2", name: "Service Example 2", description: "Description", supportDeletion: false)
}

Use Cases

The sdk offers three options:

  • Show the settings to the user without forcing them to accept the terms.
  • Show the settings as a form and force the user to accept the terms in order to proceed.
  • Show an alert telling the user that the terms and conditions have changed.

Show Settings

GDPRManager.shared.showSettings(title: "Legal Settings")

Show Form

GDPRManager.shared.showForm(title: "Legal Settings", onConfirm: { [weak self] in
            // proceed to next step
            print("Confirmed!")
        }))

Show Alert

let alert = GDPRManager.shared.showAlert(title: "Legal Settings") { [weak self] view in
                // this view is the setting view that can be presented if the user chooses the option to read new terms and conditions
            }
            present(alert, animated: true, completion: nil)

Helper Functions

  • Update the latest terms/privacy policy time stamp:
GDPRManager.shared.updateLatestPolicyTimestamp(date: Date())
  • Check if user accepted the latest terms:
GDPRManager.shared.shouldPresentTOS() -> Bool
  • Accept the latest terms:
GDPRManager.shared.acceptTermsAndPolicy()

Delegate

The framework offers a GDPRDelegate protocol to track when Terms of Services are confirmed, data deletion is called, and the user opts in or our of serivces.

func serviceValueDidChange(id: String, value: Bool)
func deleteDate(id: String)
func termsAndConditionsAccepted()

Appearance Customization

The framework offers an Appearance class to customize colors and fonts.

Version Compatibility

Current Swift compatibility breakdown:

Swift Version Framework Version
5.x 1.x

Installation

Swift Package Manager (Recommended)

Add the following dependency to your Package.swift file:

.package(url: "https://github.com/allaboutapps/gdpr-ios", from: "1.2.0")

Manually

Just drag and drop the .swift files in the grpr-ios folder into your project.

GitHub

link
Stars: 2
Last commit: 1 week ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

17 weeks ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API