如何解决输入正确的密码后 SignInWithAppleButton 循环,按下后按钮最终变为灰色,并在不久后变回蓝色
我在尝试确定代码中可能丢失某些内容的位置时遇到了麻烦,任何地方都没有错误,import time
import datetime
import bme680
from as7262 import AS7262
from datetime import date
from openpyxl import load_workbook
from db import Example
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
# create a session for writing to your db
engine = create_engine('sqlite:///foo.db')
Session = sessionmaker(bind=engine)
session = Session()
as7262 = AS7262()
as7262.set_gain(1) # 1,3.7,16,64
as7262.set_integration_time(10) #1 to 255 x 2.8ms exposure
#mode 0 - bank 1 only continuous,mode 1 - bank 2 only continuous,mode 2 - both banks continuous,mode 3 - both banks single read
as7262.set_measurement_mode(2) #2 all colours continuous
as7262.set_illumination_led_current(12.5) #12.5mA 25mA 50mA 100mA
as7262.set_illumination_led(0)
sensor_bme680 = bme680.BME680()
try:
while True:
example_object = Example(
temperature = round(sensor_bme680.data.temperature,2),humidity = round(sensor_bme680.data.humidity,.
.
# you other attributes
.
.
today = date.today(),Now = datetime.datetime.Now().time())
# Inform the user!
print('Adding this data to the spreadsheet:')
print(today)
print(Now)
print('{}*C {}hPa {}% {}res microM microM microM microM microM microM'.format(example_object.temperature,example_object.pressure,example_object.humidity,example_object.gas_resistance,example_object.red_light,example_object.orange_light,example_object.yellow_light,example_object.green_light,example_object.blue_light,example_object.violet_light))
# Add object to database
session.add(example_object)
session.commit()
finally:
print('Goodbye!')
允许我输入密码,但是一旦我输入正确的密码,它就会循环并且实际上并没有登录用户。我目前使用的是 Xcode 12.5,已在模拟器手机上使用 Apple ID 登录并运行 iOS 14.5。我在特定的 SignInWithApple 按钮关闭处设置了断点,但 onCompletion 关闭未运行
这是我的 SignUpView 代码
SignInWithAppleButton
这是我的注册/登录(身份验证)模型代码,没有错误。所有这些代码都来自这个 YouTube 教程:https://www.youtube.com/watch?v=6bYMc2WUhwk 我已经观看了 6 次以上的视频,但仍然无法找到我的代码无法直接登录的原因
import SwiftUI
import AuthenticationServices
import Firebase
struct SignUpView: View {
@StateObject var loginData = Authentication()
var body: some View {
ZStack{
let backgroundColor: Color = Color.init(red: 0.332,green: 0.087,blue: 0.839)
backgroundColor.ignoresSafeArea(.all)
Text("Welcome to GiftMe! ").font(.title).fontWeight(.heavy).shadow(color: .black,radius: 10,x: 0.0,y: 0.0).position(x:200,y: 70).foregroundColor(.white)
Image("logo").clipShape(Ellipse())
.shadow(color: .black,radius: 10)
.animation(.easeIn(duration: 2.0)).position(x: 200.0,y: 250.0)
vstack(alignment: .center,spacing: 30){
Spacer()
// Apple Button
SignInWithAppleButton { (request) in
// requesting parameters from apple login
loginData.nonce = randomNonceString()
request.requestedScopes = [.email,.fullName]
request.nonce = sha256(loginData.nonce)
} onCompletion: { (result) in
// getting error or success
switch result{
case .success(let user):
print("success")
// Login w/ Firebase
guard let credential = user.credential as? ASAuthorizationAppleIDCredential else{
print("error w/ firebase")
return
}
loginData.authenticate(credential: credential)
case .failure(let error):
print(error.localizedDescription)
}
}.signInWithAppleButtonStyle(.white)
.frame(height: 55)
.clipShape(Capsule())
.padding(.horizontal,30)
Spacer()
}.offset(x: 0.0,y: 100.0).padding()
}.ignoresSafeArea()
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
SignUpView()
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。