ASWebAuthenticationSession只显示取消按钮。
创始人
2024-09-21 00:00:08
0

要实现ASWebAuthenticationSession只显示取消按钮,可以使用ASWebAuthenticationPresentationContextProviding协议来自定义展示上下文。

首先,在你的视图控制器中,遵循ASWebAuthenticationPresentationContextProviding协议,并实现该协议的presentationAnchor(for:)方法。在该方法中,返回一个合适的窗口用于展示ASWebAuthenticationSession。

import AuthenticationServices

class ViewController: UIViewController, ASWebAuthenticationPresentationContextProviding {
    
    // ...
    
    func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor {
        return self.view.window ?? ASPresentationAnchor()
    }
    
    // ...
    
}

然后,创建ASWebAuthenticationSession时,将视图控制器设置为其presentationContextProvider属性。

let authenticationURL = URL(string: "your_authentication_url")!
let callbackURLScheme = "your_callback_url_scheme"

let session = ASWebAuthenticationSession(url: authenticationURL, callbackURLScheme: callbackURLScheme) { callbackURL, error in
    // 处理回调URL或错误
}

session.presentationContextProvider = self
session.start()

这样,ASWebAuthenticationSession将在你的视图控制器上下文中展示,只显示取消按钮。

相关内容

热门资讯

透视辅助!aapoker透视插... 透视辅助!aapoker透视插件(透视)插件(都是有挂)1、该软件可以轻松地帮助玩家将aapoker...
透视代打!aapoker怎么选... 透视代打!aapoker怎么选牌(透视)透视脚本下载(确实有挂)1、完成aapoker怎么选牌的残局...
透视代打!aapoker透视方... 透视代打!aapoker透视方法(透视)透视方法(真是是真的有挂)亲,关键说明,aapoker透视方...
透视有挂!aapoker辅助软... 透视有挂!aapoker辅助软件合法吗(透视)辅助(真是存在有挂)1、aapoker辅助软件合法吗透...
透视黑科技!aapoker透视... 透视黑科技!aapoker透视脚本(透视)透视脚本(本来是真的有挂)1、aapoker透视脚本系统规...
透视辅助!aapoker脚本(... 透视辅助!aapoker脚本(透视)辅助(好像存在有挂)1、aapoker脚本透视辅助简单,aapo...
透视实锤!aapoker透视方... 透视实锤!aapoker透视方法(透视)ai插件(都是是真的有挂)1、上手简单,内置详细流程视频教学...
透视教学!aapoker辅助工... 透视教学!aapoker辅助工具安全吗(透视)真的假的(原来真的有挂)1、透视教学!aapoker辅...
透视插件!aapoker透视脚... 透视插件!aapoker透视脚本入口(透视)免费透视脚本(切实存在有挂)在进入aapoker透视脚本...
透视存在!aapoker怎么拿... 透视存在!aapoker怎么拿好牌(透视)免费透视脚本(果然真的有挂)1、进入游戏-大厅左侧-新手福...