简体   繁体   中英

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.

I used NotificationCenter to do this but now I found somewhere written that it is for intra-app communication. 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

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.

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. It says

A URL scheme lets you communicate with other apps through a protocol that you define. To communicate with an app that implements such a scheme, you must create an appropriately formatted URL and ask the system to open it. To implement support for a custom scheme, you must declare support for the scheme and handle incoming URLs that use the scheme.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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