Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can NSNotificationCenter be used between different apps to communicate?

An app can make internal use of NSNotificationCenter for different parts to communicate with each other, but can this be extended such that differing apps can use it to communicate?

Edit: sorry for the confusion about iOS versus OSX. I only added the iOS tag, I don't know how/who/why an objective-c tag also got added, it wasn't me.

like image 523
Gruntcakes Avatar asked Dec 15 '11 21:12

Gruntcakes


2 Answers

Sorry for a brief answer but in this case that's all there is to it - no they cannot.

You can register to handle a URL type and then launch pass some data that way.

like image 151
Nick Avatar answered Oct 12 '22 07:10

Nick


Nick's answer is certainly correct, but if you're looking for an alternative to NSNotificationCenter, that works between processes, you can try using the Darwin notification mechanism in CoreFoundation.framework. This works between processes, if you use the Darwin notification center.

See example here on Stack Overflow

... and another one with an example callback

Note that I have not used this in any apps on the iTunes App Store. These APIs are not private, however Apple certainly can reject usage of whatever they like, even if it's not a private API. I just offer this solution as a possibility, without being able to predict App Store acceptibility, or even knowing whether you (or others reading this page) need to submit their apps to the App Store.

I'll also link to this similar question (currently unsolved)

like image 39
Nate Avatar answered Oct 12 '22 08:10

Nate