我尝试在没有iPhone的watchOS应用上使用Apple登录实现身份验证。
import AuthenticationServices
class InterfaceController: WKInterfaceController {
@IBOutlet weak var signInBtn: WKInterfaceAuthorizationAppleIDButton!
@IBAction func signInWithAppleTapped() {
let appleIDProvider = ASAuthorizationAppleIDProvider()
let request = appleIDProvider.createRequest()
request.requestedScopes = [.email, .fullName]
let authController = ASAuthorizationController(authorizationRequests: [request])
authController.delegate = self
authController.performRequests()
}
点击模拟器上的登录按钮后,我看到以下内容:
创建密码以继续 为此Apple Watch创建密码,以便使用您的Apple ID登录应用。
密码已添加到设置中。我想念什么?
答案 0 :(得分:1)
这只是Apple Watch用户的要求,即他们的设备必须具有密码才能使用Apple登录。将您的Apple Watch设置为方案来运行您的应用程序应该可以对其进行测试。如果您的物理设备上没有密码,则可以在watchOS的“设置”应用中设置一个密码。