Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDK-5238 Delayed init android docs #8397

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,7 @@ Braze will now be able to collect [specified data from your application]({{site.

Visit the following articles in order to enable [custom event tracking]({{site.baseurl}}/developer_guide/platform_integration_guides/android/analytics/tracking_custom_events/), [push messaging]({{site.baseurl}}/developer_guide/platform_integration_guides/android/push_notifications/android/integration/standard_integration/), [Content Cards]({{site.baseurl}}/developer_guide/platform_integration_guides/android/content_cards/integration/) and the complete suite of Braze features.

{% alert warning %}
If your app requires additional setup before SDK initialization—such as fetching configuration data from a server or waiting for user consent—see [Delayed Initialization]({{site.baseurl}}/developer_guide/platform_integration_guides/android/initialization/delayed_initialization/).
{% endalert %}

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
nav_title: Initialization
page_order: 0.2
config_only: true
noindex: true
layout: blank_config
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
---
nav_title: Delayed Initialization
article_title: Delayed Initialization for Android and FireOS
platform:
- Android
- FireOS
page_order: 0
description: "This article covers how to implement delayed initialization on the Android SDK and optionally preserve push notification analytics when delayed initialization is enabled."

---

# Delayed initialization for the Braze Android SDK

> Learn how to enable delayed initialization and opt in to preserve push notification analytics when it is enabled. This can be useful when you need to set up other services before initializing the SDK, such as fetching configuration data from a server or waiting for user consent.

{% alert note %}
While delayed initialization is enabled, all network connections will be canceled, and the Braze SDK will not pass any data to Braze servers.
{% endalert %}

## Prerequisites

To use this feature, you'll need to Braze Android SDK version XXXX or later.

## Enabling delayed initialization

Delayed initialization is disabled by default. To enable, use one of the following options:

{% tabs %}
{% tab Braze XML file %}
In your project's `braze.xml` file, set `com_braze_enable_delayed_initialization` to `true`.

```xml
<bool name="com_braze_enable_delayed_initialization">true</bool>
```
{% endtab %}

{% tab At runtime %}
To enable delayed initialization at runtime, use the following method.

{% subtabs %}
{% subtab JAVA %}

```java
Braze.enableDelayedInitialization(context);
```

{% endsubtab %}
{% subtab KOTLIN %}

```kotlin
Braze.enableDelayedInitialization(context)
```

{% endsubtab %}
{% endsubtabs %}
{% endtab %}
{% endtabs %}

## Configuring push analytics

When delayed initialization is enabled, push analytics are queued by default. However, you can choose to explicitly queue or drop push analytics instead.

### Explicitly queue

To explicitly queue push analytics, choose one of the following options:

{% tabs %}
{% tab Braze XML file %}
In your `braze.xml` file, set `com_braze_delayed_initialization_analytics_behavior` to `QUEUE`:

```xml
<string name="com_braze_delayed_initialization_analytics_behavior">QUEUE</string>
```
{% endtab %}

{% tab At runtime %}
Add `QUEUE` to your [`Braze.enableDelayedInitialization()`](LINK) method:

{% subtabs %}
{% subtab JAVA %}

```java
Braze.enableDelayedInitialization(context, DelayedInitializationAnalyticsBehavior.QUEUE);
```

{% endsubtab %}
{% subtab KOTLIN %}

```kotlin
Braze.enableDelayedInitialization(context, DelayedInitializationAnalyticsBehavior.QUEUE)
```

{% endsubtab %}
{% endsubtabs %}
{% endtab %}
{% endtabs %}

### Drop

To drop push analytics, choose one of the following options:

{% tabs %}
{% tab Braze XML file %}
In your `braze.xml` file, set `com_braze_delayed_initialization_analytics_behavior` to `DROP`:

```xml
<string name="com_braze_delayed_initialization_analytics_behavior">DROP</string>
```
{% endtab %}

{% tab At runtime %}
Add `DROP` to [`Braze.enableDelayedInitialization()`](LINK) method:

{% subtabs %}
{% subtab JAVA %}

```java
Braze.enableDelayedInitialization(context, DelayedInitializationAnalyticsBehavior.DROP);
```

{% endsubtab %}
{% subtab KOTLIN %}

```kotlin
Braze.enableDelayedInitialization(context, DelayedInitializationAnalyticsBehavior.DROP)
```

{% endsubtab %}
{% endsubtabs %}
{% endtab %}
{% endtabs %}

## Initializing after the delay

To initialize the SDK after your chosen delay period, use the [`Braze.disableDelayedInitialization()`](LINK) method:

{% tabs local %}
{% tab JAVA %}

```java
Braze.disableDelayedInitialization(context);
```

{% endtab %}
{% tab KOTLIN %}

```kotlin
Braze.disableDelayedInitialization(context)
```

{% endtab %}
{% endtabs %}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ article_title: Google Tag Manager for Android for Android and FireOS
platform:
- Android
- FireOS
page_order: 8
page_order: 1
description: "This reference article covers how to initialize, configure, and implement the Google Tag manager into your Android or FireOS app."

---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ article_title: Runtime Configuration for Android and FireOS
platform:
- Android
- FireOS
page_order: 4
page_order: 10
description: "This reference article covers how to set up runtime configuration for your Android or FireOS application."

---
Expand Down
3 changes: 3 additions & 0 deletions assets/js/broken_redirect_list.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.