Reputation: 399
I'm creating a Capacitor plugin to trigger iOS Live Activities, using Capacitor 7 and Xcode 16. In Xcode, the Live Activity widget is well displayed in the preview, it's a really simple one:
var body: some WidgetConfiguration {
ActivityConfiguration(for: LiveActivityWidgetAttributes.self) { context in
VStack {
Text(context.attributes.title)
.font(.headline)
.foregroundColor(.white) // Ensure this is visible
Text(context.state.detail)
.font(.subheadline)
.foregroundColor(.white) // Ensure this is visible
}
.activityBackgroundTint(Color.black)
.activitySystemActionForegroundColor(.white)
}dynamicIsland: { context in
DynamicIsland {
// Expanded UI goes here
DynamicIslandExpandedRegion(.leading) {
Text("Leading")
}
DynamicIslandExpandedRegion(.trailing) {
Text("Trailing")
}
DynamicIslandExpandedRegion(.bottom) {
Text(context.state.detail)
}
} compactLeading: {
Text("L")
} compactTrailing: {
Text("T")
} minimal: {
Text("Min")
}
.widgetURL(URL(string: "http://www.example.com"))
.keylineTint(Color.red)
}
}
I use the default piece of code to trigger a live activity:
let activity = try Activity<LiveActivityAttributes>.request(
attributes: attributes,
contentState: initialState,
pushType: nil
)
I well retrieve the Activity ID when I start or update one, and I'm able to stop it. However, I never see the Live Activity showing up on my iphone. There is no error message. In Mac Console app, I can see this message when starting a Live Activity:
< private > is not entitled to specify a scene target. Defaulting containingProcess target to < private >
I'm using a Free Provisioning profile, without push notifications update. Background Mode capability is well added. I well update plist file with "Supports Live Activities". In my iphone, app has right authorizations to use Live Activities. Also when creating Live Activity widget extension in Xcode, it created basic widgets we can add on home screen, I'm able to see them and use them.
I clean several times Xcode cache, uninstall, restart phone, the Live Activities never show.
Is anyone have an idea on what can be wrong ?
Upvotes: 1
Views: 186
Reputation: 399
Ok so after several days of debugging, I found what could be wrong. Instead of triggering the Live Activity from a Capacitor plugin I trigger it from a Custom Native iOS code. Difference between both is very thin.
In the iOS project, Capacitor plugin is a Pod dependency whereas Capacitor Native Code is written directly inside the iOS app. It's the only difference I see, but I didn't find clear statement in Apple doc specifying that Live Activities can't be triggered from a Pod dependency.
Also the error found in Mac console:
< private > is not entitled to specify a scene target. Defaulting containingProcess target to < private >
Is not related to the issue I faced. I was able to exclude this by creating a simple project, trigger the Live Activity, it worked well and still the error message was present.
Upvotes: 1