Overview
This guide shows you how to integrate the MetaMap SDK into your Objective-C-based iOS application using theMetaMapButton 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 toMetaMapButtonResultDelegate:
3. Initialize MetaMapButton
In yourviewDidLoad 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 theMetaMapButtonResultDelegate protocol methods to handle verification results:
Success Callback
Cancellation Callback
Swift vs Objective-C Comparison
- Swift
- Objective-C
Parameters
showMetaMapFlowWithClientId Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
clientId | NSString* | Yes | Your MetaMap client ID |
flowId | NSString* | Yes | The verification flow ID |
metadata | NSDictionary* | No | Additional metadata and customization options |
Metadata Dictionary
The metadata parameter accepts anNSDictionary with optional customization values:
Best Practices
- Memory Management: Use
strongproperty attribute for themetaMapButtonproperty - Delegate Lifecycle: Set the delegate in
viewDidLoadand clear it indeallocif needed - Button Positioning: Consider using Auto Layout constraints instead of manual frame calculations
- Error Handling: Always implement both delegate methods to handle success and cancellation
Next Steps
- Learn about UI Customization options
- Explore UIKit Integration for Swift
- See SwiftUI Integration