iOS SDK
This page explains how to use App2App iOS SDK to use Klip on your BApp.
Prerequisites
iOS 12.0 or higher
Swift 5.0 or higher
Xcode 13.4 or higher
Environment Setup
Klip iOS SDK doesn't require a separate registration process. It works in any environment where HTTP communication is available. Still, users must have KakaoTalk installed to make the requests because the user's consent is received using the Klip application or Klip located in the More[…] tab in the mobile app KakaoTalk.
1. Download Klip SDK
Download Klip iOS SDK in Download
2. Add Klip SDK Framework
Import Klip SDK Framework and add to your project
Execute your project with Xcode
Go to Xcode > Project's TARGETS > General Tab > Frameworks, Libraries, and Embedded Content Tab and click on the + button
Select the sdk directory of Klip SDK project downloaded in Source Directory and click Next
Check if the SDK is imported to Frameworks in the Project Navigator and build.
Once the Klip SDK source is copied to your project, you can modify the library code yourself.
3. Set Info.plist
Register Allowlist for Apps
To execute applications like KakaoTalk using iOS SDK with iOS 9.0 or higher, you have to register a custom scheme in the Info.plist file.
Add an array type key LSApplicationQueriesSchemes in [Info] > [Custom iOS Target Properties], and add 'klip' and 'itms-apps' as 'Item' of that key.
4. Set Source Import
v2.1.0 or above
v2.1.0 below
API
Overview
App2App API requests are made in the order: prepare
, request
, and getResult
.
prepare
is the step in which requests (from of a total of five) are definedrequest
is the step in which the function is called and the signing takes place on KlipgetResult
is the step in which the result is returned from the function call
In addition, getCardList
is a function provided for the convenience of BApp developers that returns a list of NFTs of a Klip user.
If you need help with this document or Klip in general, please visit our Developer Forum.
KlipSDK.shared
Creates an instance to use Klip SDK.
Return Value
Type | Description |
---|---|
| Klip instance |
Example
KlipSDK.shared.prepare
KlipSDK.shared.prepare(request: KlipRequest, bappInfo: BAppInfo, completion: @escaping(KlipCallback<KlipTxResponse>) -> Void)
Prepares to process an App2App API request and issues a request key.
Request Objects
Connecting Klip(=authentication)
AuthRequest
Sending KLAY
KlayTxRequest
Sending Token
TokenTxRequest
Sending Card
CardTxRequest
Executing Contract
ContractTxRequest
Parameters
Name | Type | Description |
---|---|---|
request |
| Requested information depending on request type |
bappInfo |
| Information of the requested BApp |
callback |
| The callback function to obtain the response. If it's successful, it returns |
Requesting consent to Klip users will return the data entered in request
and bappInfo
. The request key returned in the response serves as a key when requesting transactions to users, and is used with KlipSDK.shared.getResult and KlipSDK.shared.request.
Example 1. Obtaining User Information
Example 2. Sending KLAY
Example 3. Sending Token
Example 4. Sending Card
Example 5. Execute Contract
KlipSDK.shared.request
KlipSDK.shared.request(requestKey: String), isKlipAppCall: Bool = false) -> Void
Requests authentification or signature using deep link. Under the below circumstances, it would redirect automatically to the download page of Klip or KakaoTalk on the Apple AppStore.
If the device doesn't have Klip or KakaoTalk installed
The version of the installed KakaoTalk doesn't support Klip
To implement the request step using QR code, please refer to QR Code Tutorial.
Parameters
Name | Type | Description |
---|---|---|
requestKey | String | Request Number (Obtained from Klip Server) |
isKlipAppCall | Bool | If the Klip app was called first, then it should true |
Example
KlipSDK.shared.getResult
KlipSDK.shared.getResult(requestKey: String, completion: @escaping(KlipCallback<KlipTxResponse>) -> Void)
Checks the result of an App2App API request
Parameters
Name | Type | Description |
---|---|---|
requestKey | String | Request Number (Obtained from Klip Server) |
callback |
| The callback function to obtain the response. If it's successful, it returns |
Example
KlipSDK.shared.getCardList
KlipSDK.shared.getCardList(cardAddress: String, userAddress: String, cursor: String?, completion: @escaping(KlipCallback<CardListResponse>) -> Void)
Returns a list of certain Cards of a user
Parameters
Name | Type | Description |
---|---|---|
cardAddress | String | The address of the Card to return |
userAddress | String | The address of the user to return |
cursor | String | (optional) The pointer after which the next request will retrieve the next 100 items if the number of Cards exceeds 100. |
callback |
| The callback function to obtain the response. If it's successful, it returns |
Example
Error Code
Http Status | Error Code | Description |
---|---|---|
- | - | |
500 | 10 | Error in Klip SDK (ex. HTTP c connection failure) |
500 | 21 | Error in Klip SDK (Klip REST API unsupported error code) |
500 | 22 | Error in Klip SDK (Klip protocol error) |
Last updated