Installation

Following is a simple way to send data to Hardal.

// Simple Hardal track implementation with customizable URL and separate signalId
func sendHardalEvent(hardalCustomUrl: String, signalId: String, eventName: String, eventData: [String: Any] = [:]) {
    let url = URL(string: "https://\(hardalCustomUrl)/push/hardal")!
    var request = URLRequest(url: url)
    request.httpMethod = "POST"
    request.setValue("application/json", forHTTPHeaderField: "Content-Type")
    
    let body: [String: Any] = [
        "type": "event", // Must be provided
        "payload": [
            "name": eventName,
            "website": signalId, // Now using the separate signalId parameter
            "data": eventData 
        ]
    ]
    
    request.httpBody = try? JSONSerialization.data(withJSONObject: body)
    
    URLSession.shared.dataTask(with: request) { _, _, _ in }.resume()
}

Example Usage

The Hardal client allows you to send any custom data structure as part of your event payload. Here is an example

// Example usage
let customUrl = "example.usehardal.com"
let signalId = "cm5v9x9f80003tivvx7nr2bjh"
sendHardalEvent(hardalCustomUrl: customUrl, signalId: signalId, eventName: "purchase")

Troubleshooting

Validation

To validate your iOS integration:

  1. Use the debug console in Xcode
  2. Monitor network requests in the debug navigator
  3. Check for successful HTTP responses (200 status code)
  4. Verify events appear in your Hardal dashboard

Enable verbose logging in debug builds to get detailed information about event tracking and network requests.