钥匙串无法在iOS上启动

时间:2019-06-22 01:56:16

标签: ios nativescript nativescript-vue

钥匙串不会在iOS上自动填写我的登录表单。

在xCode中,我将“钥匙串共享”设置为“开”,并且两个步骤旁边都带有复选标记:将“钥匙串共享”权利添加到您的权利文件中,并将“钥匙串共享”功能添加到您的App ID中。

              <TextField
                class="input"
                hint="Email"
                keyboardType="email"
                autocorrect="false"
                autocapitalizationType="none"
                v-model="user.email"
                returnKeyType="next"
                @returnPress="focusPassword"
                fontSize="18"
              />
              <StackLayout class="hr-light"/>
            </StackLayout>

            <StackLayout class="input-field" marginBottom="15">
              <TextField
                ref="password"
                class="input"
                hint="Password"
                secure="true"
                v-model="user.password"
                :returnKeyType="isLoggingIn ? 'done' : 'next'"
                fontSize="18"
              />
              <StackLayout class="hr-light"/>
            </StackLayout> 

我非常确定问题是我需要将textContentType设置为.username和.password,但是我不确定如何设置。

1 个答案:

答案 0 :(得分:0)

您将必须在nativeView上设置textContentType

loaded事件添加到TextField

      <TextField
            class="input"
            hint="Email"
            keyboardType="email"
            autocorrect="false"
            autocapitalizationType="none"
            v-model="user.email"
            returnKeyType="next"
            @loaded="onLoaded"
            @returnPress="focusPassword"
            fontSize="18"
          />

在nativeView上更新textContentType

onLoaded: function(args) {
  const textField = args.object;
  if (textField.ios) {
     textField.ios.textContentType = UITextContentTypeEmailAddress;
  }
}

textContentType应该是docs here中的值之一。

还要确保仅在iOS 11或更高版本上运行此代码。如果您支持iOS 10,则此行代码可能会引发异常。如果您支持iOS 10,则必须在if条件下检查平台版本。