Open saormart opened 7 years ago
Hello @erickdc , I'm migrating my app to native iOS platform (Swift), and I found a way to detect and handle if the user click outside of the popup button "Choose application" based on they SDK... so follow the code (in Swift language) that may can help you with this:
` func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
self.dismiss(animated: true) {
let image = info[UIImagePickerControllerOriginalImage]
let applications:[String] = CamScannerOpenAPIController.availableApplications() as! Array
let appNames: NSMutableArray = NSMutableArray()
for applictionStr in applications
{
let appName:String = self.formatAppName(inputName: applictionStr)
if appName != ""
{
appNames.add(appName)
}
}
if applications.count>0
{
let actionSheet = ISBlockActionSheet.init(title: "Choose application", cancelButtonTitle: "Cancel", cancel: {
//After pronpt to the user "Choose application", if the user click outside it, we can handle it in here:
/*Your code....*/
print("User has clicked outside the Popup button!")
}, destructiveButtonTitle: nil, destructiveBlock: {
}, otherButtonTitles: appNames as! [Any], otherButtonBlock: { (index) in
CamScannerOpenAPIController.send(image as! UIImage, toTargetApplication: applications[index], appKey: self.AppKey, subAppKey: "")
})
actionSheet?.show(in: self.view)
}else
{
let alertVW = UIAlertView.init(title: "", message: "You should install CamScanner First", delegate: nil, cancelButtonTitle: "OK")
alertVW.show()
}
}
} `
Or maybe instead of use the "ISBlockActionSheet.h and ISBlockActionSheet.m" that's deprecated, you may use the "ISBlockAlertView.h and ISBlockAlertView.m" from: https://github.com/IntSig/ISBlockActionSheet-ISBlockAlertView
and use this code:
`if applications.count>0
{
let alertView: ISBlockAlertView = ISBlockAlertView.init(title: "Choose application", message: "To digitalize the document:", cancelButtonTitle: "Cancel", cancel: {
//After pronpt to the user "Choose application", if the user click outside it, we can handle it in here:
//Clear image taken by the CamScanner:
self.imageView.image = nil
}, otherButtonTitles: appNames as! [Any], otherButtonBlock: { (index) in
CamScannerOpenAPIController.send(pImage, toTargetApplication: applications[index], appKey: self.AppKey, subAppKey: "")
})
alertView.show()
}else
{
//Show an Alert to the User:
let alert = UIAlertController(title: "Warning:", message: "You should install CamScanner First", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: NSLocalizedString("OK", comment: "You should install CamScanner First"), style: .default, handler: { _ in
}))
self.present(alert, animated: true, completion: nil)
}`
Hello Erick, I'm using the camscanner plugin, and I have the following situation: After the user take a picture that I'm calling the camscanner plugin, it's popup a message on iPad asking: "Choose application" "CamScanner HD Pro" which is the version I'm using. I'm wonder if there's a way to know if after call camscanner, and if the user click outside the popup message, that was let's say: "canceled" by the user or something like that! By the way, I don't receive any response back on Success or Error response! Thanks!