gpt4 book ai didi

ios - iOS 13 上的 ASWebAuthenticationSession

转载 作者:行者123 更新时间:2023-12-01 16:13:37 28 4
gpt4 key购买 nike

我安装了 iOS 13,通过 Safari 的身份验证不再有效。我在 iOS 12 上有相同的配置,除了 self.authSessionAS.presentationContextProvider = self;

self.authSessionAS = [[ASWebAuthenticationSession alloc]initWithURL:[[NSURL alloc] initWithString:self.authUrl] callbackURLScheme:@"app://" completionHandler:^(NSURL * _Nullable callbackURL, NSError * _Nullable error) {
if(callbackURL)
{
self.resultStream(callbackURL.absoluteString);
}else
{
self.resultStream(@"");
}
self.resultStream = NULL;
}];

self.authSessionAS.presentationContextProvider = self;
[self.authSessionAS start];

最佳答案

我找到了解决方案

在实现之上添加。

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
@interface AppDelegate() <ASWebAuthenticationPresentationContextProviding>
@end
#endif

在您的 Auth 代码中。

self.authSessionAS = [[ASWebAuthenticationSession alloc]initWithURL:[[NSURL alloc] initWithString:self.authUrl] callbackURLScheme:@"app://" completionHandler:^(NSURL * _Nullable callbackURL, NSError * _Nullable error) {
if(callbackURL)
{
self.resultStream(callbackURL.absoluteString);
}else
{
self.resultStream(@"");
}
self.resultStream = NULL;
}];

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
if (@available(iOS 13, *)) {
self.authSessionAS.presentationContextProvider = self;
}
#endif

[self.authSessionAS start];

添加方法

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
#pragma mark - ASWebAuthenticationPresentationContextProviding
- (ASPresentationAnchor)presentationAnchorForWebAuthenticationSession:(ASWebAuthenticationSession *)session API_AVAILABLE(ios(13.0)){
return UIApplication.sharedApplication.keyWindow;
}
#endif

关于ios - iOS 13 上的 ASWebAuthenticationSession,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58237404/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com