Skip to main content

Overview

This guide shows you how to integrate the MetaMap SDK into your Objective-C-based iOS application using the MetaMapButton component.

Prerequisites

  • MetaMap SDK installed via CocoaPods
  • iOS 13.0 or later
  • Xcode with Objective-C support

Implementation

Complete Objective-C Example

Here’s a complete implementation of MetaMap verification in Objective-C:

Step-by-Step Implementation

1. Import MetaMap SDK

Add the import statement to your view controller header or implementation file:

2. Declare Protocol Conformance

In your interface, declare that your view controller conforms to MetaMapButtonResultDelegate:

3. Initialize MetaMapButton

In your viewDidLoad method, initialize the button:

4. Add Button Action

Connect the button to an action handler:

5. Configure Button Layout

Set the button’s frame and add it to your view:

6. Set Delegate

Assign the delegate to receive verification results:

7. Launch Verification Flow

Implement the button action method to launch the verification flow:

Handling Results

Implement the MetaMapButtonResultDelegate protocol methods to handle verification results:

Success Callback

Cancellation Callback

Swift vs Objective-C Comparison

Parameters

showMetaMapFlowWithClientId Parameters

Metadata Dictionary

The metadata parameter accepts an NSDictionary with optional customization values:

Best Practices

  1. Memory Management: Use strong property attribute for the metaMapButton property
  2. Delegate Lifecycle: Set the delegate in viewDidLoad and clear it in dealloc if needed
  3. Button Positioning: Consider using Auto Layout constraints instead of manual frame calculations
  4. Error Handling: Always implement both delegate methods to handle success and cancellation

Next Steps