当前位置: 移动技术网 > 移动技术>移动开发>IOS > IOS如何在Host App 与 App Extension 之间发送通知

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

2019年07月24日  | 移动技术网移动技术  | 我要评论

如何从你的一个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 之间发送通知的相关内容,希望对大家有所帮助!

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网