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
相关推荐
DisonTangor5 小时前
苹果发布iOS 18.2首个公测版:Siri接入ChatGPT、iPhone 16拍照按钮有用了
ios·chatgpt·iphone
- 羊羊不超越 -5 小时前
App渠道来源追踪方案全面分析(iOS/Android/鸿蒙)
android·ios·harmonyos
2401_8658548821 小时前
iOS应用想要下载到手机上只能苹果签名吗?
后端·ios·iphone
HackerTom1 天前
iOS用rime且导入自制输入方案
ios·iphone·rime
良技漫谈1 天前
Rust移动开发:Rust在iOS端集成使用介绍
后端·程序人生·ios·rust·objective-c·swift
2401_852403551 天前
高效管理iPhone存储:苹果手机怎么删除相似照片
ios·智能手机·iphone
星际码仔2 天前
【动画图解】是怎样的方法,能被称作是 Flutter Widget 系统的核心?
android·flutter·ios
emperinter2 天前
WordCloudStudio:AI生成模版为您的文字云创意赋能 !
图像处理·人工智能·macos·ios·信息可视化·iphone
关键帧Keyframe2 天前
音视频面试题集锦第 8 期
ios·音视频开发·客户端
pb82 天前
引入最新fluwx2.5.4的时候报错
flutter·ios