public override QRType HandleQRCode(MediaQRContent mediaQRContent) { if (mediaQRContent != null) { try { NSUrl param = new NSUrl (mediaQRContent.Text); UIApplication.SharedApplication.InvokeOnMainThread (delegate { // UIApplication.SharedApplication.OpenUrl method must be called from UI main thread [AMOB-14] switch (mediaQRContent.QRType) { case QRType.EMAIL_ADDRESS: SystemLogger.Log (SystemLogger.Module.PLATFORM, "HandleQRCode - EMAIL_ADDRESS type"); if ((UIApplication.SharedApplication.CanOpenUrl (param)) && (MFMailComposeViewController.CanSendMail)) { UIApplication.SharedApplication.OpenUrl (param); } else { StartNotifyAlert ("Mail Alert", "Sending of mail messages is not enabled or supported on this device.", "OK"); } break; case QRType.TEL: SystemLogger.Log (SystemLogger.Module.PLATFORM, "HandleQRCode - TEL type"); if (UIApplication.SharedApplication.CanOpenUrl (param)) { UIApplication.SharedApplication.OpenUrl (param); } else { StartNotifyAlert ("Phone Alert", "Establishing voice calls is not enabled or supported on this device.", "OK"); } break; case QRType.URI: SystemLogger.Log (SystemLogger.Module.PLATFORM, "HandleQRCode - URI type"); if (UIApplication.SharedApplication.CanOpenUrl (param)) { UIApplication.SharedApplication.OpenUrl (param); } else { StartNotifyAlert ("Browser Alert", "The requested URL could not be automatically opened.", "OK"); } break; default: SystemLogger.Log (SystemLogger.Module.PLATFORM, "HandleQRCode - not maanged type"); StartNotifyAlert ("QR Alert", "The QR Code " + mediaQRContent.QRType.ToString() + " cannot be processed automatically.", "OK"); break; } }); } catch (Exception ex) { SystemLogger.Log (SystemLogger.Module.PLATFORM, "HandleQRCode - exception: " + ex.Message); StartNotifyAlert ("QR Alert", "The QR Code cannot be handled due to an unhandled exception (see log).", "OK"); } return mediaQRContent.QRType; } return QRType.TEXT; }
public override void DetectQRCode(bool autoHandleQR) { UIApplication.SharedApplication.InvokeOnMainThread (delegate { UIViewController viewController = UIApplication.SharedApplication.KeyWindow.RootViewController; MobileBarcodeScanner scanner = new MobileBarcodeScanner(viewController); scanner.Scan().ContinueWith(t => { MediaQRContent resultQRContent = null; if (t.Result != null){ resultQRContent = new MediaQRContent(t.Result.Text, ZxingToBarcode(t.Result.BarcodeFormat), getQRTypeFromCode(t.Result)); //SystemLogger.Log(SystemLogger.Module.PLATFORM, "QR CODE returnValue: " + resultQRContent); } UIApplication.SharedApplication.InvokeOnMainThread (delegate { FireUnityJavascriptEvent(viewController, "Appverse.Scanner.onQRCodeDetected", resultQRContent); if(autoHandleQR) HandleQRCode(resultQRContent); }); }); // TODO: check how to do this //IPhoneServiceLocator.CurrentDelegate.SetMainUIViewControllerAsTopController(false); }); }
private void AnalyzeImage(Bitmap bitmap, TimeSpan time) { if (!_qrDetectionModeEnabled) return; var result = _barcodeReader.Decode(bitmap.Buffers[0].Buffer.ToArray(), (int)bitmap.Buffers[0].Pitch, (int)bitmap.Dimensions.Height, RGBLuminanceSource.BitmapFormat.Gray8); Dispatcher.RunAsync(CoreDispatcherPriority.High, () => { if (result == null) { if (_scannerAutoFocus != null) _scannerAutoFocus.BarcodeFound = false; } else { if (_scannerAutoFocus != null) { _cameraCapture.Failed -= CameraCaptureOnFailed; _cameraCapture.ClearEffectsAsync(MediaStreamType.VideoPreview); _scannerAutoFocus.BarcodeFound = true; } var returnQR = new MediaQRContent(result.Text, WindowsPhoneUtils.ZxingToBarcode(result.BarcodeFormat), WindowsPhoneUtils.GetQRTypeFromCode(result)); _oReturnObject = new MainPageTransferObject { CallbackName = "Appverse.Scanner.onQRCodeDetected", JSONContent = JsonConvert.SerializeObject(returnQR) }; if (_qrAutoHandleQrCode) { var launchUri = Uri.IsWellFormedUriString(returnQR.Text, UriKind.RelativeOrAbsolute) ? new Uri(returnQR.Text) : null; var ignore = Launcher.LaunchUriAsync(launchUri).AsTask().Result; } _cameraCapture.ClearEffectsAsync(MediaStreamType.VideoPreview); HideCameraView(); } }); }
public abstract QRType HandleQRCode(MediaQRContent mediaQRContent);
public abstract Task GenerateQRCode(MediaQRContent content);
public abstract Task<QRType> HandleQRCode(MediaQRContent mediaQRContent);
public abstract void GenerateQRCode (MediaQRContent content);
public abstract QRType HandleQRCode (MediaQRContent mediaQRContent);