手机
当前位置:查字典教程网 >编程开发 >IOS开发 >IOS如何在Host App 与 App Extension 之间发送通知
IOS如何在Host App 与 App Extension 之间发送通知
摘要:如何从你的一个App发送通知给另一个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 之间发送通知的相关内容,希望对大家有所帮助!

【IOS如何在Host App 与 App Extension 之间发送通知】相关文章:

iOS开发:学习笔记—变量、属性、方法、实现

iOS系统Crash文件分析方法

详解在iOS App中自定义和隐藏状态栏的方法

IOS中UIWebView的使用详解

简单掌握iOS应用开发中sandbox沙盒的使用

Swift 共享文件操作小结(iOS 8 +)

iOS实时监控网络状态的改变

如何实现IOS_SearchBar搜索栏及关键字高亮

iOS应用开发中图片的拉伸问题解决方案

如何在iphon IOS设备上使用二维码

精品推荐
分类导航