开发人员在开发过程中都会通过扩展点指定特定的系统功能,比如通知栏扩展、消息扩展、电话簿扩展等等都可以使用到,今天中国E盟技术频道小编搜罗整理了相关资讯,感兴趣的网友们可别错过那么好的机会哦!
// 发送通知
- (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 之间发送通知,希望对大家有所帮助,同时也感谢大家继续支持中国E盟技术频道!





