最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

swift - iOS Live Activities not showing - Stack Overflow

programmeradmin1浏览0评论

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: ";))
      .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 ?

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"))
      .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 ?

Share Improve this question edited Feb 2 at 1:07 HangarRash 15k5 gold badges19 silver badges55 bronze badges asked Feb 2 at 0:50 BaptisteBaptiste 3991 gold badge2 silver badges15 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

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.

发布评论

评论列表(0)

  1. 暂无评论