0

in my ios application, I have implemented the zbar qr sdk code scanner into my application. The user scans a qr code, and the contents go to a text field(Non-Editable type).

What I was wondering, is there a way that I can make the app automatically opens safari (if qr code is a link), mail (if the qr code is an email), phone (if qr code is a phone #). If I did this, it would help the app become more automated and user friendly. Thanks.

Steve
  • 205
  • 3
  • 14

1 Answers1

1

In the reader's didFinishPickingMediaWithInfo method you can make decisions based on the data. Define how you identify each data type and use a switch statement:

switch(dataType) {

  case ISLINK: [[UIApplication sharedApplication] openURL:[NSURL URLfromString:parsedUrl]]; break;
  case ISEMAIL: [[UIApplication sharedApplication] openURL:[NSURL URLfromString:[NSString stringWithFormat:@"mailto:%@",parsedUrl]]];
  ...
}
Richard Brown
  • 11,346
  • 4
  • 32
  • 43
  • when i did that, it says "Use of undeclared identifier 'dataType'? – Steve Mar 13 '13 at 02:06
  • Don't take my snippet literally. YOU need to determine what kind of barcode it is and set `dataType`. Then you can use a switch to handle the appropriate action. – Richard Brown Mar 13 '13 at 02:11