iOS Uni-APP SDK

概述

AppAuth.framework和AppAuthUniPlugin.framework为uni-app iPhone手机开发者提供的多种登录认证模块的SDK包,辅助开发者快速接入登录、注册、生物认证等功能。 本SDK基于Objective-C开发,SDK接入也通过OC的语法进行。

最新SDK包

模块名 SDK包 最新版本 文件大小 下载链接
认证SDK AppAuth.framework 1.0 1,975,419bytes 下载地址
Uni-App封装SDK AppAuthUniPlugin.framework 1.0 89,941bytes 下载地址


SDK包介绍

AppAuth.framework基于开源代码AppAuth,对AppAuth做了一层封装在使用过程中,与AppAuth的原始SDK接入有一定区别。 AppAuthUniPlugin.framework封装了对AppAuth的调用,提供接口给Uni-App使用。 本接入SDK以离线SDK为例,在线打包的方法,可参考UNI-APP官方介绍。

iOS SDK支持的版本

iOS版本 SDK描述
> iOS9 uses the in-app browser tab pattern (via SFSafariViewController)
>= iOS7 system browser

iOS SDK离线打包工程配置

参考官方文档:https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/ios.html
  1. 离线打包开发环境和配置请参考官方文档;
  2. 集成uni-app SDK
    1. 在主工程中添加framework框架: 【工程】-【General】-【frameworks,library,and Embedded Content】下添加:
      AppAuth.framework
      AppAuthUniPlugin.framework
      
    2. 头文件配置 【工程】-【Build Settings】-【Header Search Paths】 添加"$../SDK/Libs/AppAuthUniPlugin.framework/Headers",并设置“recursive”=true
  3. SDK内部会通过shceme形式接受认证中的浏览器的通信数据,scheme的配置在APP层级,需要在项目的info.plist的URL types中新增Item,在URL Schemes配置一个scheme,scheme值如下:
net.rj.appauth

离线打包:iOS SDK接口使用

AppAuthSDKModule


/**
* 调用SDK进行认证
@param options:
    {"clientId":"","redirectUrl":"","discoveryUri":""}

@param callback 
    {"ret":,"errMessage":""}
    ret: 见下面表格
*/

(void)getAuthenticationIntent:(NSDictionary *)options callback:(UniModuleKeepAliveCallback)callback


/*
*  退出登录
*  @param callback
        {"ret":,"errMessage":""}
        ret: 见下面表格
*/
 (void)endSession:(NSDictionary *)options callback:(UniModuleKeepAliveCallback)callback

接口中参数来源说明(关于url域名的绝对地址拼装,参考【概述】-【域名地址配置说明】):

参数名 参数来源/值
clientID 超管在统一身份认证后台配置后提供,见【准备工作】
redirectURI 超管在统一身份认证后台配置后提供,见【准备工作】
discoveryUri 域名,相对路径 : /oidc

ret返回码注解:

retcode retMsg
0 成功
206 当前正在验证中,请勿重复发起验证
502 参数错误
503 登录过程中异常,详细返回errMessage
500 操作前,请先登录

HBuilderX工程调用示例

请通过HBuilderX工程编写vue代码,并生成可执行的js代码,拷贝到离线打包工程assets对应目录下。

var rjAuthorModule = uni.requireNativePlugin("AppAuthUniPlugin-AppAuthSDKModule")
const modal = uni.requireNativePlugin('modal');

data() {
     return {
         formData:{
             clientId:'OC4wNS4wNS4wNy4wMC4wMy4wMS4wMS4w',
             redirectUrl:'https://s10sso.ruishan.cc/gate/public/sdkAuth/index.html',
             endSessionRedirectUrl:'https://s10sso.ruishan.cc/gate/public/sdkAuth/index.html'
             discoveryUri:'https://s10sso.ruishan.cc/cas/oidc'

     }
   };
}

getAuthenticationIntent() {                                  
     rjAuthorModule.getAuthenticationIntent(JSON.stringify(this.formData),(ret) => { })                     
},
endSession() {
     rjAuthorModule.endSession({'name': 'unimp'},(ret) => {})
}var rjAuthorModule = uni.requireNativePlugin("AppAuthUniPlugin-AppAuthSDKModule")
const modal = uni.requireNativePlugin('modal');

data() {
     return {
         formData:{
             clientId:'OC4wNS4wNS4wNy4wMC4wMy4wMS4wMS4w',
             redirectUrl:'https://s10sso.ruishan.cc/gate/public/sdkAuth/index.html',
             endSessionRedirectUrl:'https://s10sso.ruishan.cc/gate/public/sdkAuth/index.html'
             discoveryUri:'https://s10sso.ruishan.cc/cas/oidc'

     }
   };
}

getAuthenticationIntent() {                                  
     rjAuthorModule.getAuthenticationIntent(JSON.stringify(this.formData),(ret) => { })                     
},
endSession() {
     rjAuthorModule.endSession({'name': 'unimp'},(ret) => {})
}

UNI-APP调用脚本DEMO

UNI-APP调用脚本DEMO

©2025 锐捷网络股份有限公司 all right reserved,powered by Gitbook该文章修订时间: 2026-05-07 11:14:26

results matching ""

    No results matching ""