MacOS上的AswebauthenticationSession 12.4无法正常工作
我正在为我的应用程序使用Aswebauthenticationsessessionsession。 它在MACOS12.4之前正常工作,但出现了无反应的问题。 在“ session.start成功”之后,单击取消或继续,没有响应。
var session = ASWebAuthenticationSession.init(url: url, callbackURLScheme: "http", completionHandler: completionHandler)
guard let provider = NSApplication.shared.keyWindow!.contentViewController as? FlutterViewController else {
result(FlutterError(code: "FAILED", message: "Failed to aquire root FlutterViewController" , details: nil))
return
}
session.presentationContextProvider = provider
if(!session.start()) {
NSLog("session.start fail");
} else {
NSLog("session.start success");
}
I'm using ASWebAuthenticationSession authorization for my application.
It works fine before macOS12.4, but occur unresponse's issue.
After "session.start success", Click Cancel or Continue and there is no response.
var session = ASWebAuthenticationSession.init(url: url, callbackURLScheme: "http", completionHandler: completionHandler)
guard let provider = NSApplication.shared.keyWindow!.contentViewController as? FlutterViewController else {
result(FlutterError(code: "FAILED", message: "Failed to aquire root FlutterViewController" , details: nil))
return
}
session.presentationContextProvider = provider
if(!session.start()) {
NSLog("session.start fail");
} else {
NSLog("session.start success");
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
编辑:我只是注意到我没有正确阅读,而错过了这个问题是MacOS而不是iOS的事实。我仍然希望其中一个答案可能会导致解决方案。
我注意到了两件事对我来说似乎是不正确的。
第一个是您的会议需要大量参考。此限制仅适用于iOS版本< 13.0。
这意味着,会话变量必须“超越”其启动的调用方法,例如为整个类设置会话属性。
在您提供的代码段中,我看不到类似的内容,对我来说看起来像是一个范围的变量。
从苹果此功能的文档
第二件事是您的回调URL方案似乎设置为
https
。该方案应匹配您的应用程序包ID。
它必须在您的
info.plist
文件中配置。 这是一个示例,这是一个示例。它实际上应该是com.com.pan.myappname
而不是http
。您的身份验证提供商还需要重定向到com.com.com.pany.myappname:// someurl
才能使此工作。请注意,://
不得成为回调URL方案的一部分,仅是在此之前的零件。Edit: I just noticed I did not read correctly and missed the fact that this question was for macOS, not iOS. I still hope one of those answers might lead to a solution.
I have noticed 2 things that seem incorrect to me.
The first one is that you need a strong reference for your session. This limitation is only valid for iOS version < 13.0.
This means, the session variable must "outlive" the invoked method it was started in, e.g. setting a session attribute for the whole class.
I cannot see something similar in the code snippet you provided, it looks like a scoped variable to me.
From Apples documentation for this feature:
The second thing is your callback URL scheme seems to be set to
https
.The scheme should match your apps bundle ID.
It must be configured in your
Info.plist
file. Here's an example how to achieve this. It should actually be something likecom.company.myappname
instead ofhttp
. Your authentication provider would also need to redirect tocom.company.myappname://someurl
to make this work. Please note the://
must not be part of the callback URL scheme, only the part before that.