Netmera Developer Guide
Netmera Docs
  • Netmera Developer Guide
  • Platforms
    • iOS
      • New iOS (Swift)
        • SDK Integration
        • Push Notifications
          • Delegate Methods
          • Widget and In-App Messages
          • Media Push
          • Carousel, Slider and Thumbnail Push
        • Deep Linking
          • Custom Deep Links
        • Sound & Vibration
        • Push Inbox
        • Events
        • Geofence & Location
        • User Attributes & Preferences
        • Advertising ID
        • Changelog
      • Former iOS (Objective-C)
        • SDK Integration
        • Push Notifications
          • Delegate Methods
          • Push Payload Receivers
          • Widget and In-App Messages
          • Customizing In-App Messages
          • Media Push
          • Carousel, Slider and Thumbnail Push
          • Custom Web View Presentation
          • Push Icon
        • Live Activities
        • Deep Linking
          • Custom Deep Links
        • Sound & Vibration
        • Push Inbox
        • Events
        • Geofence & Location
        • User Attributes & Preferences
        • Data Transfer
        • Advertising ID
        • SSL Pinning
        • Changelog
    • Android
      • SDK Integration
        • Huawei Integration
        • Huawei Message Receipt
        • Android Integration FAQs
      • Push Notifications
        • Widget and In-App Messages
        • Push Callbacks
        • Custom Web View Presentation
        • Push Icon
      • Deep Linking
        • Custom Deep Links
      • Sound & Vibration
      • Push Inbox
      • Events
      • Geofence & Location
        • Background Location Permission
      • User & Attributes
      • Data Transfer
      • Advertising ID
      • App Tracking
      • SSL Pinning
      • Changelog
    • Web
      • SDK Setup
        • Self-Hosted SDK Setup
      • Mobile Web Push for iOS
      • Deep Linking
        • Custom Deep Links
      • Events
      • User & Attributes
    • React Native
      • SDK Integration
      • Push Notifications
        • Widget and In-App Messages
        • Push Callbacks
      • Deep Linking
        • Custom Deep Links
      • Sound & Vibration
      • Push Inbox
      • Events
      • Geofence & Location
      • User & Attributes
      • Changelog
    • Flutter
      • SDK Integration
      • Push Notifications
        • Push Notification Permissions
        • Widget and In-App Messages
        • Flutter iOS Media Push
      • Deep Linking
        • Custom Deep Links
      • Sound & Vibration
      • Push Inbox
      • Events
      • Geofence & Location
      • User & Attributes
      • SSL Pinning
      • Changelog
    • Cordova
      • SDK Integration
      • Push Notifications
      • Sound & Vibration
      • Push Inbox
      • Events
      • User & Attributes
    • Unity
      • SDK Integration
      • Sound & Vibration
      • Events
      • User & Attributes
      • Changelog
  • Integrated Modules
    • Optimove
    • Adjust
    • Mixpanel
    • IYS Integration
    • VIA Integration
      • Short URL Consent Requests
      • OTP Consent Requests
        • OTP Confirmation Completion
      • VIA Email Rejection Link Generation
      • ETK Rejection via SMS
  • API Documentation
    • REST API
      • Setup
      • Notifications
      • Events
      • User & Device Management
      • Inbox Feature
      • GDPR
      • Error Responses
  • FAQs
    • Push Notifications FAQs
Powered by GitBook
On this page
  • Netmera and Live Activities
  • Prerequisites and Setup
  • Apple Materials
  • Overview of the Live Activity Process
  • Step 1: Transmit the Starter Token to Netmera
  • Step 2: Start the Live Activity
  • Step 3: Transmit the Update Token to Netmera
  • Step 4: Update or End the Live Activity
  • Step 5: Monitor Live Activity Closure

Was this helpful?

  1. Platforms
  2. iOS
  3. New iOS (Swift)

Live Activities

Last updated 3 months ago

Was this helpful?

Live Activities enable apps to display dynamic, real-time updates directly on glanceable areas like the Lock Screen, iPhone StandBy, Dynamic Island, and Apple Watch’s Smart Stack, allowing users to monitor ongoing events, activities, or tasks without constantly reopening the app.

Ideal for tracking short-to-medium-length tasks, Live Activities present prioritized information such as live sports scores, delivery updates, or fitness metrics, and can offer interactive options for user control. For best practices, ensure a concise layout suited to all display locations, avoid sensitive information, and refrain from using Live Activities for advertising, preserving them as a tool for useful, timely updates.

Netmera and Live Activities

Netmera now supports Apple’s Live Activity, enabling real-time updates and interactions directly within targeted user groups. By combining Netmera's targeting capabilities with Live Activity, you can initiate, update, and track ongoing events or tasks, providing users with glanceable information on their Lock Screen or Dynamic Island.

To facilitate this feature, Netmera has integrated additional functionalities into the existing message delivery framework specifically designed for Live Activity.

  • Ensure your iOS SDK version is at least 3.24.0

  • A .p8 push certificate is required to enable Live Activity updates.

  • Starting with iOS 17.2, you can remotely initiate Live Activities via Netmera.

Apple Materials

This guide outlines the steps to initiate, update, and end Live Activity with Netmera’s API, enabling dynamic notifications on iOS devices. Below are the essential setup instructions, endpoint examples, and details on how to manage the lifecycle of a Live Acxtivity.

Overview of the Live Activity Process

  1. Starter Token Transmission to Netmera

  2. Starting the Live Activity

  3. Updating the Live Activity with an Update Token

  4. Modifying or Ending the Live Activity

    1. Monitoring the Close Event

Step 1: Transmit the Starter Token to Netmera

To initiate a Live Activity, Netmera requires the Starter Token provided by Apple. This token is obtained once the activity is ready to begin and is transmitted to Netmera using the LiveActivityStartToken event.

  • Starter Token: This token is essential to start a Live Activity on the user’s device.

Step 2: Start the Live Activity

Using Netmera’s REST API, you can initiate a Live Activity with either sendBulkNotification or sendNotification. Here are examples and descriptions of the parameters used.

2.1 Using sendBulkNotification

The following curl example demonstrates how to start a Live Activity for iOS:

curl --location 'https://restapi.netmera.com/rest/3.0/sendBulkNotification' \
--header 'X-netmera-api-key: your_restapi_key' \
--header 'Content-Type: application/json' \
--data '{
    "message": {
        "title": "Live Activity Start",
        "text": "Here your live activity",
        "platforms": [
            "IOS"
        ],
        "contentState": {
            "emoji": "Apple"
        },
        "liveActAttr": {
            "name": "Constant Value"
        },
        "liveActAttrType": "LiveActivityAttributes"
    },
    "type": "LIVE_ACTIVITY",
    "target": {
        "sendToAll": true
    }
}'

Parameter Descriptions

  • contentState: This dynamic, stateful section of the Live Activity is used for updates. In this example, the emoji is set as "Apple". Defined in Swift as:

    struct LiveActivityAttributes: ActivityAttributes {
      public struct ContentState: Codable, Hashable {
        var emoji: String
      }
      var name: String
    }
  • liveActAttrType: Specifies the model class used in Swift to define the activity, here set as "LiveActivityAttributes".

  • liveActAttr: Contains static content that remains fixed for the Live Activity lifecycle, such as name.

2.2 Using sendNotification

For individual Live Activity notifications, use the createNotificationDefinition API to define the notification, then send it via sendNotification.

  1. Define the Notification:

    curl --location 'https://restapi.netmera.com/rest/3.0/createNotificationDefinition' \
    --header 'X-netmera-api-key: your_restapi_key' \
    --header 'Content-Type: application/json' \
    --data '{
        "title": "Live Activity Start",
        "message": "Here your live activity",
        "platforms": [
            "IOS"
        ],
        "contentState": {
            "emoji": "Apple"
        },
        "liveActAttr": {
            "name": "Constant Value"
        },
        "liveActAttrType": "LiveActivityAttributes"
    }'
  2. Send the Notification:

    curl --location 'https://restapi.netmera.com/rest/3.0/sendNotification' \
    --header 'X-netmera-api-key: your_restapi_key' \
    --header 'Content-Type: application/json' \
    --data '{
        "notificationKey": "your_notification_key",
        "target": {
            "extId": "your_xid"
        }
    }'

After executing these commands, the Live Activity will appear on the user’s device.

Step 3: Transmit the Update Token to Netmera

Update Token: This token is used to modify an ongoing Live Activity. Once the Live Activity is started, Apple provides an update token. Transmit this token to Netmera using the LiveActivityUpdateToken event, including the group_id.

Step 4: Update or End the Live Activity

Use the update-live-activity API to either modify the content of an existing Live Activity or end it based on the action specified.

Example: Update a Live Activity

curl --location 'https://restapi.netmera.com/rest/3.0/update-live-activity' \
--header 'X-netmera-api-key: your_restapi_key' \
--header 'Content-Type: application/json' \
--data '{
    "groupId": "psg-om",
    "action": "UPDATE",
    "contentState": {
        "emoji": "PSG 3:1 OM"
    },
    "priority": 10
}'
  • groupId: Identifier of the Live Activity group.

  • action: Defines the operation type (either "UPDATE" or "END").

  • contentState: Specifies the updated information within the Live Activity.

Example: End a Live Activity

To end a Live Activity, set the action to END:

curl --location 'https://restapi.netmera.com/rest/3.0/update-live-activity' \
--header 'X-netmera-api-key: your_restapi_key' \
--header 'Content-Type: application/json' \
--data '{
    "groupId": "psg-om",
    "action": "END",
    "priority": 10
}'

Step 5: Monitor Live Activity Closure

When the end-user closes the Live Activity in the notification center, this action should be tracked and reported to Netmera using the LiveActivityClose event with the associated group_id.

Note:

Both the starter and update tokens may change over the lifecycle of the Live Activity. Always ensure Netmera receives the latest token data to maintain updates.

Prerequisites and Setup

⚠️
Starting and updating Live Activities with ActivityKit push notifications
Displaying live data with Live Activities
Human Interface Guidelines for Live Activities