我需要一些帮助/朝正确的方向推进。我有一个使用Firebase的应用程序,目前可以使用它,以便用户可以注册并拥有uid和所有这些好东西。我想做的就是根据用户的uid为每个用户个人资料创建一个QR码,以便当某人扫描其特定QR码时,会将他们带到应用程序中的该特定用户个人资料。这可能吗?我将从何处着手解决这个问题。我对动态链接做了一些研究,但是没有大量的教程/帮助。
我在此处添加了有效的QR Code URL,只是不确定一旦有人读取了QR Code,如何显示特定的用户数据。
@IBOutlet weak var imgQRCode: UIImageView!
let uid = Auth.auth().currentUser?.uid
var qrcodeImage: CIImage!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
let qrString = "https://cardless-57619.firebaseio.com/userProfile/" + uid!
let data = qrString.data(using: String.Encoding.isoLatin1, allowLossyConversion: false)
let filter = CIFilter(name: "CIQRCodeGenerator")
filter!.setValue(data, forKey: "inputMessage")
filter!.setValue("Q", forKey: "inputCorrectionLevel")
qrcodeImage = filter?.outputImage
displayQRCodeImage()
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
func displayQRCodeImage() {
//let scaleX = imgQRCode.frame.size.width / qrcodeImage.extent(10).size.width
//let scaleY = imgQRCode.frame.size.height / qrcodeImage.extent(10).size.height
let transformedImage = qrcodeImage.transformed(by: CGAffineTransform(scaleX: 20, y: 20))
imgQRCode.image = UIImage(ciImage: transformedImage)
}
}