screen()
The screen() method records a screen view event. It is the mobile equivalent of the web SDK’s page() method.
Syntax
iOS (Swift)
Datafly.shared.screen(_ name: String, properties: [String: Any]? = nil)Android (Kotlin)
Datafly.screen(name: String, properties: Map<String, Any>? = null)React Native / Cordova
DataflySignal.screen(name, properties?)Flutter
await DataflySignal.screen(name, properties: {...})Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
name | String | Yes | The name of the screen (e.g., "Product Detail") |
properties | Dictionary/Map | No | Additional properties describing the screen |
Basic usage
// iOS
Datafly.shared.screen("Home")
// Android
Datafly.screen("Home")
// React Native
DataflySignal.screen("Home");With properties
Datafly.shared.screen("Product Detail", properties: [
"item_id": "SKU-001",
"item_name": "Running Shoes",
"category": "Footwear",
])Automatic screen tracking
Unlike the web SDK which auto-detects page loads, mobile screen views must be tracked explicitly. Integrate with your navigation framework:
SwiftUI
struct ProductView: View {
var body: some View {
VStack {
// content
}
.onAppear {
Datafly.shared.screen("Product Detail", properties: [
"item_id": product.id
])
}
}
}UIKit
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
Datafly.shared.screen("Product Detail")
}Android (Activity/Fragment)
override fun onResume() {
super.onResume()
Datafly.screen("Product Detail")
}Jetpack Compose
@Composable
fun ProductScreen() {
LaunchedEffect(Unit) {
Datafly.screen("Product Detail")
}
// content
}Event payload
A screen() call produces an event with type: "screen":
{
"type": "screen",
"event": "Product Detail",
"anonymousId": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
"properties": {
"item_id": "SKU-001",
"item_name": "Running Shoes"
},
"context": {
"device": { "manufacturer": "Samsung", "model": "SM-G990B", "os": "Android", "os_version": "14" },
"session": { "id": 1712498234567, "number": 1, "is_new": true },
"library": { "name": "@datafly/android", "version": "1.0.0" }
},
"timestamp": "2026-04-06T14:22:00.000Z",
"messageId": "df-c3d4e5f6-a7b8-4c9d-0e1f-2a3b4c5d6e7f"
}Screen events are sent to the /v1/s endpoint on the Ingestion Gateway (separate from the web SDK’s /v1/p page endpoint). They are processed identically through the pipeline and delivered to vendors as screen/page view events.