Android

When using the React Native SDK, Live Activities can be managed in two different ways:

  1. Typescript API (React Native layer) – Allows you to log in/out of Live Activities, retrieve enabled activities, subscribe to them, and manage topics directly from JavaScript.
  2. Native Android integration – Gives you full access to Live Activities APIs from native Android code. See the Native Android Live Activities Integration guide for details.

Both options are fully compatible and can be used independently or in combination, depending on your project’s requirements and development workflow.

Typescript API Reference

All methods return results asynchronously through callbacks.

Log In

Registers the device in Live Activities with an externalCode provided by your backend.

LiveActivity.logIn(
  "user_identifier",
  (deviceData) => {
    console.log("Successfully logged in:", deviceData);
  },
  (error) => {
    console.error("Error logging in:", error);
  }
);


Log Out

Unregisters the device from Live Activities.

LiveActivity.logOut(
  (deviceData) => {
    console.log("Successfully logged out:", deviceData);
  },
  (error) => {
    console.error("Error logging out:", error);
  }
);


⚠️

Warning: The topics used for Live Activities are not the same as those used for the push notification service. Make sure to configure and subscribe to the correct topics so Live Activities work independently.

List Subscribed Topics

Retrieves a list of topics to which the device is currently subscribed.

LiveActivity.topicList(
  (topics) => {
    console.log("Available topics:", topics);
  },
  (error) => {
    console.error("Error retrieving topics:", error);
  }
);



Subscribe to Topics

Adds the device to one or more topics.

LiveActivity.subscribeToTopic(
  { topic: "live_activity_topic" },
  (topicData) => {
    console.log("Subscribed to topic:", topicData);
  },
  (error) => {
    console.error("Error subscribing to topic:", error);
  }
);


Unsubscribe from Topics

Removes the device from one or more topics

LiveActivity.unsubscribeToTopic(
  { topic: "live_activity_topic" },
  (topicData) => {
    console.log("Unsubscribed from topic:", topicData);
  },
  (error) => {
    console.error("Error unsubscribing from topic:", error);
  }
);



Push Reception Callback

Registers a callback to handle incoming push notifications, including Live Activity events.

import { NativeEventEmitter } from 'react-native';
import IndigitallReactNative, { Indigitall } from 'indigitall-react-native-plugin';

const eventEmitter = new NativeEventEmitter(IndigitallReactNative);

eventEmitter.addListener('onMessageReceived', async (event) => {
  
});


Typical Workflow in React-native

  1. Log in the device with an externalCode.
  2. Subscribe to the topics representing the Live Activities you want to track.
  3. Listen for push notifications via onMessageReceived and update your UI accordingly.
  4. Unsubscribe or log out when the Live Activity ends or the user session changes.

Example: Full Live Activities Workflow in React Native Example (TypeScript)

import { NativeEventEmitter } from 'react-native';
import IndigitallReactNative, { LiveActivity } from 'indigitall-react-native-plugin';

// 1. Log in the device with an externalCode
LiveActivity.logIn(
  "yourExternalCode",
  (deviceId: string) => {
    console.log("Device registered:", deviceId);

    // 2. Subscribe to desired topics after login
    const topicsToSubscribe = ["order_123", "match_live"];
    LiveActivity.subscribeToTopic(
      { topic: topicsToSubscribe[0] },
      (success) => {
        console.log(`Successfully subscribed to ${topicsToSubscribe[0]}:`, success);
      },
      (error) => {
        console.error("Subscribe error:", error);
      }
    );

    LiveActivity.subscribeToTopic(
      { topic: topicsToSubscribe[1] },
      (success) => {
        console.log(`Successfully subscribed to ${topicsToSubscribe[1]}:`, success);
      },
      (error) => {
        console.error("Subscribe error:", error);
      }
    );
  },
  (error) => {
    console.error("Login error:", error);
  }
);

// ⚠ Warning: These topics are not the same topics used for the push notification service.

// 3. Listen for push notifications
const eventEmitter = new NativeEventEmitter(IndigitallReactNative);
eventEmitter.addListener('onMessageReceived', async (event: any) => {
  console.log("Push received:", event);

  // Optional: Check if push is from Indigitall
  IndigitallReactNative.isIndigitallPushNotification(
    event,
    async (isIndigitall: boolean) => {
      console.log("Is Indigitall push:", isIndigitall);

      // Example handling based on Live Activity event type
      if (event.pushType === "LIVE_ACTIVITY") {
        if (event.liveActivityEventType === "START") {
          console.log("Live Activity started:", event);
        } else if (event.liveActivityEventType === "UPDATE") {
          console.log("Live Activity updated:", event);
        } else if (event.liveActivityEventType === "END") {
          console.log("Live Activity ended:", event);
        }
      }
    },
    (error: any) => {
      console.error("Push reception error:", error);
    }
  );
});