我正在做 iPhone 应用程序,我需要在我的应用程序中捕获其他应用程序的通知。 示例 我的 iPhone 中有 hello world 和 test 应用程序。我想在测试应用程序中捕获hello world通知。这个怎么做?和 我已使用本地通知注册应用程序,即
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(handleAppFinishLaunching)
name:UIApplicationDidFinishLaunchingNotification
object :nil];
这会注册我的应用程序本身。我还可以为 addObserver 提供哪些其他值?
最佳答案
我认为您可以在接收方应用程序中注册自定义 URL 方案,例如 notification://
,然后在发送方应用程序中使用 [UIApplication openURL:]
传递一些数据。接收者应在应用程序委托(delegate)中使用 application:openURL:sourceApplication:annotation:
您可以在 http://iosdevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html 找到有关注册自定义 URL 方案的一些信息。
关于iphone - 如何注册其他应用程序的通知?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9138804/