2017-07-06 115 views

回答

0

在这里我得到了它的诀窍,它为我工作。

使用钥匙扣插件

钥匙串插件可以让你安全地将数据存储在iOS的 钥匙扣。

您可以使用此插件设置,获取和删除钥匙串中的值。 存储在钥匙串中的项目可以保留卸载并重新安装您的 应用程序。该数据不可用于任何其他应用程序,除非它使用相同的供应配置文件签署了 。当用户备份iOS数据时, 钥匙串数据将被备份,但密钥链中的秘密仍保留在备份中加密的 。

钥匙串将数据存储为键值对。您需要使用相同的服务名称设置并获取这些对。如果你有一个新的值设置现有密钥 ,旧值将被覆盖

的PhoneGap构建用户只需要使用这个插件安装到config.xml文件

<plugin name="cordova-keychain" source="npm" /> 

如何使用它在应用程序?

// prepare some variables 
var servicename = 'MyAppUUID'; 
var key = 'MyApp'; 
var value = 'Your UUID'; // Set your Device Id here. 

// prepare the callback functions 
function onSuccess (msg) {alert(msg)}; 
function onError (msg) {alert(msg)}; 

// store your password in the Keychain 
new Keychain().setForKey(onSuccess, onError, key, servicename, value); 

// get your password from the Keychain 
new Keychain().getForKey(onSuccess, onError, key, servicename); 

// remove your password from the Keychain 
new Keychain().removeForKey(onSuccess, onError, key, servicename); 
+0

注意,跨应用程序安装钥匙串项目的持续性在iOS的10.3β相是简单地禁用,虽然已经恢复,苹果公司表示,这一功能是从来没有记录在案,并可能被关闭。我怀疑在iOS 11中包含[DeviceCheck](https://developer.apple.com/documentation/devicecheck)框架可能是未来版本中重新引入Keychain清除的一个步骤。 – Paulw11

+0

谢谢@ Paulw11。 – Maheshvirus

相关问题