The ReefReferral SDK allows you to implement a referral system in your app, enabling users to refer others and earn rewards. This guide will help you integrate the SDK quickly and efficiently.
Before you begin, make sure you have the following:
- Xcode installed.
- Your API key ready for configuration.
In standard mode, the ReefReferral SDK automatically handles referral and referring success events. You don't need to call triggerReferralSuccess
or triggerReferringSuccess
.
Add the ReefReferral SDK to your project by importing it at the top of your Swift file:
import ReefReferral
Initialize the ReefReferral SDK with your API key and set a delegate to handle referral events:
struct ContentView: View {
@ObservedObject private var reef = ReefReferral.shared
var body: some View {
NavigationView {
MyView {
...
}
.onAppear {
reef.start(apiKey: API_KEY, logLevel: .trace)
}
.onOpenURL { url in
reef.handleDeepLink(url: url)
}
}
}
}
in Swift UI, you can simply observe ReefReferral.shared
@ObservedObject private var reef = ReefReferral.shared
ReefReferral.shared offers referral-related information using the following properties:
referringLinkURL
: The URL of the referring user's referral link.receivedCount
: The number of referrals received by the referring user.redeemedCount
: The number of successful referrals made by the referring user.rewardEligibility
: The eligibility status for the referring user's reward.rewardURL
: The URL to claim the referring user's reward.referredStatus
: The status of the referred user.referredOfferURL
: The URL to claim the referred user's offer.
You can also implement the delegate protocol to get updates on those properties :
public protocol ReefReferralDelegate {
func referringUpdate(linkURL: URL?, received: Int, redeemed: Int, rewardEligibility: ReferringRewardStatus, rewardURL: URL?)
func referredUpdate(status: ReferredStatus, offerURL: URL?)
}
In manual mode, you need to trigger referral success events manually.
To manually trigger a referral success event, use the following method:
ReefReferral.shared.triggerReferralSuccess()
To manually trigger a referring success event, use the following method:
ReefReferral.shared.triggerReferringSuccess()
If you have any questions or need further assistance, refer to the SDK documentation or contact our support team.