conichiSDK for iOS
元数据
- 负责人: @David-Henner
- 负责人: @ShengHuaWu
- 负责人: @vincentjacquesson
概述
适用于 iOS 的 conichiSDK
是一种通过蓝牙低功耗 (BLE) 让用户在信标周围被识别的工具。作为软件即服务 (SaaS) 解决方案运营,conichi 的功能侧重于个人客户识别、快速办理入住、启用移动支付(因此结账)、识别个人偏好、奖励忠诚度。
套件
conichiSDK
采用将功能划分为不同模块(称为 kit
)的理念,目前共有 6 个模块可用。
- CNISDKCoreKit - 提供信标识别、简单的签到/签退以及客人个性化
- CNISDKPaymentKit - 提供对支付工具进行管理的抽象层,支持带支付功能的结账请求
- CNISDKPaylevenKit - 提供通过 Payleven 管理支付的抽象层
- CNISDKSumUpKit - 提供通过 SumUp 管理支付的抽象层
- CNISDKGeoFencingKit - 提供通过 Apple 地区围栏进行 conichi 场地跟踪
- 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
之后,您需要将 NSLocation
键添加到项目中的 Info.plist,并包含要向用户显示的消息。
<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()
。
授权
要开始对访客进行任何实际操作,则需要访客进行授权。所有与授权
相关的功能都在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,而不是使用电子邮件和密码组合,并使用以下方式执行注册操作:- (void)signUpWithExternalIDRequestInfo:(CNISDKExternalSignUpRequestInfo *)requestInfo completion:(nullable CNISDKGuestErrorBlock)completion;
监控
如果访客已授权,以下代码将启用信标监控
Objective-C
[[CNISDK sharedInstance] startMonitoring];
Swift
ConiSDK.sharedInstance().startMonitoring()
现在,当访客进入Conichi信标的范围时,以下回调应该被触发
- (void)conichiSDKDidDiscoverVenue:(CNISDKVenue *)venue;
根据不同场景,可能会调用不同的回调。所有回调都可以在CNISDKDelegate.h
中找到。
追踪
访客在指定场地到达信标区域时会创建追踪。可以通过Web API检索追踪。
商户应用可以使用追踪在信标区域周围显示用户列表。
以下代码演示了在发现场地后如何启动追踪
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
}
}
}
签到
签到与场地相关联。它们允许用户执行与场地相关的不同操作,例如支付或从场地接收消息。签到可以通过Web API手动创建,或通过PMS集成自动创建。
结账请求
结账请求允许访客请求完成他们的签到(结账)。它们可以包含或不含可交付物品(如迷你吧物品等需支付的物品)。
与签到一样,结账与场地相关联。它们可以使用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
最近版本的更新内容,请查看 CHANGELOG。
许可证
Copyright (c) 2016-present, сonichi GmbH.
All rights reserved.