zoukankan      html  css  js  c++  java
  • iOS 在Host App 与 App Extension 之间发送通知

    如何从你的一个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);
    }
  • 相关阅读:
    Python
    QinQ 技术解析
    TLS/SSL 协议
    TLS/SSL 协议
    TLS/SSL 协议
    排序算法之基本排序算法(冒泡、插入、选择)
    Spring Boot 学习笔记--手写版
    mysql -- collection一对多查询
    mybatis 批量操作增删改查
    easyUI之datagrid绑定后端返回数据的两种方式
  • 原文地址:https://www.cnblogs.com/qq744890760/p/5237904.html
Copyright © 2011-2022 走看看