Skip to content

Commit

Permalink
Update the documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
nik3212 committed Jan 22, 2024
1 parent 33804c9 commit f41fb68
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 7 deletions.
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 loggin 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 f41fb68

Please sign in to comment.