# iOS

### 简介

GitHub仓库: [**TP iOS SDK**](https://github.com/TP-Lab/Mobile-SDK/tree/master/iOS%20SDK)

*`MiniWallet`*&#x53EF;以实现对于特定操作，第三方App不需要拉起钱包，直接在应用内部完成，体验更为流畅。

### 初始化

```
[TPApi registerAppID:@"tpsdk"];
[TPApi setSeed:@"xxxx" error:nil];
[TPApi setBlockChain:TPBlockChainTypeEOSMainNet nodeUrl:@"http://eosinfo.mytokenpocket.vip" plugNodeUrl:@"http://eosinfo.mytokenpocket.vip"];
```

### Auth

```
TPAuthObj *auth = [TPAuthObj new];
auth.dappName = @"xxx";
auth.dappIcon = @"https:.../xx.png";
auth.account = "xxxx";
auth.perm = "xxxx";
auth.selectAll = NO;
auth.actions = [linkActions];
[TPApi sendObj:auth resultHandle:^(TPReqType type,NSError *error) {
    // ...        
}];


/// Response ↓
TPRespObj.data
{
    ...,
    "ref" : "TokenPocket",
    "publickey" : "EOS5AvWThdghtNngWP4UcNi9DL6kF7Mnv2ccO",
    "sign" : "SIG_K1_JyCJtV9vqwxtyEt68UhUibkg1CmRjxtG6zkZwE...",
    "timestamp" : "1554266633",
}
```

### 发起交易

* 构建数据，将操作的*action*中的*permission*字段值替换成调用auth传递的perm字段。
* 调&#x7528;*`TPApi perm:(NSString *)perm isLinkActions:(NSArray<TPLinkAction *> *)actions account:(NSString *)account completion:(void (^)(BOOL permExisted,BOOL linked,NSError *error))completion`*&#x68C0;查action绑定状态。
* 如果第二步绑定成功，则直接调用'Auth'。
* 如果第二步绑定失败，则需要开发者将permission字段替换成active或者owner,以便拉起钱包执行操作。

### 方法说明

#### **修改***`seed`*

```
+ (void)resetSeed:(NSString *)seed newSeed:(NSString *)newSeed error:(NSError **)error;
```

#### **获取已授权账号信息**

```
+ (NSArray<NSString *> *)getAccounts;
```

#### **检查权限是否存在**

```
+ (void)isPermExist:(NSString *)perm account:(NSString *)account completion:(void (^)(BOOL exist,NSError *error))completion;
```

#### **检查权限是否link到***`action`*

```
+ (void)perm:(NSString *)perm isLinkActions:(NSArray<TPLinkAction *> *)actions account:(NSString *)account completion:(void (^)(BOOL permExisted,BOOL linked,NSError *error))completion;
```

#### **清除本地授权**

```
+ (BOOL)clearAuth:(NSString *)account;
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.tokenpocket.pro/developer-cn/mobile-wallet/eos-miniwallet-sdk/ios.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
