conichiSDK for iOS
元数据
- 联系人: @David-Henner
- 联系人: @ShengHuaWu
- 联系人: @vincentjacquesson
概览
conichiSDK
for iOS 是一个允许用户通过蓝牙低能耗(BLE)在信标周围被识别的工具。作为一项软件即服务(SaaS)解决方案,conichi 的功能专注于个性化客户识别、快速登记、启用移动支付(从而结账)、识别个人偏好、奖励忠诚度。
工具集
conichiSDK
遵从将功能分割成不同模块(所谓的kit
)的思想,目前有6个模块可供使用。
- CNISDKCoreKit - 提供信标识别、简单的登记/退房,以及访客个性化
- CNISDKPaymentKit - 提供支付工具管理的抽象层,带有支付功能的结账请求
- CNISDKPaylevenKit - 提供通过Payleven进行支付的抽象层
- CNISDKSumUpKit - 提供通过SumUp进行支付的抽象层
- CNISDKGeoFencingKit - 提供通过Apple geofencing追踪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()
访问。
授权
要启动任何与访客的真实操作,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,而不是使用电子邮件
和密码
组合,并通过使用以下代码进行注册:- (void)signUpWithExternalIDRequestInfo:(CNISDKExternalSignUpRequestInfo *)requestInfo completion:(nullable CNISDKGuestErrorBlock)completion;
监控
如果访客获得授权,以下代码将启用信标监控。
Objective-C
[[CNISDK sharedInstance] startMonitoring];
Swift
CNISDK.sharedInstance().startMonitoring()
现在,当访客进入conichi信标的范围内时,应该触发以下回调
- (void)conichiSDKDidDiscoverVenue:(CNISDKVenue *)venue;
根据不同场景,可能会调用不同的回调。所有回调都可以在CNISDKDelegate.h
中找到。
Trackins
访客可以在进入场所的蓝牙信标区域时创建Trackins。可以使用Web API检索Trackins。
商家应用可以使用Trackins显示蓝牙信标区域周围的用户列表。
以下代码展示了在发现场所后如何启动Trackins。
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集成自动创建。
Checkout requests
Checkout requests允许客人请求关闭Checkins(退房)。它们可以创建带有或没有可交付物品(如迷你吧用品等需支付的物品)。
与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.