Skip to content

Commit

Permalink
Update the Documentation Page for Promotional Offers (#18)
Browse files Browse the repository at this point in the history
* Update the documentation

* Update `CHANGELOG.md`
  • Loading branch information
nik3212 authored Jan 22, 2024
1 parent 33804c9 commit 1f56285
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ All notable changes to this project will be documented in this file.
- Added `visionOS` to list of supported platforms
- Added in Pull Request [#5](https://github.com/space-code/flare/pull/5).

## Updated
- Update the documentation page for Promotional Offer
- Updated in Pull Request [#18](https://github.com/space-code/flare/pull/18).

## Fixed
- Fix typos in `CONTRIBUTING.md`
- Added in Pull Request[#14](https://github.com/space-code/flare/pull/14).
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Flare is a framework written in Swift that makes it easy for you to work with in
- [x] Complete Unit & Integration Test Coverage

## Documentation
Check out [flare documentation](https://space-code.github.io/flare/documentation/flare/).
Check out the [flare documentation](https://space-code.github.io/flare/documentation/flare/).

## Requirements
- iOS 13.0+ / macOS 10.15+ / tvOS 13.0+ / watchOS 7.0+ / visionOS 1.0+
Expand Down
19 changes: 19 additions & 0 deletions Sources/Flare/Flare.docc/Articles/logging.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# logging

Learn how to log important events.

## Overview

The `Flare` supports logging out of the box. It has a set of methods to facilitate logging, each accompanied by a detailed description.

### Enabling Logging

> important: `Flare` uses the `log` package for logging functionality. See [Log Package](https://github.com/space-code/log) for more info.
By default, `Flare` logs only `debug` or `info` events based on the package building scheme. The special logging level can be forced by setting ``IFlare/logLevel`` to Flare.

```swift
Flare.shared.logLevel = .all
```

The logging can be turned off by setting ``IFlare/logLevel`` to `off`.
20 changes: 14 additions & 6 deletions Sources/Flare/Flare.docc/Articles/promotional-offers.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Learn how to use promotional offers.
First, check if the user is eligible for an introductory offer.

> tip For this purpose can be used ``IFlare/checkEligibility(productIDs:)`` method. This method requires iOS 15.0, tvOS 15.0, watchOS 8.0, macOS 12.0. Otherwise, see [Determine Eligibility](https://developer.apple.com/documentation/storekit/in-app_purchase/original_api_for_in-app_purchase/subscriptions_and_offers/implementing_introductory_offers_in_your_app#2940726).
> tip: For this purpose can be used ``IFlare/checkEligibility(productIDs:)`` method. This method requires iOS 15.0, tvOS 15.0, watchOS 8.0, macOS 12.0. Otherwise, see [Determine Eligibility](https://developer.apple.com/documentation/storekit/in-app_purchase/original_api_for_in-app_purchase/subscriptions_and_offers/implementing_introductory_offers_in_your_app#2940726).
```swift
func isEligibleForIntroductoryOffer(productID: String) async -> Bool {
Expand All @@ -29,15 +29,19 @@ Second, proceed with the purchase as usual. See [Perform Purchase](<doc:perform-

## Promotional Offers

First, you need to fetch the signature from your server. See [Generation a signature for promotional offers](https://developer.apple.com/documentation/storekit/in-app_purchase/original_api_for_in-app_purchase/subscriptions_and_offers/generating_a_signature_for_promotional_offers) for more information.
### Configuration

Second, configure ``IFlare`` with a ``Configuration``.
Configure ``IFlare`` with a ``Configuration``.

```swift
Flare.configure(configuration: Configuration(applicationUsername: "username"))
```

Third, request a signature from your server and prepare the discount offer.
### Creating & Requesting a Signature

> important: You need to fetch the signature from your server. See [Generation a signature for promotional offers](https://developer.apple.com/documentation/storekit/in-app_purchase/original_api_for_in-app_purchase/subscriptions_and_offers/generating_a_signature_for_promotional_offers) for more information.
Request a signature from your server and prepare the discount offer.

```swift
func prepareOffer(username: String, productID: String, offerID: String, completion: @escaping (PromotionalOffer.SignedData) -> Void) {
Expand All @@ -59,7 +63,9 @@ func prepareOffer(username: String, productID: String, offerID: String, completi
}
```

Fourth, complete the purchase with the promotional offer.
### Perform a Purchase with the Promotional Offer

Complete the purchase with the promotional offer.

```swift
func purchase(product: StoreProduct, discount: StoreProductDiscount, signedData: SignedData) {
Expand All @@ -79,7 +85,9 @@ func purchase(product: StoreProduct, discount: StoreProductDiscount, signedData:
}
```

Fifth, complete the transaction.
### Finish the Transaction

Complete the transaction after purchasing.

```swift
Flare.default.finish(transaction: transaction)
Expand Down
1 change: 1 addition & 0 deletions Sources/Flare/Flare.docc/Flare.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,4 @@ flare is available under the MIT license. See the LICENSE file for more info.
- <doc:restore-purchase>
- <doc:refund-purchase>
- <doc:promotional-offers>
- <doc:logging>

0 comments on commit 1f56285

Please sign in to comment.