{"id":23143085,"url":"https://github.com/cleancocoa/triallicensing","last_synced_at":"2025-08-17T14:33:06.239Z","repository":{"id":87401484,"uuid":"68994899","full_name":"CleanCocoa/TrialLicensing","owner":"CleanCocoa","description":"Swift framework to deal with licensing and time-based trial periods in macOS apps.","archived":false,"fork":false,"pushed_at":"2024-05-10T07:36:41.000Z","size":179,"stargazers_count":56,"open_issues_count":0,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-14T19:03:25.987Z","etag":null,"topics":["license","mac","serial","trial"],"latest_commit_sha":null,"homepage":null,"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/CleanCocoa.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}},"created_at":"2016-09-23T06:17:23.000Z","updated_at":"2024-11-08T16:26:29.000Z","dependencies_parsed_at":"2023-12-05T12:34:04.873Z","dependency_job_id":null,"html_url":"https://github.com/CleanCocoa/TrialLicensing","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CleanCocoa%2FTrialLicensing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CleanCocoa%2FTrialLicensing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CleanCocoa%2FTrialLicensing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CleanCocoa%2FTrialLicensing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CleanCocoa","download_url":"https://codeload.github.com/CleanCocoa/TrialLicensing/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230136132,"owners_count":18178812,"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":["license","mac","serial","trial"],"created_at":"2024-12-17T15:12:07.646Z","updated_at":"2024-12-17T15:12:08.113Z","avatar_url":"https://github.com/CleanCocoa.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Time-Based Trial App Licensing\n\nAdds time-based trial and easy license verification using [CocoaFob](https://github.com/glebd/cocoafob) to your macOS app.\n\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n\n**For setup instructions of your own store and app preparation with FastSpring, have a look at my book [_Make Money Outside the Mac App Store_](https://christiantietze.de/books/make-money-outside-mac-app-store-fastspring/)!**\n\n## Installation\n\n### Swift Package Manager\n\n```swift\ndependencies: [\n  .package(url: \"https://github.com/CleanCocoa/TrialLicensing.git\", .upToNextMajor(from: Version(3, 0, 0))),\n]\n```\n\nAdd package depencency via Xcode by using this URL: `https://github.com/CleanCocoa/TrialLicensing.git`\n\nCocoaFob is automatically linked statically for you, no need to do anything.\n\n### Carthage\n\n* Include the `Trial` and `TrialLicense` libraries in your project.\n* Include the [CocoaFob (Swift 5)](https://github.com/glebd/cocoafob/tree/master/swift5) library in your project, too. (You have to link this in the app because a library cannot embed another library.)\n\n## Usage\n\n* Create an `AppLicensing` instance with `licenseChangeBlock` and `invalidLicenseInformationBlock` handling change events.\n* Set up and start the trial.\n\nExample:\n\n```swift\nimport TrialLicense\n\nlet publicKey = [\n        \"-----BEGIN DSA PUBLIC KEY-----\\n\",\n        // ...\n        \"-----END DSA PUBLIC KEY-----\\n\"\n    ].join(\"\")\nlet configuration = LicenseConfiguration(appName: \"AmazingApp!\", publicKey: publicKey)\n\nclass MyApp: AppLicensingDelegate {\n\n    init() {\n\n        AppLicensing.setUp(\n            configuration: configuration,\n            initialTrialDuration: Days(30),\n\n            // Set up the callbacks:\n            licenseChangeBlock: self.licenseDidChange(licenseInfo:),\n            invalidLicenseInformationBlock: self.didEnterInvalidLicenseCode(name:licenseCode:),\n\n            // Get notified about initial state to unlock the app immediately:\n            fireInitialState: true)\n    }\n\n    func licenseDidChange(licenseInformation: LicenseInformation) {\n\n        switch licenseInformation {\n        case .onTrial(_):\n            // Changing back to trial may be possible if you support unregistering\n            // form the app (and the trial period is still good.)\n            return\n\n        case .registered(_):\n            // For example:\n            //   displayThankYouAlert()\n            //   unlockApp()\n\n        case .trialUp:\n            // For example:\n            //   displayTrialUpAlert()\n            //   lockApp()\n            //   showRegisterApp()\n        }\n    }\n\n    func didEnterInvalidLicenseCode(name: String, licenseCode: String) {\n\n        // For example:\n        //   displayInvalidLicenseAlert()\n        // -- or show an error label in the license window.\n    }\n}\n\nlet myApp = MyApp()\n```\n\n\n## Privacy Manifest\n\nThe package declares usage of `UserDefaults` API because it ships with these mechanisms to read/write information in principle. That's it.\n\nIf you use this to store actual customer names and/or email addresses in your app, depending on the licensing scheme you use, you should check that your app has a `NSPrivacyCollectedDataTypes` entry with e.g. a value of `NSPrivacyCollectedDataTypeEmailAddress`.\n\n\n## Components\n\n`LicenseInformation` reveals the state your app is in:\n\n```swift\nenum LicenseInformation {\n    case registered(License)\n    case onTrial(TrialPeriod)\n    case trialUp\n}\n```\n\nThe associated types provide additional information, for example to display details in a settings window or show remaining trial days in the title bar of your app.\n\n`License` represents a valid name--license code pair:\n\n```swift\nstruct License {\n    let name: String\n    let licenseCode: String\n}\n```\n\n`TrialPeriod` encapsulates the duration of the trial.\n\n```swift\nstruct TrialPeriod {\n    let startDate: Date\n    let endDate: Date\n}\n```\n\n`TrialPeriod` also provides these convenience methods:\n\n* `ended() -\u003e Bool`\n* `daysLeft() -\u003e Days`\n\n... where `Days` encapsulates the remainder for easy conversion to `TimeInterval` and exposing `userFacingAmount: Int` for display.\n\n## License\n\nCopyright (c) 2016 by [Christian Tietze](https://christiantietze.de/). Distributed under the MIT License. See the LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcleancocoa%2Ftriallicensing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcleancocoa%2Ftriallicensing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcleancocoa%2Ftriallicensing/lists"}