UI警报搜索Firebase数据库

时间:2016-10-26 23:35:55

标签: ios swift firebase firebase-realtime-database

我正在创建一个iOS扫描程序应用程序,当用户点击搜索UI警报搜索功能以搜索Firebase数据库时,如果该对象存在于Firebase中,我就会陷入我想要的部分。

以下我的数据库中的代码是JSON格式:

// Get the metadata object.
    let metadataObj = metadataObjects[0] as! AVMetadataMachineReadableCodeObject

    if self.allowedTypes.contains(metadataObj.type) {

        // If the found metadata is equal to the QR code metadata then update the status label's text and set the bounds


        //This code vibrates the device to notify the user that there is a barcode!
        //AudioServicesPlaySystemSound(SystemSoundID(kSystemSoundID_Vibrate))


        let barCodeObject = videoPreviewLayer?.transformedMetadataObject(for: metadataObj as AVMetadataMachineReadableCodeObject) as! AVMetadataMachineReadableCodeObject

        qrCodeFrameView?.frame = barCodeObject.bounds;

        if metadataObj.stringValue != nil {

            let alert = UIAlertController(title: "Found a Barcode!", message: metadataObj.stringValue, preferredStyle: UIAlertControllerStyle.alert)

            let okAction = UIAlertAction(title: "Search", style: UIAlertActionStyle.default) { action in

                self.ref = FIRDatabase.database().reference()




                //(result : UIAlertAction) -> Void in
                //print("OK")
            }




          alert.addAction(okAction)
            present(alert, animated: true, completion: nil)
        }
        //AudioServicesDisposeSystemSoundID(SystemSoundID(kSystemSoundID_Vibrate))



    }
}

0 个答案:

没有答案