CNISDKSumUpKit 4.1.37

CNISDKSumUpKit 4.1.37

测试已测试
语言语言 Obj-CObjective C
许可证 NOASSERTION
发布最后发布2019年4月

David HennerShengHua Wuconichi iOS 开发团队Vincent JacquessonJoseph Tseng维护。



 
依赖于
CNISDKCoreKit= 4.1.37
CNISDKPaymentKit= 4.1.37
 

  • conichiGMBH

conichiSDK for iOS

Requires Carthage compatible CocoaPods Compatible Build Status

元数据

概述

conichiSDK for iOS是一个工具,通过蓝牙低功耗(BLE)允许用户在Beacon范围内被识别。作为一种软件即服务(SaaS)解决方案,conichi的功能主要集中在个性化的访客识别、加速登记、支持移动支付(从而完成结算)、识别个人喜好以及奖励忠诚度。

套件

conichiSDK 遵循将功能分为不同模块(称为 kit)的理念,目前有 6 个模块可供使用。

入门指南

安装

作为框架安装

要使用 Conichi SDK,请前往 发行版页面,下载 Frameworks.zip。解压缩 zip 文件,然后将所有框架拖放到 项目目标 -> 普通 -> 嵌入的二进制文件中。

Alt text

通过 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 - 打开开关.

Alt text

初始化

以下示例显示了指向我们开发服务器的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,而不是使用emailpassword组合,并通过以下方式使用- (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 可以由访客在进入指定场所的beacon区域时创建。可以使用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集成自动创建。

退房请求

退房请求允许客人请求关闭(退房)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.