Shinara is a mobile-first social referral platform tailored for in-app purchases, empowering brands to grow through influencer-driven advocacy. The Swift SDK enables seamless integration of Shinara's referral and attribution system into your iOS applications.
ShinaraSDK.instance.initialize(apiKey: "<YOUR_API_KEY>") { result in
switch result {
case .success:
print("Shinara SDK initialized successfully")
case .failure(let error):
print("Shinara SDK initialization failed")
}
}
return true
}
}
Referral Code Validation
To validate a referral code, use the validateReferralCode method. This method checks the validity of the given code.
Note: Ensure that the referral code is validated before initiating an In-App Purchase. This is crucial for proper attribution of the purchase to the referral code in the Shinara SDK.
ShinaraSDK.instance.validateReferralCode(code: referralCode) { result in
switch result {
case .success(let programId):
// Valid referral code
// programId can be used to map and apply discounts
print("Valid referral code with program ID: \(programId)")
To attribute a purchase made by affiliates, use the attributePurchase method. Call this method after a successful in app purchase.
let productId: String = transaction.payment.productIdentifier // in app purchase product from storekit transaction
let transactionId: String = transaction.transactionIdentifier ?? "" // in app purchase transaction id from storekit transaction
ShinaraSDK.instance.attributePurchase(productId: productId, transactionId: transactionId) { result in
switch result {
case .success(_):
// handle success
case .failure(let error):
// handle error
}
}
User Registration (Optional)
By default, Shinara generates a new user id and attribute to the purchase. Optionally, you can provide your own userId and other user details to make sure attribution of the purchase has the user id of your choice.
Note: Ensure that the referral code is validated before registering a user. This is crucial for proper attribution of the user to the referral code in the Shinara SDK.