IOS如何在Host App 与 App Extension 之间发送通知
如何从你的一个App发送通知给另一个App?(例:搜狗输入法下载皮肤完成后使用皮肤)注:搜狗输入法是App、而键盘是Extension
当你为你的App添加AppExtension时,如果想在App发送通知给Extension或许这篇文章可以帮助你。
了解更多内容
//发送通知
-(void)postNotificaiton{
CFNotificationCenterRefnotification=CFNotificationCenterGetDarwinNotifyCenter();
CFNotificationCenterPostNotification(notification,CFSTR("<notificaitonname>"),NULL,NULL,YES);
}
//接收通知
-(void)receiveNotification{
CFNotificationCenterRefnotification=CFNotificationCenterGetDarwinNotifyCenter();
CFNotificationCenterAddObserver(notification,(__bridgeconstvoid*)(self),observerMethod,CFSTR("<notificaitonname>"),NULL,CFNotificationSuspensionBehaviorDeliverImmediately);
}
voidobserverMethod(CFNotificationCenterRefcenter,void*observer,CFStringRefname,constvoid*object,CFDictionaryRefuserInfo)
{
//Yourcustomwork
}
//移除通知
-(void)removeNotification
{
CFNotificationCenterRefnotification=CFNotificationCenterGetDarwinNotifyCenter();
CFNotificationCenterRemoveObserver(notification,(__bridgeconstvoid*)(self),CFSTR("<notificaitonname>"),NULL);
}
以上内容给大家简单介绍了IOS如何在HostApp与AppExtension之间发送通知的相关内容,希望对大家有所帮助!
热门推荐
10 财运虎年祝福语简短语
11 单亲爸爸春节祝福语简短
12 狗狗上厕所训练
13 植物种植祝福语简短
14 翻译考试祝福语朋友简短
15 个人周年庆简短祝福语
16 狗狗怎么训练
17 分别祝福语简短搞笑英文
18 生日广州男生祝福语简短