首页 > 系统 > iOS > 正文

教你如何在Host App 与 App Extension 之间发送通知

2020-02-19 15:50:08
字体:
来源:转载
供稿:网友

开发人员在开发过程中都会通过扩展点指定特定的系统功能,比如通知栏扩展、消息扩展、电话簿扩展等等都可以使用到,今天武林技术频道小编搜罗整理了相关资讯,感兴趣的网友们可别错过那么好的机会哦!

// 发送通知- (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);}

以上内容给大家简单介绍了教你如何在Host App 与 App Extension 之间发送通知,希望对大家有所帮助,同时也感谢大家继续支持武林技术频道!

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表