TouchID error Code: -1004 NSLocalizedDescription: User interaction is required

自古美人都是妖i 提交于 2019-12-06 14:00:23

This happens on iOS 10 even when your application is in the foreground. As mentioned by Android Noob in one of the comments.

I did further investigation and found that it happens when you have multiple apps with the same product/executable name.

In my scenario I had 3 versions of the same app(code) with different bundle identifiers and display names. Only one of them, the last one that was installed, worked with Touch ID. The others returned the 'User interaction required error'.

Regarding the OP's issue. It is likely that the testers have another app with the same executable name installed on their devices. This could be another version of your app or another developer's app.

To circumvent the issue, change your executable or product name: Targets -> [Your Target Name] -> Build Settings -> Packaging -> Product Name

My tests and findings:

Given 3 apps with same code and product name but different bundle ids and display names: CI, UAT and Prod.

Install CI:

  • CI - Touch ID works

Install UAT:

  • UAT - Touch ID works
  • CI - Touch ID fails with 'User interaction required' error

Install Prod:

  • Prod - Touch ID works
  • UAT - Touch ID fails with 'User interaction required' error
  • CI - Touch ID fails with 'User interaction required' error

Uninstall Prod:

  • UAT - Touch ID works (but seems to have lost context because it does not display the app name)
  • CI - Touch ID works (but seems to have lost context because it does not display the app name)

Uninstall UAT and CI, reinstall CI:

  • CI - Touch ID works

Change UAT product name and install UAT:

  • CI - Touch ID works
  • UAT - Touch ID works
D4ttatraya

Check out this SO post regarding the same issue.

The answer says that

Basically this error happens when your app is woken up from background and somewhere on your code you are asking for Touch ID (my case is the local authentication type, I haven't tested with the keychain type). There's no way the user can interact with Touch ID prompted while the app is running on background, hence the error message.

If this same case is happening with you also, you need to add some logic in following AppDelegate method:

- (void)applicationWillEnterForeground:(UIApplication *)application
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!