# 备注



# 1 导入资源文件和framework

从压缩包解压文件中将下面文件直接拖到新项目中：

```
1 framework  ： 3个：

PDFReaderSDKTextBook.framework
FoxitRDK.framework
CKCEvaluationSDK.framework

2 Resources 文件夹

3 CKCEvaluation.bundle

4 images.xcassets

5 writeCard

注意 先放在本地文件夹
再从本地文件夹拖入项目
选择 Create folder reference
创建的是蓝色文件夹

6 pep.ttf

```



# 2 项目中配置增加 framework

在 xcode 的 TARGETS 中， General 栏目
的 framework，libraries，and Enbedded Content

添加：

AddressBook.framework
CoreGraphics.framework
CoreMotion.framework
CoreText.framework
libc++.1.tbd
libz.tbd
Social.framework



# 3 配置pods

参考demo ，在 Podfile 中增加


```
Podfile

pod 'AFNetworking'
pod 'Masonry'
pod 'SDWebImage'

#SDK
pod 'PEPNetworking' #, :git => 'https://github.com/PEPDigitalPublishing/PEPNetworking.git'
pod 'PEPBigData' #, :git => 'https://github.com/PEPDigitalPublishing/PEPBigData.git'
pod 'ZSSRichTextEditor'#, :git => 'https://github.com/nnhubbard/ZSSRichTextEditor.git'
pod 'YYModel'

pod 'SSZipArchive'
pod 'SAMKeychain'
pod 'FMDB'
pod 'MBProgressHUD'
pod 'MJRefresh'
pod 'PEPiFlyMSC', :git => 'https://github.com/PEPDigitalPublishing/PEPiFlyMSC.git'
pod 'ChameleonFramework'
```


配置完成，使用命令行  pod update


# 4 初始化

参考 demo中 的 ViewController.m

```
#import <PDFReaderSDKTextBook/PDFReaderSDKTextBook.h>
#import <Masonry/Masonry.h>
#import <AFNetworking.h>
#import <PDFReaderSDKTextBook/PEPHttpUtil.h>
#import <PDFReaderSDKTextBook/PEPURLPath.h>
```

# 5 获取 授权码
使用 userid 获取  authorize_code
```
NSDictionary *param1 =@{@"user_id": UserID,
                            @"client_id": SDKClientAppID,                                               };
    
    [PEPHttpUtil getWithPth:kAPI_UserAuth2 params:param1 progress:^(NSProgress *downLoadProgress) {
    } success:^(id JSON) {
        [MBProgressHUD hideHUD];
        if ([JSON[@"statusCode"] isEqualToString:@"500110"]) {
            NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:JSON[@"dataMap"]];
            self.authorize_code = dict[@"authorize_code"];
            [MBProgressHUD showNormalText:@"已获取授权码"];
        }else{
            [MBProgressHUD showNormalText:@"用户名或密码错误"];
        }
    } failure:^(NSError *error) {
        [MBProgressHUD showNormalText:@"请求失败"];
    }];




```

使用 账号密码 获取  authorize_code

```
    NSDictionary *param =@{@"username":self.accountField.text,
                           @"password":encodePassWord,
                                           @"client_id":@"110000006",
                                               };
    [PEPHttpUtil postWithPth:kAPI_UserAuth3 params:param success:^(id JSON) {
        [MBProgressHUD hideHUD];
        if ([JSON[@"statusCode"] isEqualToString:@"500110"]) {
            NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:JSON[@"dataMap"]];
            self.authorize_code = dict[@"authorize_code"];
            
            
//           保存账号密码
            [[NSUserDefaults standardUserDefaults] setObject:self.accountField.text forKey:kAccountStr];
            [[NSUserDefaults standardUserDefaults] setObject:self.pwdField.text forKey:kPwdStr];

            [[NSUserDefaults standardUserDefaults] synchronize];
            
            
            [MBProgressHUD showNormalText:@"已获取授权码"];
            
            
        }else{
            [MBProgressHUD showNormalText:@"用户名或密码错误"];
        }
    } failure:^(NSError *error) {
        [MBProgressHUD showNormalText:@"请求失败"];
    }];

```


# 6 使用 整本模式
见 demo “书架授权”

```
- (void)setPEPTextbookConfig
{

    
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];

    if (self.authorize_code.length == 0) {
         [MBProgressHUD showNormalText:@"请获取授权码"];
         return;
     }
     
     
     dic = (NSMutableDictionary *)@{@"ticket":@"ticket",
                                    @"code":self.authorize_code,
                                    @"user_id":UserID,
                                    @"client_id":SDKClientAppID,
                                    @"device_type":@"2",
     };
     
     
     [self loginWithCodeDic:dic];
    

}

- (void)loginWithCodeDic:(NSDictionary *)param
{
    PEPReaderTextBookManager *manager = [PEPReaderTextBookManager PEPShareManagerWithAPPID:SDKClientAppID];
    [manager PEPLoginWithAuthCode:param andCallBack:^(id resopnse) {
        PEPHomeCenterViewController *pepVC = [[PEPHomeCenterViewController alloc]init];
        pepVC.hidesBottomBarWhenPushed = YES;
        self.tabBarController.tabBar.hidden = YES;
        [self.navigationController pushViewController:pepVC animated:YES];
        
    }];
}
```

# 7 使用 单册 API 模式
见 demo 单册授权

参考  PEPReaderTextBookManager 类
## 打开教材

```
// 打开书籍
- (void)PEPOpenBookWithBookID:(NSString *)bookID;

```

## 下载教材
```
//下载书  根据章节数组
- (void)PEPDownloadResourceWaithChapterArray:(NSArray *)chapterArray bookID:(NSString *)bookID;


//下载整本书书  根据id
- (void)PEPDownloadZipAndResourceWithBookID:(NSString *)bookID;


```

## 获取已下载的教材信息
```
// 获取我的教材书本信息（下载中和已下载）
- (NSArray *)PEPGetMyTextBook;
```

## 下载监听
```
//获取下载状态    0-完成 1-已下载了部分（继续下载） 2-更新 3-取消（正在下载）4-删除 5-下载
- (NSInteger)PEPGetBookDownloadStatusWithBookID:(NSString *)bookID;
```

## 删除教材
```
// 根据bookID删除教材
- (void)PEPDeleteBookWithBookID:(NSString *)bookID;
```

## 获取章节列表
```
// 查询教材详情
- (void)getPEPTextbookDetailWithBookID:(NSString *)bookID withBlock:(CompleteBlock)completeBlock;
```

## 获取教材中心筛选信息
```
/**
 查询教材列表

 @param dic 请求参数{rkxd:学段,zxxkc:学科,nj:年级,name:教材名称(支持模糊搜索),pageno:分页页码(int 默认1),pagesize:分页大小(int 默认10),detail:是否返回详情(String类型,true/false;默认false不返回)}   参数皆为非必需
 @param finished 成功/失败完成后回调
 */
- (void)queryTextbookListWithParam:(NSDictionary *)dic withBlock:(CompleteBlock)finished;
```


##  查询教材 目录

/**
 查询教材 目录

 @param dic 请求参数{id:教材ID(String,必需)}
 @param finished 成功/失败完成后回调
 */
- (void)queryTextbookCatalogue:(NSDictionary *)dic withBlock:(CompleteBlock)finished;

##  查询教材 学科工具
/**
 查询教材 学科工具

 @param dic 请求参数{id:教材ID(String,必需)}
 @param finished 成功/失败完成后回调
 */
- (void)queryTextbookSubjectToolsWithBlock:(CompleteBlock)finished;





