两个应用程序之间的通 [英] Communication between two applications

查看:112
本文介绍了两个应用程序之间的通的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在两个不同的应用程序之间进行通信,一个在后台运行,另一个在前台运行?如果是的话,有人可以提出建议吗?

Is it possible to communicate between two different applications, one running in background and the other in foreground? If yes, can anyone suggest how?

推荐答案

是可以在iPhone中的两个应用程序之间进行通信,但仅限于少数情况。

Yes Communication can be made between two applications in iPhone but limited to a handful of scenarios.


  1. 根据电话等一些事件,可能会有应用程序需要发送到后台。在这种情况下你将必须配置您的音频会话对象(基于Voip的应用程序)并相应地发送通知。

  1. There might be apps which need to be sending to background according to some event like phonecall,etc.In Such cases you will have to configure your audio-session object (a Voip based app) and send notification accordingly.

上一个示例只是在应用程序之间进行交互,灵活性极低(在一些重要的内置事件中将应用程序发送到后台)。另一种方法是通过URL Schemes,apple有一些内置功能,并支持某些应用程序,如mail.tel等。但其中一个应用程序将会到来前景。

The previous example is just interacting between apps with extremely less flexibility(sending app to background on some important built in event).The other way to do this is through URL Schemes , apple has some built in functionality and support for certain applications such as mail.tel , etc.But one of the application will come to foreground.

就像你可以拨打电话号码一样,该电话号码是在应用程序中使用: -

Like you can call a phone number , which is built in application using :-

NSString *phURL= [NSString stringWithFormat:@"tel:%@", [NSString StringWithString:@"1-800-555-1212"]];
NSURL *phoneURL = [NSURL URLWithString:phURL];
[[UIApplication sharedApplication] openURL:phoneURL]];

顺便说一句,如果您需要实现自定义URL方案< /a>。玩得很开心。

By the way it's along story if You need to implement a Custom URL Schemes..have fun with it.


  1. 另一种方式是通过 UIDocumentInteractionController 其提供在应用内支持有一定的间相互作用文件。(沙盒环境禁止完全访问,甚至acc这可以修改其他应用程序的数据。)就像它可以用来预览邮件应用程序中的文件或下载附件。但是你不能为其他应用程序修改它们,当然你可以复制它并为你的应用程序修改它。

  1. The other way is through UIDocumentInteractionController which provides in-app support to have interaction between certain files.(Sandbox environment inhibits a complete access or even accesses that can modify data of other application).Like it can be used to preview files in mail app or download attachments.But you cannot modify them for other application , of course you can copy it and modify it for your application.

这篇关于两个应用程序之间的通的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆