Set mail recipients when using UIActivityViewController iOS 8 - swift

I would like to know if there is a simplified method of setting the mail recipients when using UIActivityViewController with iOS 8? I want to add the mail recipients. I was trying to do so using the following code but the recipient is just added to the main body of text.
let url = NSURL.fileURLWithPath(fileName)
let url2 = NSURL(string: "mailto:somebody#gmail.com") as! AnyObject
let activityItems:Array = [url, url2]
let activityViewController = UIActivityViewController(activityItems: activityItems , applicationActivities: nil)
I have seen some workaround methods for iOS 6 but just wondered if there was now a simplified method to add the recipient?

Related

AirDrop a custom file type from one IOS device to another / excludedActivityTypes

Currently I can send custom type Data from one device to another via email but I'm now trying to use AirDrop with my incomplete code below . I think the problem is I need to add my custom file type in the excludedActivityTypes but not sure how ??
I believe I need to add my document type and exported type identifier but not sure how ? (I've added screen shots below of my declared custom file)
enter code here let dataToShare: NSMutableArray = self.quizDataBase
let controller = UIActivityViewController(activityItems: [dataToShare], applicationActivities: nil)
controller.excludedActivityTypes = nil
self.present(controller, animated: true, completion: nil)

Can't see Reminders app option in UIActivityViewController

I have a comma-separated string like this: "Banana,Cake". I want to share this string to the Reminders app through UIActivityViewController, but while opening the controller, I can't see an option for Reminders there.
I have seen it in the YouTube app. If a content is being shared, it shows the Reminders app as an option.
You must pass an array of a string and an URL to activityItems in order to display Reminders as an option.
if let url = URL(string: "http://example.com") {
let activityVc = UIActivityViewController(activityItems: ["string", url], applicationActivities: nil)
}

UIActivityViewController - Can't AirDrop a more than one object type simultaneously

I'd like to be able to AirDrop a text file and an image at the same time using the UIActivityViewController. The code below works fine to send both file types via iMessage or eMail, but it fails when I try to use AirDrop. The code works fine for AirDropping 2 images or 2 text files, but not for one of each.
#IBAction func shareImage(_ sender: UIButton)
{
// can't seem to AirDrop a mixture of file types. ie. can send 2 images, or 2 data files, but not an image and a data file
let fileToSend: NSURL = NSURL(fileURLWithPath: dataFile!)
let image = imageView.image!
let objectsToShare = [fileToSend, image] as [Any]
let controller = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
controller.excludedActivityTypes = [UIActivityType.postToFacebook, UIActivityType.postToTwitter, UIActivityType.postToWeibo, UIActivityType.print, UIActivityType.copyToPasteboard, UIActivityType.assignToContact, UIActivityType.saveToCameraRoll, UIActivityType.postToFlickr, UIActivityType.postToTencentWeibo]
self.present(controller, animated: true, completion: nil)
}
AirDrop to an iOS device does not support sending multiple different types, but sending to a mac does. Until Apple changes that there is no code change that you can do to "fix" this.

Sending an animated Gif via sms in Swift

I'm trying to send an animated gif via the MFMessageComposeViewController in swift,
It seems to be working fine when I send the gif, however the preview shows a non-moving image. Any thoughts on how to make the preview animated?
let messageComposeVC = MFMessageComposeViewController()
let imgData = NSData(contentsOfURL: NSURL(string: "http://dramallamaapp.com/wp-content/uploads/2016/08/output_9GECbQ.gif")!)
if imgData != nil {
messageComposeVC.addAttachmentData(imgData!, typeIdentifier: "com.compuserve.gif", filename: "animated.gif")
}
messageComposeVC.messageComposeDelegate = self
presentViewController(messageComposeVC, animated: true, completion: nil)
Upon further investigation, I now believe this is default iOS behavior, as with iMessages the same happens (gif shows as an image until sent, then begins animating).

Deep link not working for a case

Hey I am developing an app for the version iOS7 and above, where I have to share a content via mail or message. I use the following code
let textToShare = "Just click the following link to view "
let urlToShare = NSURL(string: "croding.com://crodid/crodname")
let objectsToShare = [textToShare, urlToShare]
let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
self.presentViewController(activityVC, animated: true, completion: nil)
I have added the croding.com in plist. Its working fine (open our app from mail exactly what I want) only if the app is installed already otherwise this thing is just a text instead of link. I need to show it as link even app is not installed.
croding.com://crodid/crodname