Enhance collaboration experiences with Messages

RSS for tag

Discuss the WWDC22 Session Enhance collaboration experiences with Messages

Posts under wwdc2022-10095 tag

3 Posts

Post

Replies

Boosts

Views

Activity

Can’t get NSSharingServicePicker to work for sharing a CKShare
I’m trying to share CKRecords from my app’s CloudKit database using a CKShare from an NSSharingServicePicker, but the picker doesn’t show any sharing services. I’m pretty much doing exactly what the code samples in the WWDC22 video Enhance collaboration experiences with Messages show: let itemProvider = NSItemProvider() if let existingShare { itemProvider.registerCKShare(existingShare, container: container) } else { itemProvider.registerCKShare(container: container, preparationHandler: { return try await createAndSaveNewCKShare() }) } Then, I add some metadata as described in the video: let activityItem = NSPreviewRepresentingActivityItem( item: itemProvider,     title: "The title", imageProvider: nil, // TODO: Quick Look preview image iconProvider: .init(object: NSApp.applicationIconImage) ) Finally, I create the picker and show it: let picker = NSSharingServicePicker(items: [activityItem]) picker.show(relativeTo: .zero, of: view, preferredEdge: .minY)) What I then get is a sharing service picker that only shows my recent contacts, but not a single sharing service below that. The metadata is there, i.e. the title and app icon show up: What am I doing wrong here? I’m pretty confident that most of the code is correct because it works fine on iOS. There, I use the same itemProvider as above, but present the share UI like this, which is pretty much the same: let configuration = UIActivityItemsConfiguration(itemProviders: [itemProvider]) configuration.perItemMetadataProvider = { _, key in     switch key {     case .linkPresentationMetadata:         let metadata = LPLinkMetadata() metadata.title = title         metadata.imageProvider = nil // TODO: Quick Look preview image metadata.iconProvider = nil // TODO: App icon?     default:         return nil     } } let viewController = UIActivityViewController(activityItemsConfiguration: configuration)
1
0
1.4k
Dec ’22
Embedded SWCollaborationView in SwiftUI
Hello to the team, Our app (targeting iOS 16) is sharing data between users via CloudKit, and now we'd like to add the new SWCollaborationView feature. I created a CollaborationViewRep: UIViewRepresentable view as follows -     var activityItem: NSItemProvider     var eventName: String     @Binding var isCollaborationViewPresented: Bool     func makeUIView(context: Context) -> SWCollaborationView {         let collaborationView = SWCollaborationView(itemProvider: activityItem)         collaborationView.delegate = context.coordinator         return collaborationView     }     func updateUIView(_ uiView: SWCollaborationView, context: Context) {     }     class Coordinator: NSObject, SWCollaborationViewDelegate {         var parent: CollaborationViewRep         init(_ parent: CollaborationViewRep) {             self.parent = parent         }                  func collaborationViewShouldPresentPopover(_ collaborationView: SWCollaborationView) -> Bool {             return true         }         func collaborationViewWillPresentPopover(_ collaborationView: SWCollaborationView) {         }     }     func makeCoordinator() -> Coordinator {         Coordinator(self)     } } And when I'm trying to add this view as a toolbar item to my SwiftUI view, it doesn't work properly. If I'm adding this view as the toolbar item, without wrap it into a button, then nothing happens when I'm tapping the view (as it should work on UIKit). If I do wrap it with a button, and present the view as popover, then the view icon is presented and then, only when I tap this popover, the content view is presented (screenshot attached). It feels like this feature is not fully available for SwiftUI, unless I'm missing something. Unfortunately, the documentation is not covering the SwiftUI flow and there is no sample app for reference. Any idea how to best practice this situation? Thanks a lot!
0
2
1.4k
Oct ’22
Using Core Data objects with Transferable
I was wondering whether objects in Core Data (and CloudKit) conform, or are able to be conformed, to the Transferable protocol. As far as I can see there is no underlying implementation yet, but maybe this will be added as a future feature so that SwiftUI and Core Data can work better together. In the WWDC22 session "Enhance collaboration experiences with Messages" at 10:21, a struct call Note was implementing the transferRepresentation required property and returned an object of type CKShareTransferRepresentation from its body. I couldn't find any reference to this type anywhere in the documentation and nothing else was mentioned in the session video. Maybe this is something that is going to be added soon or was removed after the video was made. Since I want to use Core Data in my SwiftUI app and want to enable sharing features, such as collaboration via the shared database, NSManagedObject subclasses need some way of conforming to the Transferable protocol. I was hoping there would be a specialised way to do this, and the aforementioned type from the session video sort of hinted at this. I am just asking here to see if anyone has any information about this – whether this feature is about to be released, how this issue can be solved, or another way to do this. Any help is appreciated.
1
5
2.3k
Aug ’22
Can’t get NSSharingServicePicker to work for sharing a CKShare
I’m trying to share CKRecords from my app’s CloudKit database using a CKShare from an NSSharingServicePicker, but the picker doesn’t show any sharing services. I’m pretty much doing exactly what the code samples in the WWDC22 video Enhance collaboration experiences with Messages show: let itemProvider = NSItemProvider() if let existingShare { itemProvider.registerCKShare(existingShare, container: container) } else { itemProvider.registerCKShare(container: container, preparationHandler: { return try await createAndSaveNewCKShare() }) } Then, I add some metadata as described in the video: let activityItem = NSPreviewRepresentingActivityItem( item: itemProvider,     title: "The title", imageProvider: nil, // TODO: Quick Look preview image iconProvider: .init(object: NSApp.applicationIconImage) ) Finally, I create the picker and show it: let picker = NSSharingServicePicker(items: [activityItem]) picker.show(relativeTo: .zero, of: view, preferredEdge: .minY)) What I then get is a sharing service picker that only shows my recent contacts, but not a single sharing service below that. The metadata is there, i.e. the title and app icon show up: What am I doing wrong here? I’m pretty confident that most of the code is correct because it works fine on iOS. There, I use the same itemProvider as above, but present the share UI like this, which is pretty much the same: let configuration = UIActivityItemsConfiguration(itemProviders: [itemProvider]) configuration.perItemMetadataProvider = { _, key in     switch key {     case .linkPresentationMetadata:         let metadata = LPLinkMetadata() metadata.title = title         metadata.imageProvider = nil // TODO: Quick Look preview image metadata.iconProvider = nil // TODO: App icon?     default:         return nil     } } let viewController = UIActivityViewController(activityItemsConfiguration: configuration)
Replies
1
Boosts
0
Views
1.4k
Activity
Dec ’22
Embedded SWCollaborationView in SwiftUI
Hello to the team, Our app (targeting iOS 16) is sharing data between users via CloudKit, and now we'd like to add the new SWCollaborationView feature. I created a CollaborationViewRep: UIViewRepresentable view as follows -     var activityItem: NSItemProvider     var eventName: String     @Binding var isCollaborationViewPresented: Bool     func makeUIView(context: Context) -> SWCollaborationView {         let collaborationView = SWCollaborationView(itemProvider: activityItem)         collaborationView.delegate = context.coordinator         return collaborationView     }     func updateUIView(_ uiView: SWCollaborationView, context: Context) {     }     class Coordinator: NSObject, SWCollaborationViewDelegate {         var parent: CollaborationViewRep         init(_ parent: CollaborationViewRep) {             self.parent = parent         }                  func collaborationViewShouldPresentPopover(_ collaborationView: SWCollaborationView) -> Bool {             return true         }         func collaborationViewWillPresentPopover(_ collaborationView: SWCollaborationView) {         }     }     func makeCoordinator() -> Coordinator {         Coordinator(self)     } } And when I'm trying to add this view as a toolbar item to my SwiftUI view, it doesn't work properly. If I'm adding this view as the toolbar item, without wrap it into a button, then nothing happens when I'm tapping the view (as it should work on UIKit). If I do wrap it with a button, and present the view as popover, then the view icon is presented and then, only when I tap this popover, the content view is presented (screenshot attached). It feels like this feature is not fully available for SwiftUI, unless I'm missing something. Unfortunately, the documentation is not covering the SwiftUI flow and there is no sample app for reference. Any idea how to best practice this situation? Thanks a lot!
Replies
0
Boosts
2
Views
1.4k
Activity
Oct ’22
Using Core Data objects with Transferable
I was wondering whether objects in Core Data (and CloudKit) conform, or are able to be conformed, to the Transferable protocol. As far as I can see there is no underlying implementation yet, but maybe this will be added as a future feature so that SwiftUI and Core Data can work better together. In the WWDC22 session "Enhance collaboration experiences with Messages" at 10:21, a struct call Note was implementing the transferRepresentation required property and returned an object of type CKShareTransferRepresentation from its body. I couldn't find any reference to this type anywhere in the documentation and nothing else was mentioned in the session video. Maybe this is something that is going to be added soon or was removed after the video was made. Since I want to use Core Data in my SwiftUI app and want to enable sharing features, such as collaboration via the shared database, NSManagedObject subclasses need some way of conforming to the Transferable protocol. I was hoping there would be a specialised way to do this, and the aforementioned type from the session video sort of hinted at this. I am just asking here to see if anyone has any information about this – whether this feature is about to be released, how this issue can be solved, or another way to do this. Any help is appreciated.
Replies
1
Boosts
5
Views
2.3k
Activity
Aug ’22