# Screen API in Mobile SDKs

<p>This guide explains how to use the <code>screen</code> API in the RudderStack <a href="https://www.rudderstack.com/docs/sources/event-streams/sdks/kotlin-sdk/" >Android (Kotlin)</a> and <a href="https://www.rudderstack.com/docs/sources/event-streams/sdks/swift-sdk/" >iOS (Swift)</a> SDKs.</p>
<!-- end-chunk -->
<!-- begin-chunk -->
<h2 id="overview">Overview</h2><p>The RudderStack Android (Kotlin) and iOS (Swift) SDKs provide a <a href="https://www.rudderstack.com/docs/event-spec/standard-events/screen/" ><code>screen</code></a> API that lets you record whenever your user views their mobile screen, along with any additional relevant information about the screen.</p>
<!-- end-chunk -->
<!-- begin-chunk -->
<h2 id="android-kotlin">Android (Kotlin)</h2><p>The <code>screen</code> method definition in the Android (Kotlin) SDK is as follows:</p>
<div class="rs-tabs">
	<div class="rs-tabs__list">
		<button type="button" class="rs-tabs__tab"
			id="tab-bcafed"
		
		>Default invocation</button>
		<button type="button" class="rs-tabs__tab"
			id="tab-cfbdae"
		
		>Alternate invocations</button>
	</div>
	
<div class="rs-tabs__panel" id="panel-bcafed">

<div class="rs-code">
  <div class="rs-code__head">kotlin<button class="rs-code__copy" type="button">
      
      Copy
    </button>
  </div>
  <div class="highlight"><pre class="chroma"><code class="language-kotlin" data-lang="kotlin">analytics.screen(
    screenName = &#34;&lt;name&gt;&#34;,
    category = &#34;&lt;category&gt;&#34;,
    properties = buildJsonObject {
        put(&#34;key&#34;, &#34;value&#34;)
    },
    options = RudderOption(),
)</code></pre></div>
</div>
<p>The corresponding Java snippet is shown below:</p>
<div class="rs-code">
  <div class="rs-code__head">java<button class="rs-code__copy" type="button">
      
      Copy
    </button>
  </div>
  <div class="highlight"><pre class="chroma"><code class="language-java" data-lang="java">HashMap&lt;String, Object&gt; properties = new HashMap&lt;&gt;();
properties.put(&#34;key&#34;, &#34;value&#34;);

analytics.screen(&#34;&lt;name&gt;&#34;, &#34;&lt;category&gt;&#34;, properties, new RudderOption());</code></pre></div>
</div>

</div>

<div class="rs-tabs__panel" id="panel-cfbdae" hidden>

<div class="rs-code">
  <div class="rs-code__head">kotlin<button class="rs-code__copy" type="button">
      
      Copy
    </button>
  </div>
  <div class="highlight"><pre class="chroma"><code class="language-kotlin" data-lang="kotlin">// Screen event with screen name
analytics.screen(screenName = &#34;Main Screen&#34;)

// Screen event with screen name and category
analytics.screen(screenName = &#34;Main Screen&#34;, category = &#34;Main&#34;)

// Screen event with screen name, category and properties
analytics.screen(
    screenName = &#34;Main Screen&#34;,
    category = &#34;Main&#34;,
    properties = buildJsonObject {
        put(&#34;key-1&#34;, &#34;value&#34;)
    }
)

// Screen event with screen name and properties
analytics.screen(
    screenName = &#34;Main Screen&#34;,
    properties = buildJsonObject {
        put(&#34;key-1&#34;, &#34;value&#34;)
    }
)

// Screen event with screen name, category, and options
analytics.screen(
    screenName = &#34;Main Screen&#34;,
    category = &#34;Main&#34;,
    options = RudderOption(
        customContext = buildJsonObject {
            put(&#34;key-1&#34;, &#34;value&#34;)
        },
        integrations = buildJsonObject {
            put(&#34;Amplitude&#34;, true)
            put(&#34;INTERCOM&#34;, buildJsonObject {
                put(&#34;field&#34;, &#34;value&#34;)
            })
        },
        externalIds = listOf(
            ExternalId(type = &#34;&lt;id_type&gt;&#34;, id = &#34;&lt;value&gt;&#34;),
        ),
    )
)</code></pre></div>
</div>

</div>

</div>

<!-- end-chunk -->
<!-- begin-chunk -->
<h3 id="method-signature-kotlin">Method signature</h3><p>The below table describes the <code>screen</code> method signature in detail:</p>
<table>
  <thead>
      <tr>
          <th>Field</th>
          <th>Data type</th>
          <th>Description</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><code>screenName</code></td>
          <td>String</td>
          <td>Name of the screen viewed by the user.</td>
      </tr>
      <tr>
          <td><code>category</code></td>
          <td>String</td>
          <td>Screen category.</td>
      </tr>
      <tr>
          <td><code>properties</code></td>
          <td>Properties</td>
          <td>Additional properties describing the screen to be sent along with the event.<br /><br /><strong>Note</strong>: The <code>properties</code> type in Java is <code>Map&lt;String, Object&gt;</code>.</td>
      </tr>
      <tr>
          <td><code>options</code></td>
          <td>RudderOption</td>
          <td>Additional event options.</td>
      </tr>
  </tbody>
</table>
<!-- end-chunk -->
<!-- begin-chunk -->
<h3 id="example-kotlin">Example</h3><p>A sample <code>screen</code> event sent from the Android (Kotlin) SDK is shown below:</p>
<div class="rs-tabs">
	<div class="rs-tabs__list">
		<button type="button" class="rs-tabs__tab"
			id="tab-dfeabc"
		
		>Kotlin</button>
		<button type="button" class="rs-tabs__tab"
			id="tab-fcdeab"
		
		>Java</button>
	</div>
	
<div class="rs-tabs__panel" id="panel-dfeabc">

<div class="rs-code">
  <div class="rs-code__head">kotlin<button class="rs-code__copy" type="button">
      
      Copy
    </button>
  </div>
  <div class="highlight"><pre class="chroma"><code class="language-kotlin" data-lang="kotlin">analytics.screen(
    screenName = &#34;Main Screen&#34;,
    category = &#34;Main&#34;,
    properties = buildJsonObject {
        put(&#34;type&#34;, &#34;application&#34;)
    },
    options = RudderOption(
        customContext = buildJsonObject {
            put(&#34;key&#34;, &#34;value&#34;)
        },
        integrations = buildJsonObject {
            put(&#34;Amplitude&#34;, true)
            put(&#34;INTERCOM&#34;, buildJsonObject {
                put(&#34;lookup&#34;, &#34;phone&#34;)
            })
        },
        externalIds = listOf(
            ExternalId(type = &#34;brazeExternalId&#34;, id = &#34;value1234&#34;),
        ),
    ),
)</code></pre></div>
</div>

</div>

<div class="rs-tabs__panel" id="panel-fcdeab" hidden>

<div class="rs-code">
  <div class="rs-code__head">java<button class="rs-code__copy" type="button">
      
      Copy
    </button>
  </div>
  <div class="highlight"><pre class="chroma"><code class="language-java" data-lang="java">HashMap&lt;String, Object&gt; properties = new HashMap&lt;&gt;();
properties.put(&#34;type&#34;, &#34;application&#34;);

Map&lt;String, Object&gt; customContext = new HashMap&lt;&gt;();
customContext.put(&#34;key&#34;, &#34;value&#34;);

Map&lt;String, Object&gt; nestedIntegrations = new HashMap&lt;&gt;();
nestedIntegrations.put(&#34;lookup&#34;, &#34;phone&#34;);
Map&lt;String, Object&gt; integrations = new HashMap&lt;&gt;();
integrations.put(&#34;Amplitude&#34;, true);
integrations.put(&#34;INTERCOM&#34;, nestedIntegrations);

List&lt;ExternalId&gt; externalIds = new ArrayList&lt;&gt;();
externalIds.add(new ExternalId(&#34;brazeExternalId&#34;, &#34;value1234&#34;));

RudderOption option = new RudderOptionBuilder()
    .setIntegrations(integrations)
    .setExternalId(externalIds)
    .setCustomContext(customContext)
    .build();

analytics.screen(&#34;Main Screen&#34;, &#34;Main&#34;, properties, option);</code></pre></div>
</div>

</div>

</div>

<!-- end-chunk -->
<!-- begin-chunk -->
<h2 id="ios-swift">iOS (Swift)</h2><p>The <code>screen</code> method definition in the iOS (Swift) SDK is as follows:</p>
<div class="rs-tabs">
	<div class="rs-tabs__list">
		<button type="button" class="rs-tabs__tab"
			id="tab-befcda"
		
		>Default invocation</button>
		<button type="button" class="rs-tabs__tab"
			id="tab-abfcde"
		
		>Alternate invocations</button>
	</div>
	
<div class="rs-tabs__panel" id="panel-befcda">

<div class="rs-code">
  <div class="rs-code__head">swift<button class="rs-code__copy" type="button">
      
      Copy
    </button>
  </div>
  <div class="highlight"><pre class="chroma"><code class="language-swift" data-lang="swift">analytics.screen(
    screenName: &#34;&lt;name&gt;&#34;,
    category: &#34;&lt;category&gt;&#34;,
    properties: [
        &#34;key&#34;: &#34;value&#34;
    ],
    options: RudderOption()
)</code></pre></div>
</div>
<blockquote class="warning">
  <div class="tip-quote">
    
    <div class="tip-text">Make sure to include the <code>import RudderStackAnalytics</code> statement before making the call.</div>
  </div>
</blockquote>
<p>The corresponding Objective-C snippet is shown below:</p>
<div class="rs-code">
  <div class="rs-code__head">objectivec<button class="rs-code__copy" type="button">
      
      Copy
    </button>
  </div>
  <div class="highlight"><pre class="chroma"><code class="language-objectivec" data-lang="objectivec">[analytics screen:@&#34;&lt;name&gt;&#34; category:@&#34;&lt;category&gt;&#34; properties:@{@&#34;key&#34;: @&#34;value&#34;} options:[[RSSOptionBuilder new] build]];</code></pre></div>
</div>
<html lang="en">
<blockquote class="info">
  <div class="tip-quote">
    
    <div class="tip-text"><code>RSSOptionBuilder</code> is an Objective-C–only helper class. It uses the builder pattern to create an <code>RSSOption</code> instance and lets you set custom context, configure integrations, and attach external IDs in a structured way.</div>
  </div>
</blockquote>
</html>

</div>

<div class="rs-tabs__panel" id="panel-abfcde" hidden>

<div class="rs-code">
  <div class="rs-code__head">swift<button class="rs-code__copy" type="button">
      
      Copy
    </button>
  </div>
  <div class="highlight"><pre class="chroma"><code class="language-swift" data-lang="swift">// Screen event with screen name
analytics.screen(screenName: &#34;Main Screen&#34;)

// Screen event with screen name and category
analytics.screen(screenName: &#34;Main Screen&#34;, category: &#34;Main&#34;)

// Screen event with screen name, category and properties
analytics.screen(
    screenName: &#34;Main Screen&#34;,
    category: &#34;Main&#34;,
    properties: [
        &#34;key-1&#34;: &#34;value-1&#34;
    ]
)

// Screen event with screen name and properties
analytics.screen(
    screenName: &#34;Main Screen&#34;,
    properties: [
        &#34;key-1&#34;: &#34;value-1&#34;
    ]
)

// Screen event with screen name, category, and options
analytics.screen(
    screenName: &#34;Main Screen&#34;,
    category: &#34;Main&#34;,
    properties: [
        &#34;key-1&#34;: &#34;value-1&#34;
    ],
    options: RudderOption(
        integrations: [
            &#34;Amplitude&#34;: true,
            &#34;INTERCOM&#34;: [
                &#34;lookup&#34;: &#34;phone&#34;
            ]
        ],
        customContext: [
            &#34;key-1&#34;: &#34;value-1&#34;
        ],
        externalIds: [
            ExternalId(type: &#34;brazeExternalId&#34;, id: &#34;value1234&#34;)
        ]
    )
)</code></pre></div>
</div>
<p>The corresponding Objective-C snippet is shown below:</p>
<div class="rs-code">
  <div class="rs-code__head">objectivec<button class="rs-code__copy" type="button">
      
      Copy
    </button>
  </div>
  <div class="highlight"><pre class="chroma"><code class="language-objectivec" data-lang="objectivec">// Screen event with screen name
[analytics screen:@&#34;Main Screen&#34;];

// Screen event with screen name and category
[analytics screen:@&#34;Main Screen&#34; category:@&#34;Main&#34;];

// Screen event with screen name, category and properties
[analytics screen:@&#34;Main Screen&#34;
         category:@&#34;Main&#34;
       properties:@{
           @&#34;key-1&#34;: @&#34;value-1&#34;
       }];

// Screen event with screen name and properties
[analytics screen:@&#34;Main Screen&#34;
       properties:@{
           @&#34;key-1&#34;: @&#34;value-1&#34;
       }];

// Screen event with screen name, category, and options
RSSOptionBuilder *optionBuilder = [[RSSOptionBuilder alloc] init];

[optionBuilder setCustomContext:@{
    @&#34;key-1&#34;: @&#34;value-1&#34;
}];

[optionBuilder setIntegrations:@{
    @&#34;Amplitude&#34;: @YES,
    @&#34;INTERCOM&#34;: @{
        @&#34;lookup&#34;: @&#34;phone&#34;
    }
}];

[optionBuilder setExternalIds:@[
    [[RSSExternalId alloc] initWithType:@&#34;brazeExternalId&#34; id:@&#34;value1234&#34;]
]];

[analytics screen:@&#34;Main Screen&#34;
         category:@&#34;Main&#34;
       properties:@{
           @&#34;key-1&#34;: @&#34;value-1&#34;
       }
         options:[optionBuilder build]];</code></pre></div>
</div>

</div>

</div>

<!-- end-chunk -->
<!-- begin-chunk -->
<h3 id="method-signature-swift">Method signature</h3><p>The below table describes the <code>screen</code> method signature in detail:</p>
<table>
  <thead>
      <tr>
          <th>Field</th>
          <th>Data type</th>
          <th>Description</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><code>screenName</code></td>
          <td>String</td>
          <td>Name of the screen viewed by the user.</td>
      </tr>
      <tr>
          <td><code>category</code></td>
          <td>String</td>
          <td>Screen category.</td>
      </tr>
      <tr>
          <td><code>properties</code></td>
          <td>Properties</td>
          <td>Additional properties describing the screen to be sent along with the event.</td>
      </tr>
      <tr>
          <td><code>options</code></td>
          <td>RudderOption</td>
          <td>Additional event options.</td>
      </tr>
  </tbody>
</table>
<!-- end-chunk -->
<!-- begin-chunk -->
<h3 id="example-swift">Example</h3><p>A sample <code>screen</code> event sent from the iOS (Swift) SDK is shown below:</p>
<div class="rs-tabs">
	<div class="rs-tabs__list">
		<button type="button" class="rs-tabs__tab"
			id="tab-dfaebc"
		
		>Swift</button>
		<button type="button" class="rs-tabs__tab"
			id="tab-dbfaec"
		
		>Objective-C</button>
	</div>
	
<div class="rs-tabs__panel" id="panel-dfaebc">

<div class="rs-code">
  <div class="rs-code__head">swift<button class="rs-code__copy" type="button">
      
      Copy
    </button>
  </div>
  <div class="highlight"><pre class="chroma"><code class="language-swift" data-lang="swift">analytics.screen(
    screenName: &#34;Main Screen&#34;,
    category: &#34;Main&#34;,
    properties: [
        &#34;key-1&#34;: &#34;value-1&#34;
    ],
    options: RudderOption(
        integrations: [
            &#34;Amplitude&#34;: true,
            &#34;INTERCOM&#34;: [
                &#34;lookup&#34;: &#34;phone&#34;
            ]
        ],
        customContext: [
            &#34;key-1&#34;: &#34;value-1&#34;
        ],
        externalIds: [
            ExternalId(type: &#34;brazeExternalId&#34;, id: &#34;value1234&#34;)
        ]
    )
)</code></pre></div>
</div>

</div>

<div class="rs-tabs__panel" id="panel-dbfaec" hidden>

<div class="rs-code">
  <div class="rs-code__head">objectivec<button class="rs-code__copy" type="button">
      
      Copy
    </button>
  </div>
  <div class="highlight"><pre class="chroma"><code class="language-objectivec" data-lang="objectivec">RSSOptionBuilder *optionBuilder = [[RSSOptionBuilder alloc] init];

[optionBuilder setCustomContext:@{
    @&#34;key-1&#34;: @&#34;value-1&#34;
}];

[optionBuilder setIntegrations:@{
    @&#34;Amplitude&#34;: @YES,
    @&#34;INTERCOM&#34;: @{
        @&#34;lookup&#34;: @&#34;phone&#34;
    }
}];

[optionBuilder setExternalIds:@[
    [[RSSExternalId alloc] initWithType:@&#34;brazeExternalId&#34; id:@&#34;value1234&#34;]
]];

[analytics screen:@&#34;Main Screen&#34;
         category:@&#34;Main&#34;
       properties:@{
           @&#34;key-1&#34;: @&#34;value-1&#34;
       }
         options:[optionBuilder build]];</code></pre></div>
</div>

</div>

</div>


