Callback URL for iOS App

This page shows how to call Mocha barcode from your iOS code, and get a barcode back.

A simple iOS app example:

Your iOS application must have an URL Schemes defined: Example

Start mocha barcode with a call to function openURL with a parameter telling, where to return the barcode data.
- (IBAction) doit_action:(id)sender
    NSString *tmp2 = [NSString stringWithFormat:@"mochabarcode://CALLBACK=mochabarcodetest://"];
    NSURL *url = [NSURL URLWithString:tmp2];
    if (![[UIApplication sharedApplication] openURL:url]) {
       NSLog(@"doit failed");
To receive the barcode back, in the Appdelegate.m file define:
- (BOOL)application:(UIApplication *)app
            openURL:(NSURL *)url
            options:(NSDictionary<NSString *,
                     id> *)options
    if (!url) {  return NO; }
    NSString *URLString = [url absoluteString];
    NSLog(@"Url return %@",URLString);
    if (URLString != nil) {
        NSString * start =@"mochabarcodetest://?BARCODE=";
        if ([URLString hasPrefix:start] && [URLString length] > [start length]+1) {
            NSString *tt = [URLString substringFromIndex:[start length]];
            NSLog(@"result is %@",tt);
    return YES;