简体   繁体   English

Settings.bundle限制

[英]Settings.bundle limitations

I've got an app that requires a password, which is set within the app itself. 我有一个需要密码的应用程序,该密码是在应用程序内部设置的。 However, once a password has been set, if the user forgets the password and needs to reset it, I thought we could reset the password in Settings.bundle and hoped that the device would prompt for a password in order to make such a change. 但是,一旦设置了密码,如果用户忘记了密码并需要重设密码,我想我们可以在Settings.bundle中重设密码,并希望设备会提示输入密码以进行更改。

The goal is so that only the owner of the device will be able to reset their password. 目的是使只有设备的所有者才能重设密码。 If someone else resets the password they'll be stuck without ability to access the app. 如果其他人重置了密码,他们将被卡住,无法访问该应用程序。

I've researched and found that buttons (like Safari's "Clear History" and "Clear Cache") cannot be used by 3rd party developers. 我研究发现,按钮(例如Safari的“清除历史记录”和“清除缓存”)不能被第三方开发人员使用。

I've created a Toggle Switch in Settings.bundle that starts at "Off" and is labeled "Reset Password." 我已经在Settings.bundle中创建了一个切换开关,该切换开关从“关闭”开始,并标记为“重置密码”。 When users toggle this on and return to the app, it prompts them to set up a new password. 当用户打开此按钮并返回到应用程序时,它会提示他们设置新密码。

However - I can't find a way to programmatically change the toggle in preferences back to "Off" at this point so the user isn't prompted to set up a new password every time they open the app from that point on unless they go back to settings and turn the toggle off. 但是-我目前无法找到一种方法来以编程方式将首选项切换更改回“关”,因此从该点开始每次打开应用程序时都不会提示用户设置新密码,除非他们进入返回设置并关闭切换开关。

I'm starting to think that this isn't possible at all. 我开始认为这根本不可能。 Does anybody know more that can chime in? 有人知道更多可以鸣叫的声音吗?

Second part of the question is whether there is a way to require users to enter their device password in order to make a change? 问题的第二部分是是否有一种方法可以要求用户输入设备密码才能进行更改? If there is a way to prompt for the device password I will be able to use that as the security measure to allow them to reset their password. 如果有提示输入设备密码的方法,我将能够使用它作为安全措施以允许他们重置密码。

Thank you all so much in advance for your help! 预先非常感谢您的帮助!

The data stored in the app's settings is available through NSUserDefaults. 应用程序设置中存储的数据可通过NSUserDefaults获得。 You can get the state of a ToggleSwitch using the boolForKey: method passing the switch's Identifier as parameter. 您可以使用boolForKey:方法来获取ToggleSwitch的状态,该方法将开关的标识符作为参数传递。 You can also set its state using the setBool:forKey method. 您也可以使用setBool:forKey方法设置其状态。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM