iOS SDK Reference
iOS SDK Reference
Complete API reference for the Hood iOS SDK, including all classes, methods, and configuration options.
Overview
The Hood iOS SDK provides comprehensive APIs for implementing push notifications, in-app messaging, and analytics in your iOS applications.
Quick Navigation
API Classes
OcambaBuilder
Main builder class for initializing the Hood SDK.
let builder = OcambaBuilder(apiKey: "YOUR_API_KEY")
.push()
.analytics(true)
.build()
OcambaHoood
Core SDK class containing all main functionality.
OcambaHoood.registerToken(deviceToken)
OcambaHoood.track("event_name", "value")
Configuration
Basic Setup
import UIKit
import UserNotifications
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let builder = OcambaBuilder(apiKey: "YOUR_API_KEY")
.push()
.analytics(true)
.build()
OcambaHoood.initialize(config: builder)
return true
}
}
Push Notifications
// Register for push notifications
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
OcambaHoood.registerToken(deviceToken)
}
// Handle notification received
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {
OcambaHoood.didReciveAdministrativeNotificationWith(userInfo) { (geo, bcs) in
// Handle notification
}
}
Methods
Analytics
// Track custom events
OcambaHoood.track(["button_clicked": "value"])
// Send tracked data
OcambaHoood.sendTrack()
// Get tracked data
let data = OcambaHoood.getTrack()
// Get specific tracked value
let value = OcambaHoood.getTrackFor(key: "button_clicked")
// Remove tracked value
OcambaHoood.removeTrackFor(key: "button_clicked")
UTM Tracking
// Set UTM parameters
OcambaHoood.setUtm("source", "google")
OcambaHoood.setUtm("medium", "cpc")
// Get UTM parameter
let source = OcambaHoood.getUtm("source")
// Remove UTM parameter
OcambaHoood.removeUtm("source")
Scheduled Notifications
// Schedule notifications
let builder = OcambaBuilder(apiKey: "YOUR_API_KEY")
.scheduleNotificaitons(TimeInterval(3600)) // 1 hour
.build()
Notification Content
// Decrease notification count
OcambaHoood.decreseNotificationCount(forNotif: notificationContent)
// Add notification count
OcambaHoood.addNotificationCount(forNotif: notificationContent)
// Get notification content
let content = OcambaHoood.getNotificationContent(userInfo: userInfo)
Events
Notification Events
// Handle notification response
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
OcambaHoood.pushTrackOpen(true, response: response) { url in
// Handle notification click
}
completionHandler()
}
Error Handling
do {
let builder = OcambaBuilder(apiKey: "YOUR_API_KEY").build()
OcambaHoood.initialize(config: builder)
} catch {
print("OcambaHoood initialization failed: \(error)")
}
Requirements
- iOS 10.0+
- Xcode 12.0+
- Swift 5.0+
Troubleshooting
Common issues and solutions:
SDK Initialization Failed
- Check API key validity
- Verify bundle identifier
- Ensure proper permissions
Push Notifications Not Working
- Verify APNs certificate
- Check device token registration
- Test on physical device
Analytics Not Tracking
- Ensure analytics is enabled
- Check network connectivity
- Verify event parameters