Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
752 views
in Technique[技术] by (71.8m points)

ios - UIActivityViewController Subject not working for Outlook

Foe setting subject of share, overriding

   func activityViewController(activityViewController: UIActivityViewController, subjectForActivityType activityType: String?) -> String {
          return "mySubject"
    }

not working for outlook app, while sharing. this method not being called for outlook, works for other apps like mail, gmail etc.

Found that some app like Yelp, Apple maps, Google Maps able to set subject in outlook. How'd one achieve it?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I believe I figured out how this was made to work in those apps. I observed the same behavior in my own app where func activityViewController(_ activityViewController: UIActivityViewController, subjectForActivityType activityType: UIActivityType?) -> String is not being called when choosing the Outlook app. However, I noted the CNN app, as an example, was properly creating a subject line.

The answer it seems is to make the first line of the body text be what you wish the subject to be. I had an asset I was attaching with a URL and so the subject was inserting the URL which I didn't want. However, when I made the subject I did want, the first line of the body in the email, it did then populate the email's subject in Outlook correctly.

So this isn't ideal and certainly the appropriate protocol function should be called, but this does appear to be how others have gotten around what we otherwise cannot fix for Apple or Microsoft.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...