DID SDK使用文档

DID SDK [使用文档]

一、安装

因为SDK目前尚未发布至GitHub,目前只支持手动安装。

手动安装:

  1. DIDSDK.frameworkDIDSDKBundle.bundle文件拷贝到项目中。

  2. 进入你的项目,选择Add files to Your Project Name

  3. 导入 DIDSDK。

graph LR DIDSDK.framework --> Project{Your Project} DIDSDKBundle.bundle --> Project

in Swift

import DIDSDK

in Objective-C

#import <DIDSDK/DIDSDK.h>

二、使用

SDK权限设置:

1、打开info.plist,添加Application supports iTunes file sharing,设置为NO
2、打开info.plist,添加View controller-based status bar appearance,设置为YES
3、打开info.plist,添加Privacy - Microphone Usage Description
4、打开info.plist,添加Privacy - Camera Usage Description

SDK版本要求:

[iOS 11] && [iOS 11 +]

SDK注册:

进入AppDelegate.m中注册SDK:

objective-c 复制代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    NSString *clientId = @"your clientId";
    NSString *clientKey = @"your clientKey";
    NSString *phoneNumber = @"your phoneNumber";
    NSString *phoneCountryCode = @"your phoneCountryCode";
    [DIDSDKManager.shared  registerSDKWithClientId:clientId clientKey:clientKey phoneCountryCode:phoneCountryCode phoneNumber:phoneNumber resultBlock:^(ResultErrorType type, NSString * msg) {
        NSLog(@"注册结果:%@", msg);
    }];
}

当注册回调中,ResultErrorTypeRESULTTYPE_SUCCESS_REGISTER 时,代表注册成功,更多类型可以查看DIDSDKManagerDefine.h

注意: 在使用SDK前,请务必保证在SDK注册成功后,否则将无法正常使用.

开始认证:

当您需要使用SDK的认证服务时

objective-c 复制代码
[[DIDSDKManager  shared] startServiceFromeNavi:self.navigationController resultBlock:^(NSString * _Nonnull accessToken) {
    // save the accessToken on your project
    // use the accessToken...
}];

当您需要使用SDK的Open API服务时

您可以导入#import <DIDSDK/DIDNetManager+Post.h>,并查看DIDNetManager+Post.h中的请求方法。

请求回调定义

objective-c 复制代码
///  数据请求回调
typedef  void (^RequestCompleteServiceBlock)(NSDictionary *dic);
typedef  void (^RequestErrorServiceBlock)(NSError *error);

请求方法定义

objective-c 复制代码
///  发送短信验证码
///  - Parameters:
///  - phoneNumber: 手机号
///  - phoneCountryCode: 手机所属区
///  - channel: 发送方式
+(void)sendSmsMessagingWithPhoneNumber:(NSString *)phoneNumber
 phoneCountryCode:(NSString *)phoneCountryCode
    channel:(SMSChannel)channel
 completeBlock:(RequestCompleteServiceBlock)successBlock
 errorBlock:(RequestErrorServiceBlock)errorBlock;

///  根据人脸获取AccessToken
///  - Parameters:
///  - portraitImage: 人脸图片base64字符串
///  - verifyMethod: 认证方式
///  - block: 回调
+(void)getAccessTokenByFacePortraitImage:(NSString *)portraitImage
    verifyMethod:(VerifyMethod)verifyMethod
 completeBlock:(RequestCompleteServiceBlock)successBlock
  errorBlock:(RequestErrorServiceBlock)errorBlock;

///  根据email 或者mobile 获取AccessToken
///  - Parameters:
///  - email: email description
///  - password: password description
///  - phoneNumber: phoneNumber description
///  - phoneCountryCode: phoneCountryCode description
///  - phonePassCode: phonePassCode description
///  - verifyMethod: 认证方式
///  - block: 回调
+(void)getAccessTokenByEmailOrMobileWithEmail:(NSString *)email
    password:(NSString *)password
  phoneNumber:(NSString *)phoneNumber
 phoneCountryCode:(NSString *)phoneCountryCode
   phonePassCode:(NSString * )phonePassCode
   verifyMethod:(VerifyMethod)verifyMethod
 completeBlock:(RequestCompleteServiceBlock)successBlock
   errorBlock:(RequestErrorServiceBlock)errorBlock;

///  User Inquiry
///  查询did账号的信息
///  - block: 回调
+(void)getAccountWithCompleteBlock:(RequestCompleteServiceBlock)successBlock
    errorBlock:(RequestErrorServiceBlock)errorBlock;

///  User phone number modification
///  修改手机号
///  - Parameters:
///  - newPhoneNumber: 新手加号
///  - newPhonePassCode: 新手机号验证码
///  - newPhoneCountryCode: 手机区号
///  - block: 回调
+(void)modificationUserPhoneNumberWithNewPhoneNumber:(NSString *)newPhoneNumber
    newPhonePassCode:(NSString *)newPhonePassCode
   newPhoneCountryCode:(NSString *)newPhoneCountryCode
  completeBlock:(RequestCompleteServiceBlock)successBlock
    errorBlock:(RequestErrorServiceBlock)errorBlock;

///  User attribute modification
///  修改did账号的信息
///  - Parameters:
///  - userName: 昵称
///  - familyName: 姓
///  - middleName: 中间名
///  - givenName: 名
///  - avatarImage: 头像
///  - portraitImage: 人脸底图
///  - idType: ID类型
///  - idNumber: ID账号
///  - birthday: 生日,格式为yyyy-MM-dd
///  - gender: 性别
///  - company: 所在公司
///  - address: 所处地址
///  - block: 回调
+(void)modificationUserAttributeWithUserName:(NSString *)userName
   familyName:(NSString *)familyName
   middleName:(NSString *)middleName
    givenName:(NSString *)givenName
   avatarImage:(NSString *)avatarImage
 portraitImage:(NSString *)portraitImage
    idType:(IdType)idType
   idNumber:(NSString *)idNumber
   birthday:(NSString *)birthday
    gender:(GenderType)gender
    company:(NSString *)company
    address:(NSString *)address
completeBlock:(RequestCompleteServiceBlock)successBlock
   errorBlock:(RequestErrorServiceBlock)errorBlock;

///  User registration
///  用户注册
///  - Parameters:
///  - passCode: 一次性临时验证码,你需要先调用发送短信或者发送邮件接口获取验证码。目前仅支持手机验证
///  - email: 邮箱
///  - phoneCountryCode: 手机区号,默认沙特手机号可不填
///  - givenName: 名
///  - userName: 昵称
///  - familyName: 姓
///  - middleName: 中间名
///  - givenName: 名
///  - avatarImage: 头像
///  - portraitImage: 人脸底图
///  - idType: ID类型
///  - idNumber: ID账号
///  - birthday: 生日,格式为yyyy-MM-dd
///  - gender: 性别
///  - company: 所在公司
///  - address: 所处地址
///  - block: 回调
+(void)userRegistrationWithPassCode:(NSString *)passCode
email:(NSString *)email
    phoneNumber:(NSString *)phoneNumber
 phoneCountryCode:(NSString *)phoneCountryCode
    userName:(NSString *)userName
   familyName:(NSString *)familyName
   middleName:(NSString *)middleName
    givenName:(NSString *)givenName
  avatarImage:(NSString *)avatarImage
 portraitImage:(NSString *)portraitImage
    idType:(IdType)idType
    idNumber:(NSString *)idNumber
    birthday:(NSString *)birthday
    gender:(GenderType)gender
    company:(NSString *)company
    address:(NSString *)address
 completeBlock:(RequestCompleteServiceBlock)successBlock
    errorBlock:(RequestErrorServiceBlock)errorBlock;

///  User deletion
///  删除did账号的信息
///  - block: 回调
+(void)userDeletionWithCompleteBlock:(RequestCompleteServiceBlock)successBlock
    errorBlock:(RequestErrorServiceBlock)errorBlock;

///  AccessToken refreshing
///  使用RefreshToken在AccessToken快过期前刷新AccessToken生成新的AccessToken与RefreshToken
///  - Parameters:
///  - refreshToken: 刷新token
///  - block: 回调
+(void)refreshingAccessTokenWithRefreshToken:(NSString *)refreshToken
  completeBlock:(RequestCompleteServiceBlock)successBlock
    errorBlock:(RequestErrorServiceBlock)errorBlock;

///  Logout of AccessToken
///  用户安全地退出登录。
///  - block: 回调
+(void)logoutWithCompleteBlock:(RequestCompleteServiceBlock)successBlock
    errorBlock:(RequestErrorServiceBlock)errorBlock;

///  Organizational Information Inquiry
///  获取当前组织基本信息。组织不存在返回为null
///  - block: 回调
+(void)getOrganizationalWithCompleteBlock:(RequestCompleteServiceBlock)successBlock
    errorBlock:(RequestErrorServiceBlock)errorBlock;

///  kafd-access-control
///  获取二维码
///  - block: 回调
+(void)qrcodesWithUserId:(NSString *)userId
  completeBlock:(RequestCompleteServiceBlock)successBlock
    errorBlock:(RequestErrorServiceBlock)errorBlock;

其中关于SMSChannelVerifyMethodIdTypeGenderType 的定义和说明,请查看DIDSDKManagerDefine.h

SDK提供的文件

为了帮助您更好的使用DID SDK,我们提供的以下头文件和SDK需要的资源文件:

DID SDK Header Bundle
SDK Manager cer
SDK Network img
SDK Cache language
model
相关推荐
app开发工程师V帅1 小时前
iOS 苹果开发者账号: 查看和添加设备UUID 及设备数量
ios
CodeCreator18181 小时前
iOS AccentColor 和 Color Set
ios
iOS民工2 小时前
iOS keychain
ios
m0_748238925 小时前
webgis入门实战案例——智慧校园
开发语言·ios·swift
Legendary_0089 小时前
LDR6020在iPad一体式键盘的创新应用
ios·计算机外设·ipad
/**书香门第*/18 小时前
Laya ios接入goole广告,搭建环境 1
ios
wakangda1 天前
React Native 集成 iOS 原生功能
react native·ios·cocoa
crasowas2 天前
iOS - 超好用的隐私清单修复脚本(持续更新)
ios·app store
ii_best2 天前
ios按键精灵脚本开发:ios悬浮窗命令
ios
Code&Ocean2 天前
iOS从Matter的设备认证证书中获取VID和PID
ios·matter·chip