这篇文章主要介绍了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 之间发送通知的相关内容,希望对大家有所帮助!
织梦狗教程
本文标题为:IOS如何在Host App 与 App Extension 之间发送通知


基础教程推荐
猜你喜欢
- iOS开发教程之XLForm的基本使用方法 2023-05-01
- Flutter绘图组件之CustomPaint使用详解 2023-05-12
- IOS 播放系统提示音使用总结(AudioToolbox) 2023-03-01
- Android中的webview监听每次URL变化实例 2023-01-23
- Android开发使用RecyclerView添加点击事件实例详解 2023-06-15
- IOS应用内跳转系统设置相关界面的方法 2022-11-20
- android studio按钮监听的5种方法实例详解 2023-01-12
- Flutter手势密码的实现示例(附demo) 2023-04-11
- 解决Android Studio突然不显示logcat日志的问题 2023-02-04
- Android多返回栈技术 2023-04-15