Functions that allow an Eitri-App to create and manage order tracking live notifications.

Live notifications display real-time order status updates on the lock screen and Dynamic Island, providing users with at-a-glance information about their order progress without opening the app.

Platform Support:

  • ✅ iOS 16.2 and later (implemented as Live Activities)
  • ❌ Android (not supported yet - coming soon)
  • ❌ iOS versions below 16.2 (not supported)

Important Notes:

  • Only one live notification per orderId can be active at a time

Methods

  • Checks if order tracking live notifications are supported on the current device.

    This method verifies:

    • Device is running iOS 16.2 or later
    • User has live notifications enabled in system settings
    • App has live notifications properly configured

    Platform Support: Returns false on Android and iOS < 16.2.

    Example:

    const modules = await Eitri.modules()
    const liveNotificationIsSupported = modules.orderStatusLiveNotification?.isSupported
    if (!liveNotificationIsSupported) return

    const supported = await liveNotificationIsSupported()
    if (!supported) {
    console.log("Live notifications not available on this device")
    // Fallback to push notifications or in-app updates
    }

    Returns Promise<boolean>

    Promise resolving to true if live notifications are available, false otherwise.

  • Starts a new order tracking live notification for the specified order.

    Creates a live notification (implemented as iOS Live Activity) that displays on the user's lock screen and Dynamic Island, showing real-time order status updates.

    Platform Support: iOS 16.2+ only. Throws error on other platforms.

    Important:

    • Only one live notification per orderId can be active
    • If a live notification already exists for the orderId, returns existing activity info
    • The notification persists across app restarts until explicitly ended

    Example:

    const modules = await Eitri.modules()
    const liveNotificationStart = modules.orderStatusLiveNotification?.start
    if (!liveNotificationStart) return

    try {
    const result = await liveNotificationStart({
    orderId: "12345",
    orderIdDisplayText: "Order #ORD-12345",
    storeName: "Test Store",
    status: {
    displayName: "Confirmed",
    icon: "checkmark.circle",
    progress: 0.25
    },
    message: "Your order has been confirmed",
    estimatedTime: "30 min"
    })
    console.log("Live notification started:", result.activityId)
    } catch (error) {
    console.error("Failed to start live notification:", error)
    }

    Parameters

    Returns Promise<StartLiveNotificationResult>

    Promise resolving to activity information including activityId and orderId

    Error if live notifications are not supported or if required parameters are missing

  • Updates an existing order tracking live notification with new status information.

    Updates the live notification on the user's lock screen and Dynamic Island with new order status, progress, message, and estimated time.

    Platform Support: iOS 16.2+ only. Throws error on other platforms.

    Update Methods:

    Live notifications can be updated in two ways:

    1. From the app - Using this method directly (as shown in examples below)
    2. From server - Using Apple Push Notification service (APNs)

    When a live notification is started, iOS registers a push token with APNs. Eitri server can use this token to send remote updates, allowing you to update the live notification even when the app is not running.

    Common Update Scenarios:

    • Order confirmed → Preparing
    • Preparing → Out for delivery
    • Out for delivery → Delivered

    Example (update to preparing):

    const modules = await Eitri.modules()
    const liveNotificationUpdate = modules.orderStatusLiveNotification?.update
    if (!liveNotificationUpdate) return

    try {
    await liveNotificationUpdate({
    orderId: "12345",
    status: {
    displayName: "Preparing",
    icon: "flame",
    progress: 0.5
    },
    message: "Your order is being prepared",
    estimatedTime: "25 min"
    })
    } catch (error) {
    console.error("Failed to update live notification:", error)
    }

    Example (update to out for delivery):

    const modules = await Eitri.modules()
    const liveNotificationUpdate = modules.orderStatusLiveNotification?.update
    if (!liveNotificationUpdate) return

    await liveNotificationUpdate({
    orderId: "12345",
    status: {
    displayName: "Out for delivery",
    icon: "truck.box",
    progress: 0.75
    },
    message: "Your order is on it's way",
    estimatedTime: "10 min"
    })

    Example (update to delivered):

    const modules = await Eitri.modules()
    const liveNotificationUpdate = modules.orderStatusLiveNotification?.update
    if (!liveNotificationUpdate) return

    await liveNotificationUpdate({
    orderId: "12345",
    status: {
    displayName: "Delivered",
    icon: "checkmark.circle.fill",
    progress: 1.0
    },
    message: "Your order has been delivered",
    })

    Parameters

    Returns Promise<void>

    Promise that resolves when the update is complete

    Error if the live notification for orderId doesn't exist or if platform is not supported

  • Ends a specific order tracking live notification.

    Dismisses the live notification from the user's lock screen and Dynamic Island. The notification is removed immediately.

    Platform Support: iOS 16.2+ only. Throws error on other platforms.

    Example:

    const modules = await Eitri.modules()
    const liveNotificationEnd = modules.orderStatusLiveNotification?.end
    if (!liveNotificationEnd) return

    try {
    await liveNotificationEnd({
    orderId: "12345"
    })
    console.log("Live notification ended successfully")
    } catch (error) {
    console.error("Failed to end live notification:", error)
    }

    Parameters

    Returns Promise<void>

    Promise that resolves when the live notification is dismissed

    Error if the live notification for orderId doesn't exist or if platform is not supported

  • Ends all active order tracking live notifications for the current user.

    Dismisses all live notifications associated with the app, regardless of order ID. Useful for cleanup operations like user logout.

    Platform Support: iOS 16.2+ only. No-op on other platforms.

    When to call:

    • User logs out
    • App needs to clear all notifications (e.g., account deletion)

    Example:

    // Clear all live notifications on logout
    async function handleLogout() {
    const modules = await Eitri.modules()
    const liveNotificationEndAll = modules.orderStatusLiveNotification?.endAll
    if (liveNotificationEndAll) {
    await liveNotificationEndAll()
    }
    // Continue with logout flow...
    }

    Returns Promise<void>

    Promise that resolves when all live notifications are dismissed

  • Retrieves information about all currently active order tracking live notifications.

    Returns a list of all live notifications currently displayed for the user, including their order IDs and activity IDs.

    Platform Support: iOS 16.2+ only. Returns empty array on other platforms.

    Use cases:

    • Check if a specific order already has an active live notification
    • Display list of tracked orders in your app UI
    • Sync app state with active live notifications

    Example:

    const modules = await Eitri.modules()
    const liveNotificationGetActiveNotifications = modules.orderStatusLiveNotification?.getActiveNotifications
    if (!liveNotificationGetActiveNotifications) return

    const activities = await liveNotificationGetActiveNotifications()
    console.log(`${activities.length} active order notifications`)

    activities.forEach(activity => {
    console.log(`Order ${activity.orderId} - Activity ${activity.activityId}`)
    })

    // Check if specific order is being tracked
    const isTracking = activities.some(a => a.orderId === "12345")

    Returns Promise<LiveNotificationActivityInfo[]>

    Promise resolving to array of active live notification info. Empty array if none active.