conichiSDK for iOS
元数据
- 联系人: @David-Henner
- 联系人: @ShengHuaWu
- 联系人: @vincentjacquesson
概述
conichiSDK
for iOS是一个允许用户通过蓝牙低能耗(BLE)在信标周围被识别的工具。作为一个软件即服务(SaaS)解决方案,conichi的功能专注于个人访客识别、快速签到、启用移动支付(从而结账)、识别个人偏好和奖励忠诚度。
工具集
康尼奇 SDK(conichiSDK)遵循将功能拆分为不同模块(所谓 kit
)的思想,目前有 6 个模块可用。
- CNISDKCoreKit - 提供信标识别、简单登记/退宿和访客定制
- CNISDKPaymentKit - 提供管理支付工具的抽象层,带支付功能的登记/退宿请求
- CNISDKPaylevenKit - 提供通过 Payleven 管理支付的抽象层
- CNISDKSumUpKit - 提供通过 SumUp 管理支付的抽象层
- CNISDKGeoFencingKit - 提供康尼奇场所跟踪的 Apple 地理围栏功能
- CNISDKPMSKit - 提供与物业管理系统集成时的移动登记/退宿
入门
安装
通过 CocoaPods 安装
通过 CocoaPods
集成 CNISDKCoreKit
是首选方法。将以下行添加到您的 Podfile
source '[email protected]:CocoaPods/Specs.git'
use_frameworks!
target 'your_tagret' do
pod 'CNISDKCoreKit'
end
运行 pod install
,现在您应该有最新的 CNISDKCoreKit
发布版。
通过 Carthage 安装
要通过 Carthage 集成 CNISDKCoreKit
,请将以下行添加到您的 Cartfile
github "conichiGMBH/conichi-ios-sdk"
运行 carthage update
,现在应该已在您的 Carthage 文件夹中获得最新的 CNISDKCoreKit
版本。
部分安装
以下链接提供了如何安装特定 kit
的说明,参考 入门 部分以下链接
更新 info.plist
然后,您必须向项目中的 Info.plist 添加 NSLocation
键,其中包含提示用户的消息。
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>This app needs your location so you can be recognized in conichi Hotels</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>This app needs your location so you can be recognized in conichi Hotels</string>
<key>NSLocationUsageDescription</key>
<string>This app needs your location so you can be recognized in conichi Hotels</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>This app needs your location so you can be recognized in conichi Hotels</string>
请注意,如果您决定不对所有这些键进行操作,则应用程序可能无法正常运行。如果您想知道为什么这些键是必要的,您可以查看 此链接
如果您将使用我们对开发或测试环境的,您需要在 info.plist 中添加以下行
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
启用一些功能
Conichi非常关注安全性,因此SDK将授权信息存储在iOS Keychain中,但要能够即使SDK未运行也能读取和写入值,iOS系统要求 دارد Keychain Sharing
功能。
目标 -> 功能 -> Keychain Sharing - 打开开关
.
初始化
以下示例显示了为指向我们的 开发
服务器创建的 conichiSDK CoreKit
的最简单设置。
Objective-C
//Create a configuration for the sdk instance
CNISDKConfiguration *configuration = [CNISDKConfiguration configurationWithBlock:^(id<CNISDKMutableConfiguration> \_Nonnull mutableConfiguration) {
mutableConfiguration.logLevel = CNISDKLogLevelInfo;
mutableConfiguration.apiKey = @"your-api-key";
mutableConfiguration.apiSecret = @"your-api-secret";
mutableConfiguration.kits = @[ ];
mutableConfiguration.environment = CNISDKEnvironmentDevelopment;
}];
//Setups the sdk delegate - it can be any object that conforms to CNISDKDelegate protocol
id<CNISDKDelegate> delegate = [self yourMethodToSetupSDKDelegate];
//Start the sdk with the given configuration
[CNISDK startWithConfiguration:configuration delegate:delegate];
Swift
//Create configuration for the sdk instance
let config: CNISDKConfiguration = CNISDKConfiguration() {
(mutableConfig: CNISDKMutableConfiguration) in
mutableConfig.logLevel = CNISDKLogLevel.info
mutableConfig.apiKey = "your-api-key"
mutableConfig.apiSecret = "your-api-secret"
mutableConfig.kits = []
mutableConfig.environment = CNISDKEnvironment.development
}
//Setups the sdk delegate - make sure that you conform to the CNISDKDelegate protocol
let delegate: CNISDKDelegate = self
//Start the sdk with given configuration
CNISDK.start(with: config, delegate: delegate)
完成此设置后,您可以在..Obj-C中使用 [CNISDK sharedInstance]
实例或在..Swift中使用 CNISDK.sharedInstance()
。
授权
要开始与访客进行任何实际操作,=sdk 需要访客
进行授权。所有与 授权
相关的方法都在=CNISDKAPIManager+Authentication 类别中。以下示例显示了如何为新访客进行注册。
Objective-C
//Create a sign up request
CNISDKSignUpRequestInfo *info = [[CNISDKSignUpRequestInfo alloc] init];
info.firstName = @"Jenessa";
info.lastName = @"Gretta";
info.email = @"[email protected]";
info.password = @"strongestpasswordever=)";
//Perform sign up
[CNISDKAPIManager manager] signUpWithRequest:info completion:^(CNISDKGuest *guest, NSError *error){
if (error) {
//handle error during the sign up
}
else {
//handle authorized guest
}
}];
Swift
// Create a signup request
let info = CNISDKSignUpRequestInfo()
info.firstName = "Jenessa"
info.lastName = "Gretta"
info.email = "[email protected]"
info.password = "strongestpasswordever=)"
// Instantiate APImanager
let apiManager = CNISDKAPIManager()
// Perform signup
apiManager.signUp(withRequest: info) {
(guest, error) in
if let error = error {
//handle error during the sign up
return
}
//handle authorized guest
}
您还可以使用 CNISDKExternalSignUpRequestInfo
对象提供外部 ID 而不是使用 email
和 password
组合,并通过使用以下命令执行注册:- (void)signUpWithExternalIDRequestInfo:(CNISDKExternalSignUpRequestInfo *)requestInfo completion:(nullable CNISDKGuestErrorBlock)completion;
监控系统
如果 Guest 获得了授权,以下是启用信标监控的代码
Objective-C
[[CNISDK sharedInstance] startMonitoring];
Swift
CNISDK.sharedInstance().startMonitoring()
现在,当 Guest 进入 conichi 信标的范围时,应该触发以下回调
- (void)conichiSDKDidDiscoverVenue:(CNISDKVenue *)venue;
根据场景的不同,可以调用不同的回调。所有回调都可以在 CNISDKDelegate.h
中找到
Trackins
当游客进入特定场所的 beacon 区域时,可以创建 Trackins。可以使用 Web API 来获取 Trackins。
商户应用可以使用 Trackins 在 beacon 区域周围显示用户列表。
以下代码演示了在场所被发现后如何启动一个 Trackin。
Objective-C
- (void)conichiSDKDidDiscoverVenue:(CNISDKVenue *)venue {
// Get the region ID
NSString *regionID = venue.regions.firstObject.conichiID;
// Start tracking guest in region
[[CNISDKAPIManager manager] startTrackingGuestInRegionWithID:regionID completion:^(id trackin, NSError *error) {
if error {
// Handle error
} else {
// Do something with trackin
}
}];
}
Swift
func conichiSDKDidDiscover(_ venue: CNISDKVenue) {
// Get the region ID
guard let regionID = currentVenue?.regions?.first?.conichiID else {
return
}
// Instantiate API Manager if needed
let apiManager = CNISDKAPIManager()
// Start tracking guest in region
apiManager.startTrackingGuestInRegion(withID: regionID) { (trackin, error) in
if let unwrappedError = error {
// Handle error
} else {
// Do something with trackin
}
}
}
Checkins
Checkins 与场所相关联。它们允许用户执行与场所相关的不同操作,例如付款或接收场所的消息。可以使用 Web API 手动创建 Checkins,或通过 PMS 集成自动创建。
结账请求
结账请求允许游客请求关闭 Checkin(结账)。它们可以创建时带或不带可交付的物品(如迷你吧物品等)。
与 Checkins 类似,它们也与场所相关联。可以使用 SDK 创建并使用 Web API 获取。
以下示例展示了如何使用 CNISDKCoreKit
为游客进行无可交付物品的结账请求:
Objective-C
// Get the guest's credit card
CNISDKCreditCard *creditCard = guest.creditCards.firstObject;
// Create checkout request
[[CNISDKAPIManager manager] createCheckoutRequestWithDeliverableCountableItems:nil selectedCreditCard:creditCard completion:^(id checkoutRequest, NSError *error) {
if (error) {
// Handle error
} else {
// Do something with checkoutRequest
}
}];
Swift
// Get the guest's credit card
let creditCard = guest.creditCards.first
// Instantiate API Manager if needed
let apiManager = CNISDKAPIManager()
// Create checkout request
apiManager.createCheckoutRequest(with: nil, selectedCreditCard: creditCard.conichiID ) { (checkoutRequest, error) in
if error {
// Handle error
} else {
// Do something with checkoutRequest
}
}
获取游客状态
您可以使用以下代码从 conichi 的云端获取游客信息。
Objective-C
// Fetch guest status
[[CNISDK sharedInstance] fetchGuestStatus];
// Implement delegate method of CNISDKDelegate
- (void)conichiSDKDidUpdateGuestStatus:(CNISDKGuest *)guest {
// do something with guest
}
Swift
// Fetch guest status
CNISDK.sharedInstance().fetchGuestStatus()
// Implement delegate method of CNISDKDelegate
func conichiSDKDidUpdateGuestStatus(_ guest: CNISDKGuest) {
// do something with guest
}
注意
尽管上述文档应该足以帮助您入门,但它仅涵盖了 SDK 功能性的一部分。如果您对该使用有任何疑问,请随时联系我们。
文档
每个套件的文档可以在以下链接找到
有关推送通知集成的文档可以在此处找到
版本历史
要查看conichiSDK
最近版本的变化,请参阅版本历史。
许可
Copyright (c) 2016-present, сonichi GmbH.
All rights reserved.