Skip to content

Commit

Permalink
Merge pull request #204 from superwall/develop
Browse files Browse the repository at this point in the history
3.6.0
  • Loading branch information
yusuftor committed Apr 5, 2024
2 parents 63fb263 + fe532a1 commit a8c914b
Show file tree
Hide file tree
Showing 46 changed files with 1,018 additions and 454 deletions.
17 changes: 15 additions & 2 deletions CHANGELOG.md
@@ -1,6 +1,19 @@
# CHANGELOG

The changelog for `SuperwallKit`. Also see the [releases](https://github.com/superwall-me/Superwall-iOS/releases) on GitHub.
The changelog for `SuperwallKit`. Also see the [releases](https://github.com/superwall/Superwall-iOS/releases) on GitHub.

## 3.6.0

### Enhancements

- Adds support for unlimited products in a paywall.
- SW-2767: Adds `device.regionCode` and `device.preferredRegionCode`, which returns the `regionCode` of the locale. For example, if a locale is `en_GB`, the `regionCode` will be `GB`. You can use this in the filters of your campaign.
- Adds ability to specify custom API endpoints using `SuperwallOptions` to facilitate local testing more easily.

### Fixes

- Calls the completion block even if Superwall.configure is called more than once.
- `getPresentationResult` now confirms assignments for holdouts.

## 3.5.0

Expand All @@ -24,7 +37,7 @@ This is our first visionOS pre-release, we'll test this on a few devices to
ensure everything works as expected!

### Enhancements

- Adds support for visionOS!

## 3.4.8
Expand Down
2 changes: 1 addition & 1 deletion Examples/SwiftUI/README.md
Expand Up @@ -24,7 +24,7 @@ This example app uses:

## Getting Started

Clone or download the SuperwallKit from the [project home page](https://github.com/superwall-me/Superwall-iOS). Then, open **Superwall-SwiftUI.xcodeproj** in Xcode and take a look at the code inside the [Superwall-SwiftUI](Superwall-SwiftUI) folder.
Clone or download the SuperwallKit from the [project home page](https://github.com/superwall/Superwall-iOS). Then, open **Superwall-SwiftUI.xcodeproj** in Xcode and take a look at the code inside the [Superwall-SwiftUI](Superwall-SwiftUI) folder.

You'll see a few folders relating to the design and components used in the app, which you don't need to worry about. [SuperwallSwiftUIExampleApp.swift](Superwall-SwiftUI/SuperwallSwiftUIExampleApp.swift) handles the setup of the Superwall SDK and is used to control which views show, depending on whether the user has logged in or not. If you're not logged in, [WelcomeView.swift](Superwall-SwiftUI/WelcomeView.swift) shows. Otherwise, [HomeView.swift](Superwall-SwiftUI/HomeView.swift) shows. This view handles the presentation of a paywall.

Expand Down
2 changes: 1 addition & 1 deletion Examples/UIKit+RevenueCat/README.md
Expand Up @@ -25,7 +25,7 @@ This example app uses:

## Getting Started

Clone or download SuperwallKit from the [project home page](https://github.com/superwall-me/Superwall-iOS). Then, open **Superwall-UIKit+RevenueCat.xcodeproj** in Xcode and take a look at the code inside the [Superwall-UIKit+RevenueCat](Superwall-UIKit+RevenueCat) folder.
Clone or download SuperwallKit from the [project home page](https://github.com/superwall/Superwall-iOS). Then, open **Superwall-UIKit+RevenueCat.xcodeproj** in Xcode and take a look at the code inside the [Superwall-UIKit+RevenueCat](Superwall-UIKit+RevenueCat) folder.

You'll see a file called [RCPurchaseController.swift](Superwall-UIKit+RevenueCat/RCPurchaseController.swift) which handles the subscription-related logic of both Superwall and RevenueCat.

Expand Down
2 changes: 1 addition & 1 deletion Examples/UIKit-Swift/README.md
Expand Up @@ -24,7 +24,7 @@ This example app uses:

## Getting Started

Clone or download SuperwallKit from the [project home page](https://github.com/superwall-me/Superwall-iOS). Then, open **Superwall-UIKit-Swift.xcodeproj** in Xcode and take a look at the code inside the [Superwall-UIKit-Swift](Superwall-UIKit-Swift) folder.
Clone or download SuperwallKit from the [project home page](https://github.com/superwall/Superwall-iOS). Then, open **Superwall-UIKit-Swift.xcodeproj** in Xcode and take a look at the code inside the [Superwall-UIKit-Swift](Superwall-UIKit-Swift) folder.

You'll see a few folders relating to the design and components used in the app, which you don't need to worry about.

Expand Down
Expand Up @@ -5,9 +5,9 @@
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.945",
"green" : "0.988",
"red" : "0.604"
"blue" : "0xF0",
"green" : "0xFB",
"red" : "0x9A"
}
},
"idiom" : "universal"
Expand Down
8 changes: 4 additions & 4 deletions README.md
Expand Up @@ -15,14 +15,14 @@
<a href="https://superwall.com/">
<img src="https://img.shields.io/badge/ios%20version-%3E%3D%2013.0-blueviolet" alt="iOS Versions Supported">
</a>
<a href="https://github.com/superwall-me/Superwall-iOS/blob/master/LICENSE">
<a href="https://github.com/superwall/Superwall-iOS/blob/master/LICENSE">
<img src="https://img.shields.io/badge/license-MIT-green/" alt="MIT License">
</a>
<a href="https://superwall.com/">
<img src="https://img.shields.io/badge/community-active-9cf" alt="Community Active">
</a>
<a href="https://superwall.com/">
<img src="https://img.shields.io/github/v/tag/superwall-me/Superwall-iOS" alt="Version Number">
<img src="https://img.shields.io/github/v/tag/superwall/Superwall-iOS" alt="Version Number">
</a>
</p>

Expand All @@ -48,7 +48,7 @@
✏️ | A/B Testing - automatically calculate metrics for different paywalls
📝 | [Online documentation](https://docs.superwall.com/docs) up to date
🔀 | [Integrations](https://docs.superwall.com/docs) - over a dozen integrations to easily send conversion data where you need it
💯 | Well maintained - [frequent releases](https://github.com/superwall-me/Superwall-iOS/releases)
💯 | Well maintained - [frequent releases](https://github.com/superwall/Superwall-iOS/releases)
📮 | Great support - email a founder: jake@superwall.com

## Installation
Expand All @@ -58,7 +58,7 @@
The preferred installation method is with [Swift Package Manager](https://swift.org/package-manager/). This is a tool for automating the distribution of Swift code and is integrated into the swift compiler. In Xcode, do the following:

- Select **File ▸ Add Packages...**
- Search for `https://github.com/superwall-me/Superwall-iOS` in the search bar.
- Search for `https://github.com/superwall/Superwall-iOS` in the search bar.
- Set the **Dependency Rule** to **Up to Next Major Version** with the lower bound set to **3.0.0**.
- Make sure your project name is selected in **Add to Project**.
- Then, **Add Package**.
Expand Down
Expand Up @@ -58,7 +58,10 @@ extension Superwall {
disableVerboseEvents: verboseEvents,
isSandbox: dependencyContainer.makeIsSandbox()
) {
await dependencyContainer.eventsQueue.enqueue(event: eventData.jsonData)
await dependencyContainer.eventsQueue.enqueue(
data: eventData.jsonData,
from: event
)
}
dependencyContainer.storage.coreDataManager.saveEventData(eventData)

Expand Down
10 changes: 8 additions & 2 deletions Sources/SuperwallKit/Analytics/SessionEventsQueue.swift
@@ -1,6 +1,6 @@
//
// File.swift
//
//
//
// Created by Yusuf Tör on 06/05/2022.
//
Expand Down Expand Up @@ -64,7 +64,13 @@ actor SessionEventsQueue: SessionEnqueuable {
}

private func setupTimer() {
let timeInterval = configManager.options.networkEnvironment == .release ? 20.0 : 1.0
let timeInterval: Double
switch configManager.options.networkEnvironment {
case .release:
timeInterval = 20.0
default:
timeInterval = 1.0
}
let timer = Timer(
timeInterval: timeInterval,
repeats: true
Expand Down
52 changes: 48 additions & 4 deletions Sources/SuperwallKit/Config/Options/SuperwallOptions.swift
@@ -1,6 +1,6 @@
//
// File.swift
//
//
//
// Created by Yusuf Tör on 11/07/2022.
//
Expand All @@ -20,13 +20,39 @@ public final class SuperwallOptions: NSObject {
/// **WARNING**: The different network environments that the SDK should use.
/// Only use this enum to set ``SuperwallOptions/networkEnvironment-swift.property``
/// if told so explicitly by the Superwall team.
public enum NetworkEnvironment: Int {
public enum NetworkEnvironment {
/// Default: Uses the standard latest environment.
case release
/// **WARNING**: Uses a release candidate environment. This is not meant for a production environment.
case releaseCandidate
/// **WARNING**: Uses the nightly build environment. This is not meant for a production environment.
case developer
/// **WARNING**: Uses a custom environment. This is not meant for a production environment.
case custom(String)

var scheme: String {
switch self {
case .custom(let domain):
if let url = URL(string: domain) {
return url.scheme ?? "https"
}
default:
return "https"
}
return "https"
}

var port: Int? {
switch self {
case .custom(let domain):
if let url = URL(string: domain) {
return url.port
}
default:
return nil
}
return nil
}

var hostDomain: String {
switch self {
Expand All @@ -36,15 +62,33 @@ public final class SuperwallOptions: NSObject {
return "superwallcanary.com"
case .developer:
return "superwall.dev"
case .custom(let domain):
if let url = URL(string: domain) {
if let host = url.host {
return host
}
}
return domain
}
}

var baseHost: String {
"api.\(hostDomain)"
switch self {
case .custom:

return hostDomain
default:
return "api.\(hostDomain)"
}
}

var collectorHost: String {
return "collector.\(hostDomain)"
switch self {
case .custom:
return hostDomain
default:
return "collector.\(hostDomain)"
}
}
}

Expand Down
10 changes: 7 additions & 3 deletions Sources/SuperwallKit/Dependencies/DependencyContainer.swift
@@ -1,6 +1,6 @@
//
// File.swift
//
//
//
// Created by Yusuf Tör on 23/12/2022.
//
Expand Down Expand Up @@ -248,7 +248,7 @@ extension DependencyContainer: ViewControllerFactory {

extension DependencyContainer: VariablesFactory {
func makeJsonVariables(
productVariables: [ProductVariable]?,
products: [ProductVariable]?,
computedPropertyRequests: [ComputedPropertyRequest],
event: EventData?
) async -> JSON {
Expand All @@ -258,7 +258,7 @@ extension DependencyContainer: VariablesFactory {
)

return Variables(
productVariables: productVariables,
products: products,
params: event?.parameters,
userAttributes: identityManager.userAttributes,
templateDeviceDictionary: templateDeviceDict
Expand Down Expand Up @@ -349,6 +349,10 @@ extension DependencyContainer: ApiFactory {

return headers
}

func makeDefaultComponents(host: EndpointHost) -> ApiHostConfig {
return self.api.getConfig(host: host)
}
}

// MARK: - Rule Params
Expand Down
8 changes: 7 additions & 1 deletion Sources/SuperwallKit/Dependencies/FactoryProtocols.swift
Expand Up @@ -27,7 +27,7 @@ protocol CacheFactory: AnyObject {

protocol VariablesFactory: AnyObject {
func makeJsonVariables(
productVariables: [ProductVariable]?,
products: [ProductVariable]?,
computedPropertyRequests: [ComputedPropertyRequest],
event: EventData?
) async -> JSON
Expand Down Expand Up @@ -99,6 +99,8 @@ protocol HasExternalPurchaseControllerFactory: AnyObject {
func makeHasExternalPurchaseController() -> Bool
}

struct DummyDecodable: Decodable {}

protocol ApiFactory: AnyObject {
// TODO: Think of an alternative way such that we don't need to do this:
// swiftlint:disable implicitly_unwrapped_optional
Expand All @@ -114,6 +116,10 @@ protocol ApiFactory: AnyObject {
isForDebugging: Bool,
requestId: String
) async -> [String: String]

func makeDefaultComponents(
host: EndpointHost
) -> ApiHostConfig
}

protocol StoreTransactionFactory: AnyObject {
Expand Down
2 changes: 1 addition & 1 deletion Sources/SuperwallKit/Misc/Constants.swift
Expand Up @@ -18,5 +18,5 @@ let sdkVersion = """
*/

let sdkVersion = """
3.5.0
3.6.0
"""
17 changes: 17 additions & 0 deletions Sources/SuperwallKit/Misc/ThrowableDecodable.swift
Expand Up @@ -7,6 +7,23 @@

import Foundation


/// A generic struct for error-tolerant decoding.
///
/// It allows each element in a collection to be decoded independently, enabling the
/// handling of decoding errors on a per-element basis. This is useful for decoding
/// arrays of objects where some objects might be malformed or incomplete.
///
/// Example:
///
/// ```
/// let appStoreProductItems = try values.decodeIfPresent(
/// [Throwable<ProductItem>].self,
/// forKey: .productItems
/// ) ?? []
/// productItems = appStoreProductItems.compactMap { try? $0.result.get() }
/// ```
/// This gets the product items whose decoding doesn't fail.
struct Throwable<T: Decodable>: Decodable {
let result: Result<T, Error>

Expand Down

0 comments on commit a8c914b

Please sign in to comment.