Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Activity created but not show up #93

Open
ibrahimKonyali opened this issue Oct 15, 2024 · 10 comments
Open

Activity created but not show up #93

ibrahimKonyali opened this issue Oct 15, 2024 · 10 comments
Labels
question Further information is requested

Comments

@ibrahimKonyali
Copy link

Hello all,

I'm following the procedure and can't get the activity show up on lock screen.

Here what i did so far;

Opened; ios/Runner.xcworkspace
Added widget extension with embed application runner is selected.
Activated the widget extension from dialog
Added push notification to runner
Enabled NSSupportsLiveActivities for both widget extension info and runner info
Added App group capability for both widget extension and runner and gave same id for both
I used example code for native side and gave same app group id to UserDefaults

https://github.com/istornz/flutter_live_activities/blob/main/example/ios/extension-example/extension_example.swift

let sharedDefault = UserDefaults(suiteName: "YOUR_GROUP_ID")!

And on flutter side, i init() the plugin and call createActivity()

After doing all of these and tried to create activity, this is only error i get from runner (it creates activity and return activity id without problem)

[User Defaults] Couldn't read values in CFPrefsPlistSource<0x28010f900> (Domain: group.xxx.xxx, User: kCFPreferencesAnyUser, ByHost: Yes, Container: (null), Contents Need Refresh: Yes): Using kCFPreferencesAnyUser with a container is only allowed for System Containers, detaching from cfprefsd

Even id in app group for both in extension and runner is same and that id is active on Certificates, Identifiers & Profiles at developer at apple it still doesn't show the activity on lock screen.

If you are going to suggest using app group id with TeamID in it, i already tried that and didn't work either.

@DKMonster
Copy link

Could you share your Swift code?

I encountered the same issues before, but I managed to fix them.

I think we're running into the same problem.

@DKMonster
Copy link

When implementing the Live Activity widget:

  1. The top-level attributes struct must be named LiveActivitiesAppAttributes in your Swift code.
    This is essential because the Flutter method channel uses this specific type to communicate with the widget.

  2. The widget struct itself (below the attributes) can have any name you choose.

If your widget isn't displaying, please check if you've properly implemented the LiveActivitiesAppAttributes struct.

@ibrahimKonyali
Copy link
Author

When implementing the Live Activity widget:

  1. The top-level attributes struct must be named LiveActivitiesAppAttributes in your Swift code.
    This is essential because the Flutter method channel uses this specific type to communicate with the widget.
  2. The widget struct itself (below the attributes) can have any name you choose.

If your widget isn't displaying, please check if you've properly implemented the LiveActivitiesAppAttributes struct.

Yeah i use same struct with example but didn't work. Then i use this package https://pub.dev/packages/flutter_live_activities and without app group and custom struct i was able to create and update activities after i uncheck "copy only when installing" under the embed frameworks in build phases.

@manoj1749
Copy link

manoj1749 commented Nov 12, 2024

Heyy @ibrahimKonyali @DKMonster I am also having the same issue, my flutter engine is updating and creating the activity, but the live activity, notification and dynamic island are not showing, in both my simulator and mobile. But when the app is in background and when I click on Dynamic Island it's opening the app.
This is my Swift code

//
//  extension_example.swift
//  extension-example
//
//  Created by Dimitri Dessus on 28/09/2022.
//

import ActivityKit
import WidgetKit
import SwiftUI

@main
struct Widgets: WidgetBundle {
  var body: some Widget {
    if #available(iOS 16.1, *) {
      RideTrackingApp()
    }
  }
}

struct LiveActivitiesAppAttributes: ActivityAttributes, Identifiable {
    public typealias RideData = ContentState

    public struct ContentState: Codable, Hashable {
              var rideStatus: String
        var elapsedTime: String
        var distanceCovered: String
    }

    var id = UUID()
}

let sharedDefault = UserDefaults(suiteName: "group.goeleventhmile.liveactivities")!

@available(iOSApplicationExtension 16.1, *)
struct RideTrackingApp: Widget {
  var body: some WidgetConfiguration {
    ActivityConfiguration(for: LiveActivitiesAppAttributes.self) { context in
//     let pizzaName = sharedDefault.string(forKey: context.attributes.prefixedKey("rideStatus"))! // put the same key as your Dart map
// let pizzaPrice = sharedDefault.string(forKey: context.attributes.prefixedKey("elapsedTime"))
// let quantity = sharedDefault.string(forKey: context.attributes.prefixedKey("distanceCovered"))
      VStack(alignment: .leading) {
        Text(context.state.rideStatus)
          .font(.headline)
          .padding(.bottom, 4)
        
        HStack {
          Text("Time:")
            .font(.caption)
          Text(context.state.elapsedTime)
            .font(.body)
            .foregroundColor(.blue)
        }
        
        HStack {
          Text("Distance:")
            .font(.caption)
          Text(context.state.distanceCovered)
            .font(.body)
            .foregroundColor(.green)
        }
      }
      .activityBackgroundTint(Color.gray.opacity(0.2))
      .activitySystemActionForegroundColor(Color.blue)
    } dynamicIsland: { context in
      DynamicIsland {
        DynamicIslandExpandedRegion(.leading) {
          VStack {
            Text("Status")
            Text(context.state.rideStatus)
              .font(.headline)
              .foregroundColor(.primary)
          }
        }
        
        DynamicIslandExpandedRegion(.trailing) {
          VStack {
            Text("Time")
            Text(context.state.elapsedTime)
              .font(.headline)
              .foregroundColor(.primary)
          }
        }
        
        DynamicIslandExpandedRegion(.bottom) {
          VStack {
            Text("Distance")
            Text(context.state.distanceCovered)
              .font(.headline)
              .foregroundColor(.primary)
          }
        }
      } compactLeading: {
        Text("T")
      } compactTrailing: {
        Text("D")
      } minimal: {
        Text("R")
      }
      .widgetURL(URL(string: "http://www.apple.com"))
      .keylineTint(Color.blue)
    }
  }
}

extension LiveActivitiesAppAttributes {
  func prefixedKey(_ key: String) -> String {
    return "\(id)_\(key)"
  }
}

I have tried running the app through xcode, and this is the error I am getting

SendProcessControlEvent:toPid: encountered an error: Error Domain=com.apple.dt.deviceprocesscontrolservice Code=8 "Failed to show Widget 'com.goeleventhmile.MyAppWidget' error: Error Domain=FBSOpenApplicationServiceErrorDomain Code=1 "The request to open "com.apple.springboard" failed." UserInfo={NSLocalizedFailureReason=The request was denied by service delegate (SBMainWorkspace)., BSErrorCodeDescription=RequestDenied, NSUnderlyingError=0x600000cacc60 {Error Domain=SBAvocadoDebuggingControllerErrorDomain Code=1 "Failed to get descriptors for extensionBundleID (com.goeleventhmile.MyAppWidget)" UserInfo={NSLocalizedDescription=Failed to get descriptors for extensionBundleID (com.goeleventhmile.MyAppWidget)}}, FBSOpenApplicationRequestID=0x2e8d, NSLocalizedDescription=The request to open "com.apple.springboard" failed.}." UserInfo={NSLocalizedDescription=Failed to show Widget 'com.goeleventhmile.MyAppWidget' error: Error Domain=FBSOpenApplicationServiceErrorDomain Code=1 "The request to open "com.apple.springboard" failed." UserInfo={NSLocalizedFailureReason=The request was denied by service delegate (SBMainWorkspace)., BSErrorCodeDescription=RequestDenied, NSUnderlyingError=0x600000cacc60 {Error Domain=SBAvocadoDebuggingControllerErrorDomain Code=1 "Failed to get descriptors for extensionBundleID (com.goeleventhmile.MyAppWidget)" UserInfo={NSLocalizedDescription=Failed to get descriptors for extensionBundleID (com.goeleventhmile.MyAppWidget)}}, FBSOpenApplicationRequestID=0x2e8d, NSLocalizedDescription=The request to open "com.apple.springboard" failed.}., NSUnderlyingError=0x600000cac9c0 {Error Domain=FBSOpenApplicationServiceErrorDomain Code=1 "The request to open "com.apple.springboard" failed." UserInfo={NSLocalizedFailureReason=The request was denied by service delegate (SBMainWorkspace)., BSErrorCodeDescription=RequestDenied, NSUnderlyingError=0x600000cacc60 {Error Domain=SBAvocadoDebuggingControllerErrorDomain Code=1 "Failed to get descriptors for extensionBundleID (com.goeleventhmile.MyAppWidget)" UserInfo={NSLocalizedDescription=Failed to get descriptors for extensionBundleID (com.goeleventhmile.MyAppWidget)}}, FBSOpenApplicationRequestID=0x2e8d, NSLocalizedDescription=The request to open "com.apple.springboard" failed.}}}
Domain: DTXMessage
Code: 1
User Info: {
    DVTErrorCreationDateKey = "2024-11-12 06:40:26 +0000";
}
--
SendProcessControlEvent:toPid: encountered an error: Error Domain=com.apple.dt.deviceprocesscontrolservice Code=8 "Failed to show Widget 'com.goeleventhmile.MyAppWidget' error: Error Domain=FBSOpenApplicationServiceErrorDomain Code=1 "The request to open "com.apple.springboard" failed." UserInfo={NSLocalizedFailureReason=The request was denied by service delegate (SBMainWorkspace)., BSErrorCodeDescription=RequestDenied, NSUnderlyingError=0x600000cacc60 {Error Domain=SBAvocadoDebuggingControllerErrorDomain Code=1 "Failed to get descriptors for extensionBundleID (com.goeleventhmile.MyAppWidget)" UserInfo={NSLocalizedDescription=Failed to get descriptors for extensionBundleID (com.goeleventhmile.MyAppWidget)}}, FBSOpenApplicationRequestID=0x2e8d, NSLocalizedDescription=The request to open "com.apple.springboard" failed.}." UserInfo={NSLocalizedDescription=Failed to show Widget 'com.goeleventhmile.MyAppWidget' error: Error Domain=FBSOpenApplicationServiceErrorDomain Code=1 "The request to open "com.apple.springboard" failed." UserInfo={NSLocalizedFailureReason=The request was denied by service delegate (SBMainWorkspace)., BSErrorCodeDescription=RequestDenied, NSUnderlyingError=0x600000cacc60 {Error Domain=SBAvocadoDebuggingControllerErrorDomain Code=1 "Failed to get descriptors for extensionBundleID (com.goeleventhmile.MyAppWidget)" UserInfo={NSLocalizedDescription=Failed to get descriptors for extensionBundleID (com.goeleventhmile.MyAppWidget)}}, FBSOpenApplicationRequestID=0x2e8d, NSLocalizedDescription=The request to open "com.apple.springboard" failed.}., NSUnderlyingError=0x600000cac9c0 {Error Domain=FBSOpenApplicationServiceErrorDomain Code=1 "The request to open "com.apple.springboard" failed." UserInfo={NSLocalizedFailureReason=The request was denied by service delegate (SBMainWorkspace)., BSErrorCodeDescription=RequestDenied, NSUnderlyingError=0x600000cacc60 {Error Domain=SBAvocadoDebuggingControllerErrorDomain Code=1 "Failed to get descriptors for extensionBundleID (com.goeleventhmile.MyAppWidget)" UserInfo={NSLocalizedDescription=Failed to get descriptors for extensionBundleID (com.goeleventhmile.MyAppWidget)}}, FBSOpenApplicationRequestID=0x2e8d, NSLocalizedDescription=The request to open "com.apple.springboard" failed.}}}
Domain: DTXMessage
Code: 1
--


System Information

macOS Version 15.1 (Build 24B83)
Xcode 16.1 (23503) (Build 16B40)
Timestamp: 2024-11-12T12:10:26+05:30

@thpengu
Copy link

thpengu commented Nov 20, 2024

Hello everyone,

I'm trying to integrate Dynamic Island functionality into my Flutter app using the package live_activities, and I've followed the documentation thoroughly. However, I'm running into some issues. Specifically, Dynamic Island does not appear on the screen. I tested a real device that supports this function.

@ibrahimKonyali @manoj1749, have you found a solution? I would appreciate any advice or guidance.

I appreciate any help you can give me.

@manoj1749
Copy link

What error is it showing for you?
@thpengu

@thpengu
Copy link

thpengu commented Nov 21, 2024

@manoj1749
There is no error showing. I checked, and the live activity is created but not appearing on my screen. I tested the real device and the emulator, too. I think it's the same issue as yours.

<But when the app is in background and when I click on Dynamic Island it's opening the app.>
In my case, it opens only on the emulator if I click the dynamic island area.

@manoj1749
Copy link

You can see the dynamic island minimising and maximising when holded and all?. If that so, can you check whether the data which you are trying to send form flutter is being sent to native side or not? Also share youe AppDelegate.swift of the widget.

@RahnRazamai
Copy link

@manoj1749 There is no error showing. I checked, and the live activity is created but not appearing on my screen. I tested the real device and the emulator, too. I think it's the same issue as yours.

<But when the app is in background and when I click on Dynamic Island it's opening the app.> In my case, it opens only on the emulator if I click the dynamic island area.

check your live activities widget iOS version target. make sure its 16.1 or lower than your emulator iOS version. took me one week to figure this out

@istornz istornz added the question Further information is requested label Nov 27, 2024
@sbergmair
Copy link

In my case live activities did not show up after upgrading to flutter: 3.27.1. The changes on Color in dart broke the live activities, because deserialization did not work any more. Fixing this also fixed the live activities. Maybe this helps anyone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

7 participants