若何從你的一個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 之間發送告訴】的相關資料介紹到這裡,希望對您有所幫助! 提示:不會對讀者因本文所帶來的任何損失負責。如果您支持就請把本站添加至收藏夾哦!