Local Authentication & localized reason string

In a project I was using Local Authentication to authenticate a user. When I got a request to support smartcard/PIV token authentication (which Local Authentication does not support), I had to switch to Authorization Services, which works pretty. There's only one issue I have. Local Authentication's evaluatePolicy:localizedReason:reply: requires a reason in the form "<appname>" is trying to <localized reason>. The app is currently translated into 41 languages and I would like to use the localized strings for the AuthorizationEnvironment of Authorization Services as well. The problem is that Local Authentication prefixes the localized string with something like "<appname>" is trying to and Authorization Services does not do this. Is there a way to get this prefix from somewhere so I can manually add it to the (partially) localized string? Any help would be highly appreciated.

Thank you, Marc

I am not quite familiar with Local Authentication, but am interested in taking a look from the localization side. Would you mind to provide screenshots to show the issue?

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

Local Authorization's evaluatePolicy:localizedReason:reply: requires a partly localized reason, which is not ideal from a localization perspective. This is what the docs say:

Application reason for authentication. This string must be provided in correct localization and should be short and clear. It will be eventually displayed in the authentication dialog as a part of the following string: "<appname>" is trying to <localized reason>.

For example, if the app name is "TestApp" and localizedReason is passed "access the hidden records", then the authentication prompt will read: "TestApp" is trying to access the hidden records.

What I found out now is, that the complete strings look as follows:

Where the first placeholder contains the app name and the second placeholder contains the localized string the user provided. So I think I should be able to build the string I need.

Best regards, Marc

BTW: I had to upload the above list as an image because otherwise my post supposedly contained sensitive language. Very strange...

I’ll leave Ziqiao to look at your localisation issue, but I wanted to ask about this:

Written by marc_thielemann in 823662022
I had to upload the above list as an image because otherwise my post supposedly contained sensitive language. Very strange...

Sadly, it’s not that strange. The DevForums content filtering rules are… well… strange (-:

Do you still have the original text you were trying to post? If so, please file a bug against the forums, attaching your text file, and then post the bug number here. I’ll make sure that our forums platform folks see it.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Hi Quinn,

opened feedback FB16445453.

Best regards, Marc

Thanks for providing more context, @marc_thielemann.

The documentation you quoted is a bit different from what I see today from the API reference, where the discussion section reads:

In the localized string you present to the user in the authentication dialog, provide a clear reason for the authentication request, and describe the resulting action. Make the message short and clear, and provide it in the user’s language. Don’t include the app name, which already appears in the authentication dialog (in macOS, in the title of the dialog; in iOS, in the subtitle).

I guess it may be that the documentation was updated at some point. In any case, my read is that you just need to provide the localized reason, which shouldn't include the app name, and the system takes care the rest, including grabbing your app name and using it in the authentication dialog. I don't think you can change the behavior because:

  • On different platforms, the app name is presented in a different way. Concretely, it is "in macOS, in the title of the dialog; in iOS, in the subtitle."

  • The system determines the app name. This avoids the app passing something that is different from the app name and confusing the user.

Lastly, I am curious where you get the localized string keys, as shown in your screenshot. Did you grab it from somewhere in the sytem, or is it something you created for your app?

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

At least for macOS I can say that it still needs that substring. If you look at the APP_ASKING_AUTH keys in /System/Library/Frameworks/LocalAuthentication.framework/Support/coreautha.bundle/Contents/Resources/UIAgent.loctable you'll see exactly this and all my tests with the Local Authentication framework have also confirmed this.

Best regards, Marc

Local Authentication &amp; localized reason string
 
 
Q