此 NimbleLoyalty SDK 库允许开发者轻松地将忠诚度计划集成到他们的 iOS 应用程序中。
iOS Loyalty SDK 可以使用 CocoaPods 或 Swift Package Manager 安装。
要使用 CocoaPods 安装,请将以下行添加到您的 Podfile
pod 'NimbleLoyalty', '~> 0.1.0'
要使用 Swift Package Manager 安装,请将以下行添加到您的依赖项
.package(url: "https://github.com/nimblehq/business-loyalty-ios-sdk-poc.git", from: "0.1.0")
在验证用户身份之前,请务必设置 clientId 和 clientSecret。
NimbleLoyalty.shared.setClientId("CLIENT_ID")
NimbleLoyalty.shared.setClientSecret("CLIENT_SECRET")
检查用户是否已通过身份验证。
if NimbleLoyalty.shared.isAuthenticated() {
// The user is authenticated, do something
} else {
// The user is not authenticated, show a login button
}
启动身份验证流程。
NimbleLoyalty.shared.authenticate { result in
switch result {
case .success:
// The user is authenticated, do something
case .failure(let error):
print("Error authenticating: \(error.localizedDescription)")
}
}
移除会话,有效地注销用户。
// Clear the user's session
NimbleLoyalty.shared.clearSession()
检索已验证用户的可用奖励列表。
NimbleLoyalty.shared.getRewardList { result in
switch result {
case .success(let rewardList):
// Display the list of rewards to the user
for reward in rewardList.rewards {
print("Reward name: \(reward.name)")
}
case .failure(let error):
print("Error retrieving rewards: \(error.localizedDescription)")
}
}
检索特定奖励的详细信息。
NimbleLoyalty.shared.getRewardDetail(code: "reward_id") { result in
switch result {
case .success(let rewardDetail):
// Display the reward detail to the user
case .failure(let error):
print("Error retrieving reward detail: \(error.localizedDescription)")
}
}
使用给定的奖励代码为已验证用户兑换奖励。
NimbleLoyalty.shared.redeemReward(code: "ABC123") { result in
switch result {
case .success(let rewardList):
print("Reward redeemed with ID: \(redeemReward.id)")
case .failure(let error):
print("Error redeeming reward: \(error.localizedDescription)")
}
}
检索已验证用户的奖励历史记录。
NimbleLoyalty.shared.getRewardHistory { result in
switch result {
case .success(let rewardHistory):
// Display the reward history to the user
for reward in rewardHistory {
print("Reward name: \(reward.name)")
}
case .failure(let error):
print("Error retrieving reward history: \(error.localizedDescription)")
}
}
检索已验证用户的可用产品列表。
NimbleLoyalty.shared.getProductList { result in
switch result {
case .success(let products):
// Display the list of products to the user
for product in products {
print("Product name: \(product.name)")
}
case .failure(let error):
print("Error retrieving products: \(error.localizedDescription)")
}
}
检索特定产品的详细信息。
NimbleLoyalty.shared.getProductDetail(id: "product_id") { result in
switch result {
case .success(let productDetail):
// Display the reward detail to the user
case .failure(let error):
print("Error retrieving reward detail: \(error.localizedDescription)")
}
}
bundle installbundle exec arkanabundle exec pod install。
此项目由 Nimble 维护和资助。
此项目版权归 Nimble 所有,始于 2023 年。它是自由软件,可以根据 LICENSE 文件中指定的条款进行重新分发。