You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I only enabled text sharing and I simply want to add a title to the shared text. Here is my ShareViewController.swift. The UI part works. I can put a title and click on Post but the title is then not part of the value in ReceiveSharingIntent.instance.getMediaStream().listen((value). Can somebody please help me or provide a minimal working example of how something like this would work? Thank you!
import UIKit
import Social
import UniformTypeIdentifiers
import receive_sharing_intent
classShareViewController:RSIShareViewController{vartitleConfigurationItem:SLComposeSheetConfigurationItem?privatevartextString:String?privatevartitleItem:NSExtensionItem?overridefunc viewDidLoad(){
super.viewDidLoad()}overridefunc shouldAutoRedirect()->Bool{return false
}overridefunc isContentValid()->Bool{return true
}overridefunc didSelectPost(){
super.didSelectPost()}overridefunc configurationItems()->[Any]!{
if titleConfigurationItem ==nil{
titleConfigurationItem =SLComposeSheetConfigurationItem()
titleConfigurationItem?.title ="Title"
titleConfigurationItem?.tapHandler ={[unowned self]inletalertController=UIAlertController(title:"Title", message:nil, preferredStyle:.alert)
alertController.addTextField{ textField in
textField.placeholder ="Enter title"
textField.textAlignment =.center
}// A cancel actionletcancelAction=UIAlertAction(title:"Cancel", style:.cancel){ _ inprint("Canelled")}letconfirmAction=UIAlertAction(title:"OK", style:.default){ _ in
if let text = alertController.textFields?.first?.text {self.titleItem =NSExtensionItem()
if let titleItem =self.titleItem {letitemProvider=NSItemProvider(item: text asNSSecureCoding, typeIdentifier:UTType.plainText.identifier)
titleItem.attachments =[itemProvider]}}}
alertController.addAction(cancelAction)
alertController.addAction(confirmAction)self.present(alertController, animated: true, completion:{
titleConfigurationItem?.value = alertController.textFields?.first?.text ??"None"})}}return[titleConfigurationItem!]}}
The text was updated successfully, but these errors were encountered:
Hi,
I only enabled text sharing and I simply want to add a title to the shared text. Here is my ShareViewController.swift. The UI part works. I can put a title and click on Post but the title is then not part of the
value
inReceiveSharingIntent.instance.getMediaStream().listen((value)
. Can somebody please help me or provide a minimal working example of how something like this would work? Thank you!The text was updated successfully, but these errors were encountered: