6

I am using UIActivityViewController to share but on gmail when I set its subject specifically it does not set. Any help please.

let eventURL = eventShare[sender.tag]
let eventTitleText = eventTitle[sender.tag]
let contentDescription = eventDescription[sender.tag]

let contentURL:NSURL = NSURL(string:eventURL)!

let activityViewController : UIActivityViewController = UIActivityViewController(activityItems: [contentDescription, contentURL],applicationActivities: nil)

activityViewController.setValue("Our Buzz - \(eventTitleText)", forKey: "Subject")
activityViewController.popoverPresentationController?.sourceView = self.view
self.presentViewController(activityViewController, animated: true, completion: nil)
Sandy Chapman
  • 11,133
  • 3
  • 58
  • 67

2 Answers2

1

Try "subject" instead of "Subject" (lower case)

Sonny Saluja
  • 7,193
  • 2
  • 25
  • 39
1

This seems to be a bug with the Gmail/Inbox apps. Using "Subject" as the key works correctly for Apple's Mail app but not for Gmail/Inbox. Other keys which also do not work include "subject", "title", "Title".

Another thing to be aware of is that the subject for Gmail/Inbox will include all the items in activityItems that you pass.

Since "Subject" sets the subject, people might be inclined to think that "Body" or some variant may work; but that results in a crash.

EndersJeesh
  • 427
  • 1
  • 4
  • 20