Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

objective c - How to pass text to 3rd party app in iOS

My app generates some sort of text information.

User presses button like "Share" in my app and after that pops up a windows with a list of installed applications or only apps which can recieve string parameter. After that, user selects, for example, "Mail" app and then it is opened with the new email message and with a given text from my app. Or user selects Skype app and then it is opened with a given text.

How could those scenarios be implemented in iOS?

PS: I already saw similar behavior in Android app (via Intent extras).

UPDATE: I posted the answer below that works for me (via UIActivityViewController) exactly how I need.

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

There is no single answer that will work for all target apps. You need to research each app and see if it has a facility for receiving info from other apps.

A simple way to do this is to invoke an URL that targets the other app.

For mail, you could invoke a mailto:// URL that composes an email with the text in the desired field(s) (to, cc, bcc, subject, or body.)

If the app supports the iOS document model you may be able to pass it a document to open.

If the target app has a server then you may also be able to connect to the server and send data to it that way. Again, this is not a question you can ask in general. The answer will be different for each target app, and for some apps the answer will be "you can't, because it doesn't have any mechanism to receive data from an outside app."

Android is a different beast with different abilities than iOS. iOS is more of a "walled garden", with very limited access outside of your app.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...