IOS如何在Host App 与 App Extension 之间发送通知
更新时间:2016年03月03日 11:47:33 作者:Saviors
这篇文章主要介绍了IOS如何在Host App 与 App Extension 之间发送通知 的相关资料,需要的朋友可以参考下
如何从你的一个App发送通知给另一个App? (例:搜狗输入法下载皮肤完成后使用皮肤) 注:搜狗输入法是App、而键盘是Extension
当你为你的App 添加 App Extension时,如果想在App 发送通知给 Extension或许这篇文章可以帮助你。
了解更多内容
// 发送通知
- (void)postNotificaiton {
CFNotificationCenterRef notification = CFNotificationCenterGetDarwinNotifyCenter ();
CFNotificationCenterPostNotification(notification, CFSTR("<notificaiton name>"), NULL,NULL, YES);
}
// 接收通知
- (void)receiveNotification {
CFNotificationCenterRef notification = CFNotificationCenterGetDarwinNotifyCenter ();
CFNotificationCenterAddObserver(notification, (__bridge const void *)(self), observerMethod,CFSTR("<notificaiton name>"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
}
void observerMethod (CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo)
{
// Your custom work
}
// 移除通知
- (void)removeNotification
{
CFNotificationCenterRef notification = CFNotificationCenterGetDarwinNotifyCenter ();
CFNotificationCenterRemoveObserver(notification, (__bridge const void *)(self), CFSTR("<notificaiton name>"), NULL);
}
以上内容给大家简单介绍了IOS如何在Host App 与 App Extension 之间发送通知的相关内容,希望对大家有所帮助!
相关文章
浅谈Unity中IOS Build Settings选项的作用
下面小编就为大家分享一篇浅谈Unity中IOS Build Settings选项的作用,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧2018-01-01
iOS经验之初始化方法中不该设置self.view的属性浅析
这篇文章主要给大家介绍了关于iOS经验之初始化方法中不该设置self.view的属性的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面来一起看看吧2018-09-09
iOS应用开发中导航栏按钮UIBarButtonItem的添加教程
这篇文章主要介绍了iOS应用开发中导航栏按钮UIBarButtonItem的添加教程,文中详细介绍了使用UINavigationController导航控制器添加的过程,需要的朋友可以参考下2016-02-02


最新评论