Monetize your app with micro-tasks via the DataPoint iOS SDK.
Add the following to your Package.swift:
dependencies: [
.package(url: "https://github.com/trydatapoint/datapoint-ios-sdk.git", from: "1.1.0")
]Or in Xcode: File → Add Package Dependencies → Enter the repository URL.
import DataPointSDK
DataPoint.initialize(apiKey: "YOUR_API_KEY") { result in
switch result {
case .success:
print("SDK initialized")
case .failure(let error):
print("Failed: \(error)")
}
}DataPoint.setAppUserId("user123") { result in
// Handle result
}DataPoint.setListener(self)
DataPoint.showTasks(from: viewController)extension YourClass: DataPointListener {
func onTaskCompleted(_ payload: String?) {
// User completed a task
}
func onAdRequested() {
// Show an ad
}
func noTaskAvailable() {
// No tasks available
}
func onClosed() {
// Task screen closed
}
func onError(message: String, code: Int) {
// Handle error
}
// Optional: host app went to background / returned while the task UI was visible.
func onAppLifecycleEvent(_ state: DataPointAppLifecycleState) {
// .didEnterBackground or .willEnterForeground
}
}Task pages on DataPoint domains render inside the SDK's WKWebView. Anything else leaves it:
| The page does | Where it opens |
|---|---|
Link / redirect to a non-DataPoint http(s) host |
In-app SFSafariViewController |
target="_blank" link / window.open |
In-app browser (or the WebView, if the host is DataPoint) |
mailto: tel: itms-apps: … |
The app that handles that scheme |
javascript: file: data: about: |
Blocked |
The task screen stays presented underneath, so closing the browser returns the user to their task. If a task completes while the browser is open, the task screen is dismissed once the browser closes. Which target a task's CTA uses (in-app or external) is configured per job in DataPoint, not in your app.
- iOS 13.0+
- Swift 5.9+
Apache License 2.0 - see LICENSE for details.