Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions packages/react-native-activity-kit/ios/ActivityKitModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,14 @@ class ActivityKitModule: HybridActivityKitModuleSpec {
pushType = nil
}

let attributeDict = anyMapToDictionary(attributes)
let scheduledStartTimestamp = attributeDict["_startDate"] as? Double
let scheduledAlertTitle = attributeDict["_alertTitle"] as? String
let scheduledAlertBody = attributeDict["_alertBody"] as? String

let state = try ActivityKitModuleAttributes.ContentState(data: anyMapToDictionary(state))

let attributes = try ActivityKitModuleAttributes(data: anyMapToDictionary(attributes))
let attributes = try ActivityKitModuleAttributes(data: attributeDict)

var activity: Activity<ActivityKitModuleAttributes>

Expand All @@ -125,7 +130,33 @@ class ActivityKitModule: HybridActivityKitModuleSpec {
relevanceScore: options?.relevanceScore ?? 0,
)

if #available(iOS 18.0, *) {
if let startTimestamp = scheduledStartTimestamp {
let startDate = Date(timeIntervalSince1970: startTimestamp / 1000)
let alertConfig = ActivityKit.AlertConfiguration(
title: LocalizedStringResource(stringLiteral: scheduledAlertTitle ?? "Live Activity Started"),
body: LocalizedStringResource(stringLiteral: scheduledAlertBody ?? "Tap to open"),
sound: .default
)
if #available(iOS 26.0, *) {
activity = try Activity.request(
attributes: attributes,
content: content,
pushType: pushType,
style: options?.style == .transient ? .transient : .standard,
alertConfiguration: alertConfig,
start: startDate
)
} else {
activity = try Activity.request(
attributes: attributes,
content: content,
pushType: pushType,
style: options?.style == .transient ? .transient : .standard,
alertConfiguration: alertConfig,
startDate: startDate
)
}
} else if #available(iOS 18.0, *) {
activity = try Activity.request(
attributes: attributes,
content: content,
Expand Down