简体   繁体   English

应用程序之间的应用程序之间的通信

[英]Inter App communication between apps present in foreground

I am building sdk which at point of time requires to communicate with third party app and communication broadly means here notifiying some event may or may not with any data. 我正在构建sdk,它在某个时间点需要与第三方应用程序通信,并且广泛地通信意味着在某些情况下通知某些事件可能会也可能没有任何数据。

I used NotificationCenter to do this but now I found somewhere written that it is for intra-app communication. 我使用NotificationCenter来做这个,但现在我发现某处写的是用于应用内部通信。 And thats the behaviour I found when I run my code. 这就是我运行代码时发现的行为。

NotificationCenter.default.post(name: action, object: nil, userInfo: jsonObject)

this is the listener I added in sdk 这是我在sdk中添加的听众

NotificationCenter.default.addObserver(self, selector: #selector(onReceive(_:)), name: Notification.Name.ACTION_PAYMENT_ACK, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(onReceive(_:)), name: Notification.Name.ACTION_PAYMENT_CMP, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(onReceive(_:)), name: Notification.Name.ACTION_PAYMENT_REJ, object: nil)

I also found something written related to darwin notification but that was too old a post. 我还发现了一些与达尔文通知有关的内容,但这个帖子太旧了。 How can I do inter-app communication. 我该如何进行应用间通信。

I am looking for something like Broadcast in android. 我正在寻找像Android中的广播一样的东西。

Inter app communication is described here . 这里描述应用程序间通信。
Since you want to do it without manual intervention, only the 2nd part, Using URL Schemes to Communicate with Apps , is relevant for you. 由于您希望在没有人工干预的情况下进行此操作,因此只有第二部分“ 使用URL方案与应用程序通信”才与您相关。 It says 它说

A URL scheme lets you communicate with other apps through a protocol that you define. URL方案允许您通过您定义的协议与其他应用程序通信。 To communicate with an app that implements such a scheme, you must create an appropriately formatted URL and ask the system to open it. 要与实现此类方案的应用程序通信,您必须创建格式正确的URL并要求系统打开它。 To implement support for a custom scheme, you must declare support for the scheme and handle incoming URLs that use the scheme. 要实现对自定义方案的支持,您必须声明对方案的支持并处理使用该方案的传入URL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM