Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Licensing concept [draft] #555

Closed
felix-schwarz opened this issue Oct 31, 2019 · 1 comment · Fixed by #571
Closed

Licensing concept [draft] #555

felix-schwarz opened this issue Oct 31, 2019 · 1 comment · Fixed by #571
Assignees
Milestone

Comments

@felix-schwarz
Copy link
Contributor

Licensing

Overview

The OCLicense set of classes allow gating and granting access to features through an extensible number of different mechanisms through a single, unified interface:

  • OCLicenseFeature represents a particular feature for which access is gated.

  • OCLicenseProduct represents a product and is defined by a collection of features.

    • for an IAP unlocking a single feature, that product would be defined by that single feature
    • for an Unlock all IAP, that product would be defined by all features
    • this allows creating tailored products consisting of a particular feature set, representing actual products
  • OCLicenseEnvironment encapsulates information on an environment against which the authorization to use a product should be checked

    • typically defined by host name, TLS certificate, etc.
  • OCLicenseEntitlement represents the entitlement to use a product. An entitlement

    • identifies its origin: where does it come from?
    • includes an expiryDate property (to allow trials + subscription expirations)
    • provides information on validity and applicability:
      • validity: if this entitlement should be considered at all (i.e. has not expired)
      • applicability: if this entitlement actually authorizes the use of a product in a certain OCLicenseEnvironment
        • can limit the authorization to use a product/feature to a certain domain/TLS certificate/public key
  • OCLicenseOffer represents an offer to purchase a product

  • OCLicenseProvider retrieve and provide information

    • about licensed/purchased products in the form of OCLicenseEntitlements, sourced from f.ex.
      • In App Purchases
      • Subscriptions
      • License Information pulled from a server
      • App Store Receipt original purchase date
    • about offers in the form of OCLicenseOffer, source from f.ex.
      • StoreKit (App Store)
  • OCLicenseManager

    • puts all these pieces together and provides APIs to determine if the usage of a certain feature is allowed
    • allows observation of single or groups of products and features in a particular environment and notify on change (handled through OCLicenseObserver)

Hierarchy

  • Sessions

    • OCLicenseEnvironment
  • OCLicenseManager

    • OCLicenseFeatures
    • OCLicenseProducts
    • OCLicenseProviders
      • OCLicenseEntitlements
      • OCLicenseOffers
    • OCLicenseObserver
      • app code

Examples

Registering features and products

// Register features
[OCLicenseManger.sharedLicenseManager registerFeature:[OCLicenseFeature featureWithIdentifier:@"feature.document-scanning" localizedName:@"Document scanning"]];
[OCLicenseManger.sharedLicenseManager registerFeature:[OCLicenseFeature featureWithIdentifier:@"feature.push-notifications" localizedName:@"Push notification"]];

// Register products
[OCLicenseManger.sharedLicenseManager registerProduct:[OCLicenseProduct productWithIdentifier:@"product.document-scanner" localizedName:@"Document scanner" contents:@[
	@"feature.document-scanning"
]]];

[OCLicenseManger.sharedLicenseManager registerProduct:[OCLicenseProduct productWithIdentifier:@"product.document-scanner" localizedName:@"Push notifications" contents:@[
	@"feature.push-notifications"
]]];

[OCLicenseManger.sharedLicenseManager registerProduct:[OCLicenseProduct productWithIdentifier:@"product.unlock-all" localizedName:@"Unlock all" contents:@[
	@"com.owncloud.document-scanning",
	@"com.owncloud.push-notifications"
]]];

Determining state and reacting to changes

[OCLicenseManager.sharedLicenseManager observeProducts:nil features:@[ @"product.document-scanner" ] environment:core.environment withOwner:self updateHandler:^(OCLicenseObserver *observer, BOOL isInitial, OCLicenseAuthorizationStatus authorizationStatus){
	// Handle updates to authorization status to use the document scanner feature	
}];

Reference

App Store Receipt parsing

@jesmrec jesmrec added this to the 1.3.0-Next milestone Nov 4, 2019
@michaelstingl michaelstingl linked a pull request Feb 4, 2020 that will close this issue
15 tasks
@felix-schwarz
Copy link
Contributor Author

felix-schwarz commented Feb 17, 2020

Moved

The information in this issue has been updated and extended and can now be found at information can now be found in the repository, where it continues to be maintained.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants