Swift SDK
SDK for iOS and macOS.
Requirements
The WinWinKit SDK is available in native Swift and supports iOS 16 and macOS 13 or later.
Installation
Swift Package Manager
You can use Swift Package Manager to add WinWinKit to your Xcode project.
Select “File” -> “Add Packages Dependencies”, enter the repository URL and click “Add Package”.
The library should be added to the Package Dependencies section and you should now be able to import WinWinKit
in your source files.
Repository URL:
Configuration
Configure the SDK with the API key and set the referral user’s App User Id.
Set the First Seen At
Recommended to set first seen at which is the date when the user was first seen in your app. This is used to evaluate user’s eligibility to claim code of another user. By default it is 7 days since the first seen at date.
If not set, the first seen at is the date the user was created in WinWinKit.
Update referral user properties
Is Premium
Update is premium property to track referring user’s stats and enable rewards activation on conversion.
Last Seen At
Tracked automatically by the SDK. To disable auto tracking, set the shouldAutoUpdateLastSeenAt
property to false
before setting the appUserId
property.
Metadata
Optionally set metadata to save user’s additional properties.
Referral user
Referral user object contains all necessary information needed to display in the user interface.
Access the latest referral user object.
Also available as a property of
ReferralUserObservableObject
(see below).
Claim code
Claim code object contains all necessary information needed to claim a code.
Access the latest claim code object.
Another way to claim code is to call the
claim
method ofReferralClaimCodeObservableObject
.
Delegate
Set a delegate to receive events from the SDK.
Setting the delegate is optional when using observable objects described below.
Observable objects for SwiftUI
The SDK provides convenient Observable
objects to observe changes to the referral user and claim code.
ReferralUserObservableObject
Provides observable ReferralUser
and isRefreshing
properties.
ReferralClaimCodeObservableObject
Provides observable isClaimingCode
, didClaimCodeSuccessfully
, grantedRewards
properties and claim(code:)
method.
In SwiftUI only apps it is possible to build complete integration with only these observable objects.
User Interface
The SDKs provide interface for interacting with WinWinKit APIs, but not the UI.
Thus you need to build the user interface for the referral feature in your app.
We plan to provide UI with the SDK in the future. Please let us know if that is your requirement to get started.