从自动填充凭据提供程序扩展打开主应用程序时出错 [英] Error when opening main app from Autofill Credential Provider extension

查看:34
本文介绍了从自动填充凭据提供程序扩展打开主应用程序时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:这篇博文的目的是找出下面代码的问题,并找到合适的解决方案,从其自动填充凭据提供程序扩展目标打开主应用程序.

尝试 1:我将 URL 方案设置为打开";如下图所示:

<块引用>

然后我尝试从我的扩展视图控制器调用这个函数:

 func openMainApp(){让 urlStr: String = "open";让 url2 = NSURL(string: urlStr)self.extensionContext.open(url2! as URL)}

在打开主应用程序之前,它在打开函数之前崩溃,并显示以下消息:

<块引用>

线程 2:EXC_BAD_ACCESS(代码=1,地址=0x10)

我认为一切都设置正确,可以打开应用程序.我错过了什么?

尝试 2:尝试新的配置以避免解包"下面的url问题和无效url问题,将url方案更改为open:",并在print(url)"处设置断点;行以确保 url 已形成.断点变量记录在代码下方.

仍然得到:线程 3:EXC_BAD_ACCESS(代码=1,地址=0x10)

 func openMainApp(){var urlComponents = URLComponents(string: "open:")如果让 url = urlComponents?.url {打印(网址)self.extensionContext.open(url)} 别的 {打印(NIL URL")}}

<块引用>

urlComponents Foundation.URLComponents?一些url Foundation.URL 打开:"_url NSURL 打开:"0x0000000281695540baseNSObject@0 NSObject
_urlString id 0x100001d80 0x00000000100001d80_baseURL ID 0x800010000010001 0x0800010000010001_clients NSString 打开:"0x8521474e0e31dd15_reserved NSURL 0x0000000000000000

抛出异常的线程的标题:

<块引用>

ExtensionKit`__62-[EXExtensionContextImplementation openURL:completionHandler:]_block_invoke_2:

解决方案

Credential Provider 扩展程序不允许打开 url.

来自文档

<块引用>

每个扩展点决定是否支持该方法,或者在什么条件下支持该方法.在 iOS 中,Today 和 iMessage 应用扩展点支持此方法.iMessage 应用扩展程序只能使用此方法打开其父应用,并且仅当父应用显示在 iOS 主屏幕上时.

Problem: The aim of this post is to find what's wrong with the code below and find the appropriate solution to open the main app from its Autofill Credential Provider extension target.

Attempt 1: I have a URL scheme set as "open" as shown in the image below:

I then attempt to call this function from my extension viewcontroller:

    func openMainApp()
{
    let urlStr: String = "open"
    let url2 = NSURL(string: urlStr)
    self.extensionContext.open(url2! as URL)
}

This crashes before at the open function before opening the main app with the following message:

Thread 2: EXC_BAD_ACCESS (code=1, address=0x10)

I think everything is set up properly to open the app. What am I missing?

Attempt 2: Tried a new configuration to avoid "unwrapping" of url problem and invalid url problems below, changed url scheme to "open:", and set a breakpoint at the "print(url)" line to assure url was formed. Breakpoint vars documented below the code.

Still getting: Thread 3: EXC_BAD_ACCESS (code=1, address=0x10)

    func openMainApp()
{
    var urlComponents = URLComponents(string: "open:")
            if let url = urlComponents?.url {
                print(url)
                self.extensionContext.open(url)
            } else {
                print ("NIL URL")
            }
}

urlComponents Foundation.URLComponents? some url Foundation.URL "open:" _url NSURL "open:" 0x0000000281695540 baseNSObject@0 NSObject
_urlString id 0x100001d80 0x0000000100001d80 _baseURL id 0x800010000010001 0x0800010000010001 _clients NSString "open:" 0x8521474e0e31dd15 _reserved NSURL 0x0000000000000000

Title of the Thread throwing the exception:

ExtensionKit`__62-[EXExtensionContextImplementation openURL:completionHandler:]_block_invoke_2:

解决方案

Credential Provider extensions are not permitted to open urls.

From the documentation

Each extension point determines whether to support this method, or under which conditions to support this method. In iOS, the Today and iMessage app extension points support this method. An iMessage app extension can use this method only to open its parent app, and only if the parent app is shown on the iOS home screen.

这篇关于从自动填充凭据提供程序扩展打开主应用程序时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆