iOS

Overview


live activities

Live Activities allow your app to display real-time, glanceable updates on the Lock Screen and Dynamic Island (on supported iPhone models). This feature helps users stay informed about ongoing events—such as delivery progress, timers, or scores—without needing to open the app.

Our SDK simplifies the integration of Live Activities by managing setup, lifecycle management, and updates. With just a few lines of code, you can start, update, and end activities seamlessly.

Use cases include tracking orders, workouts, media playback, or any live process. Live Activities enhance user engagement by keeping key information always visible and up to date.

This functionality is available on iOS 16.1 and later.

Note: Starting with iOS 17, Live Activities have new behaviors and interaction capabilities, including support for standby mode and enhanced Dynamic Island experiences.

Limitations

  • Currently, bulk delivery is supported only on devices running iOS 18 or later.
  • A maximum of 10 iOSClass entries can be created.
  • Up to 5 Live Activities can be active (on the Lock Screen) per device and application.
  • Each application can have up to 10,000 active channels.

Integration

Live Activities on iOS with the Ionic Capacitor SDK

When using the Ionic Capacitor SDK, Live Activities can be managed in two different ways:

  1. TypeScript API ( Ionic Capacitor layer) – Allows you to retrieve active Live Activities, subscribe them to the backend, and listen for push updates directly from TypeScript.
  2. Native iOS integration – Gives you full access to Live Activities APIs, including push token generation and updates. See the Native iOS Live Activities Integration guide for detailed instructions.

⚠️

Note: Push token generation (PushToStart and PushTokenUpdates) cannot be triggered from Ionic Capacitor. This must be implemented in the native iOS layer, which then sends tokens to your backend for targeting Live Activities.

TypeScript API Reference

All methods return results asynchronously through callbacks. Let's do this example code and reference with the attribute name: TimerWidgetAttributes.

Get List of Active Live Activities

Retrieves all active Live Activities currently associated with the device.

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

LiveActivity.getListEnabledLiveActivities(
  (liveActivities) => {
    console.log("Active Live Activities:", liveActivities);
  },
  (error) => {
    console.error("Error fetching live activities:", error);
  }
);

 

Subscribe to Live Activities

Sends a list of Live Activities the device is subscribed to, so the backend can target them with push updates.

const activities = [
  { liveActivityExternalId: "order_123", iosAttributesType: "TimerWidgetAttributes" }
];

LiveActivity.subscribeToLiveActivities(
  { activities },
  (result) => {
    console.log("Successfully registered live activities:", result);
  },
  (error) => {
    console.error("Error subscribing to live activities:", error);
  }
);

 

Set PushToStart Token Updates

Native-only limitation: The actual token retrieval must be done in iOS native code, then passed to this method.

const tokenParams = {
  token: "hexadecimal_push_to_start_token",
  iosAttributesType: "TimerWidgetAttributes"
};

LiveActivity.setPushToStartTokenUpdates(
  tokenParams,
  (response) => {
    console.log("PushToStart token sent successfully:", response);
  },
  (error) => {
    console.error("Error sending PushToStart token:", error);
  }
);

 

Set Push Token Updates

Updates the push token for an already running Live Activity.

const tokenUpdateParams = {
  token: "hexadecimal_push_token",
  liveActivityExternalId: "order_123"
};

LiveActivity.setPushTokenUpdates(
  tokenUpdateParams,
  (response) => {
    console.log("Push token update sent successfully:", response);
  },
  (error) => {
    console.error("Error updating push token:", error);
  }
);

 

Push Reception Callback

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

import { Indigitall } from 'indigitall-capacitor-plugin';

Indigitall.onMessageReceived(async (data) => {
  console.log("Push received:", JSON.stringify(data));

  Indigitall.isIndigitallPushNotification(
    data,
    async () => {
      console.log("Push is from Indigitall");
      // You can show alerts, update UI, etc.
      // await Alert.showAlert('Push indigitall', 'True');
    },
    async (error) => {
      console.error("Not an Indigitall push:", error);
      // await Alert.showAlert('Not Indigitall push', error.message);
    }
  );

});

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

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

// 1. Get current active Live Activities
LiveActivity.getListEnabledLiveActivities(
  (liveActivities) => {
    console.log("Active Live Activities:", liveActivities);

    // 2. Subscribe them to the backend
    LiveActivity.subscribeToLiveActivities(
      { activities: liveActivities },
      (result) => {
        console.log("Live activities subscribed successfully:", result);
      },
      (error) => {
        console.error("Subscription error:", error);
      }
    );
  },
  (error) => {
    console.error("Error fetching live activities:", error);
  }
);

// 3. Set PushToStart token (token must come from native iOS code)
const pushToStartParams = {
  token: "hexadecimal_push_to_start_token",
  iosAttributesType: "TimerWidgetAttributes"
};
LiveActivity.setPushToStartTokenUpdates(
  pushToStartParams,
  (response) => {
    console.log("PushToStart token sent:", response);
  },
  (error) => {
    console.error("Error sending PushToStart token:", error);
  }
);

// 4. Set Push token updates (token must come from native iOS code)
const pushTokenParams = {
  token: "hexadecimal_push_token",
  liveActivityExternalId: "order_123"
};
LiveActivity.setPushTokenUpdates(
  pushTokenParams,
  (response) => {
    console.log("Push token update sent:", response);
  },
  (error) => {
    console.error("Error updating push token:", error);
  }
);

// 5. Listen for push events
Indigitall.onMessageReceived(async (data) => {
  console.log("Push received:", JSON.stringify(data));

  if (data.pushType === "LIVE_ACTIVITY") {
    if (data.liveActivityEventType === "START") {
      console.log("Live Activity started:", data);
    } else if (data.liveActivityEventType === "UPDATE") {
      console.log("Live Activity updated:", data);
    } else if (data.liveActivityEventType === "END") {
      console.log("Live Activity ended:", data);
    }
  }

  Indigitall.isIndigitallPushNotification(
    data,
    async () => {
      console.log("Push is from Indigitall");
      // Aquí puedes mostrar alertas, actualizar UI, etc.
    },
    async (error) => {
      console.error("Not an Indigitall push:", error);
      // Aquí puedes mostrar alertas de error, etc.
    }
  );
});