iOS Native

Learn how to

  1. Add iOS Viewer library to your project

  2. Connect to the server, open iOS viewer, and load an e-Form in your storyboard.

  3. Trigger the e-Form submit button from an action button

Preparations

Required skills/experiences

  • iOS native App development experience with Xcode

XCode

  • Here we use Xcode ver. 12.1

OZ products

  • e-Form Server installed on the WAS server

  • iOS Viewer library

    Download ozrv80_ios_version.number.tar.gz from 👉 Product Downloads

Sample project

Create a new iOS App project ("app") with Objective-C and Storyboard.

Add iOS viewer library to the project

  1. Create a folder (ex: ozviewer) under your project folder.

  2. Add the license file to ozviewer (Your instructor will provide the license file).

  3. Copy custom_ui and Framework folder into ozviewer from extracted files.

  4. Remove the Device folder from Framework (We will run the app on the simulator).

    If you want to run the app on your device, remove the Framework folder.

  5. Remove the optional folder from Simulator ( We don't need optional features for now).

  6. Right-click your project folder > Add Files to "app" > select the ozviewer folder > Add

  7. Right-click the target, go to the Build Phases tab, and add more libraries and frameworks:

    libc++.tbd libxml2.tbd libiconv.tbd UIKit.framework Foundation.framework CoreText.framework CoreGraphics.framework

  8. And in the Copy Files, add the OZRViewer.framework.

Storyboard

Add a view for OZ viewer

Add a button for Submit

ViewController.h

//  ViewController.h
//  app
//
//  Created by John Kim on 2021/10/27.
//
 
#import <UIKit/UIKit.h>
#import <OZRViewer/OZReportViewer.h>
@interface ViewController : UIViewController <OZReportCommandListener> {
}
@property (weak, nonatomic) IBOutlet UIButton *SubmitBtn;
@property (nonatomic, retain) OZReportViewer* viewer;
@property (nonatomic, retain) IBOutlet UIView *OZViewer;
@end

ViewerController.m

//  ViewController.m
//  app
//
//  Created by John Kim on 2021/10/27.
//
 
#import "ViewController.h"
#import <OZRViewer/OZReportAPI.h>
 
@interface ViewController ()
 
@end
 
@implementation ViewController
@synthesize viewer, OZViewer;
 
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
 
    [self performSelector:@selector(createViewer) withObject:nil afterDelay:0.1];
 
}
 
-(void)createViewer{
    NSString* ozserverUrl = @"http://oz.ozeform.io/oz/server";
    NSString* ozrFileName = @"demo/customer.ozr";
 
    NSString* paramStr = [NSString stringWithFormat:@"connection.servlet=%@\n", ozserverUrl];
    paramStr = [NSString stringWithFormat:@"%@connection.reportname=%@", paramStr, ozrFileName];
 
    OZReportViewer* newViewer = [OZReportAPI createViewer:self view:self.OZViewer listener:self param:paramStr closeButton:nil];
    self.viewer = newViewer;
}
 
- (IBAction)Submit:(id)sender {
    NSString* validity = [self.viewer GetInformation:@"INPUT_CHECK_VALIDITY"];
    if ([validity isEqualToString:@"valid"]) {
        NSString* inputData = [self.viewer GetInformation:@"INPUT_JSON_ALL"];
        UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Input data" message:inputData preferredStyle:UIAlertControllerStyleAlert];
        UIAlertAction *closeAction = [UIAlertAction actionWithTitle:@"Close" style:UIAlertActionStyleCancel handler:nil];
        [alert addAction:closeAction];
        [self presentViewController:alert animated:YES completion:nil];
    }
}
 
@end

Info.plist

App Transport Security Settings > Allow Arbitrary Loads > YES

Run the app

Last updated

Was this helpful?