这篇文章主要介绍了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 之间发送通知
				
        
 
            
        
             猜你喜欢
        
	     - Android实现轮询的三种方式 2023-02-17
 - Flutter实现底部和顶部导航栏 2022-08-31
 - SurfaceView播放视频发送弹幕并实现滚动歌词 2023-01-02
 - Android studio实现动态背景页面 2023-05-23
 - 详解flutter engine 那些没被释放的东西 2022-12-04
 - Android实现监听音量的变化 2023-03-30
 - Android MaterialButton使用实例详解(告别shape、selector) 2023-06-16
 - iOS 对当前webView进行截屏的方法 2023-03-01
 - 最好用的ios数据恢复软件:PhoneRescue for Mac 2023-09-14
 - 作为iOS开发,这道面试题你能答出来,说明你基础很OK! 2023-09-14
 
						
						
						
						
						
				
				
				
				