在iOS扩展程序和包含钥匙串的应用程序之间共享? [英] Share between an iOS extension and it's containing app with the keychain?

查看:230
本文介绍了在iOS扩展程序和包含钥匙串的应用程序之间共享?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解我可以通过启用应用群组和使用NSUserDefaults在我的共享扩展程序和其包含应用之间共享数据(请参阅在iOS 8共享扩展程序和主应用程序之间共享数据

I understand I can share data between my share extension and its containing app by enabling app groups and using NSUserDefaults (see Sharing data between an iOS 8 share extension and main app).

但是,我存储的数据很敏感,所以我希望使用钥匙串。因此,用户可以在包含的应用程序中输入帐户信息,然后共享扩展程序将读取该数据以执行预期的共享操作。

However, the data I am storing is sensitive, so I hoped to use the keychain. So the user would enter account information in the containing app, and then the share extension would read that data to perform the intended sharing action.

有谁知道这是否可行?我的第一个破解建议扩展和包含应用程序具有单独的钥匙串(在包含应用程序中使用密钥保存数据时,在尝试返回扩展中该键的数据时返回null)。

Does anyone know if this is possible? My first crack at it suggests that the extension and the containing app have separate keychains (saving the data with a key in the containing app returns null when attempting to return data for that key in the extension).

谢谢!

PS使用Lockbox进行Keychain访问,但如果它太过抽象而无法使其工作,我可能会抛弃它。 https://github.com/granoff/Lockbox

P.S. Using Lockbox for Keychain access, but I could ditch it if it's too much of an abstraction to make it work. https://github.com/granoff/Lockbox

推荐答案

这可以做到。它是创建一个框架来进行Keychain访问,并在Capabilities下启用Activate Keychain Sharing的组合。这个链接告诉我我需要知道的事情: http:// swiftandpainless .com / ios8-share-extension-with-a-shared-keychain /

This can be done. It is a combination of creating a framework to do the Keychain access, and turning on "Activate Keychain Sharing" under "Capabilities". This link told me what I needed to know: http://swiftandpainless.com/ios8-share-extension-with-a-shared-keychain/

这篇关于在iOS扩展程序和包含钥匙串的应用程序之间共享?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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