操作系统底层支持了一些预置的通知消息,这些通知消息在头文件notify_keys.h中被声明。这些预置的消息有针对目录服务的、有针对磁盘空间和卷挂起的、有针对网络配置改变的、有针对写日志通知的、有针对系统时区和时间改变的。每种具体的通知消息可以看文件中的说明,比如下面的例子实现对了对磁盘空间不足,网络状态改变以及对调整了系统的时间进行的监听处理:
- #include <notify.h>
- #include <notify_keys.h>
-
- void foo()
- {
- int token1, token2, token3;
- //注册监听网络状态改变的通知。
- notify_register_dispatch(kNotifySCNetworkChange, & token1, dispatch_get_main_queue(), ^(int token) {
- //...
- });
-
-
- //注册监听系统磁盘空间不足的通知
- notify_register_dispatch(kNotifyVFSLowDiskSpaceRootFS, &token2, dispatch_get_main_queue(), ^(int token) {
- //....
- });
-
-
- //注册监听系统时间被改变的通知。
- notify_register_dispatch(kNotifyClockSet, &token3, dispatch_get_main_queue(), ^(int token) {
- //...
- });
-
- }
除了notify_keys.h文件中公开的通知消息外,还有一些未被公开的通知消息,我们可以通过这些未被公开的消息来获取更多关于系统状态的改变,下面的列表将列出所有的系统底层的通知消息,具体每个通知是什么意义就读者自行猜测和验证吧。
- "com.apple.asl.remote"
- "com.apple.system.timezone"
- "com.apple.MCX._managementStatusChangedForDomains"
- "com.apple.CFPreferences._domainsChangedExternally"
- "com.apple.system.clock_set"
- "com.apple.system.timezone"
- "AppleNumberPreferencesChangedNotification"
- "AppleTimePreferencesChangedNotification"
- "AppleDatePreferencesChangedNotification"
- "AppleLanguagePreferencesChangedNotification"
- "AppleTextBehaviorPreferencesChangedNotification"
- "com.apple.librarian.account-token-changed"
- "com.apple.system.batterysavermode"
- "com.apple.accessibility.cache.forcetouch.sensitivity.changed"
- "com.apple.networkd.started"
- "com.apple.neconfigurationchanged"
- "com.apple.networkd.settings"
- "com.apple.system.config.network_change"
- "com.apple.CoreAnimation.CAWindowServer.DisplayChanged"
- "com.apple.networkd.proxy_count"
- "com.apple.iohideventsystem.available"
- "com.apple.backboardd.rawOrientation"
- "com.apple.springboard.hasBlankedScreen"
- "UIBacklightLevelChangedNotification"
- "com.apple.accessibility.wob.status"
- "com.apple.backboardd.videosettingschanged"
- "com.apple.mobile.keybagd.user_changed"
- "com.apple.LaunchServices.database"
- "com.apple.accessibility.cache.enhance.text.legibility"
- "com.apple.frontboard.systemappservices.serverNotifyToken"
- "com.apple.frontboard.workspace.serverNotifyToken"
- "com.apple.accessibility.cache.captioning"
- "com.apple.accessibility.cache.vot"
- "com.apple.accessibility.cache.ax"
- "com.apple.accessibility.cache.app.ax"
- "com.apple.accessibility.status"
- "com.apple.language.changed"
- "com.apple.springboard.showingAlertItem"
- "com.apple.mobile.keybagd.lock_status"
- "NameLayerTree"
- "ApplePreferredContentSizeCategoryChangedNotification"
- "kKeepAppsUpToDateEnabledChangedNotification"
- "com.apple.accessibility.cache.reduce.motion"
- "UIKeyboardSpringBoardKeyboardShow"
- "UIKeyboardSpringBoardKeyboardHide"
- "com.apple.locationd.registration"
- "kCTDaemonReadyNotification"
- "com.apple.system.config.network_change"
- "com.apple.system.timezone./var/db/timezone/zoneinfo/UTC"
- "com.apple.system.info:/etc/hosts"
- "com.apple.MSVLoggingConfigurationDidChange"
- "com.apple.managedconfiguration.defaultsdidchange"
- "com.apple.AppSupport.loggingDefaultsChanged"
- "com.apple.mobileipod.MPMusicPlayerController.launched"
- "com.apple.networkd.nat64.ifstate"
- "com.apple.ManagedConfiguration.profileListChanged"
- "com.apple.backboardd.unambiguousOrientation"
- "com.apple.accessibility.cache.button.shapes.enabled"
- "com.apple.accessibility.cache.use.single.system.color.enabled"
- "com.apple.accessibility.cache.darken.system.colors.enabled"
- "com.apple.coreui.statistics"
- "com.apple.UIKit.UIScreenEdgeGestureMode"
- "com.apple.managedconfiguration.restrictionchanged"
- "com.apple.managedconfiguration.passcodechanged"
- "PINPolicyChangedNotification"
- "com.apple.managedconfiguration.settingschanged"
- "com.apple.managedconfiguration.effectivesettingschanged"
- "com.apple.managedconfiguration.appwhitelistdidchange"
- "com.apple.managedconfiguration.defaultsdidchange"
- "com.apple.managedconfiguration.keyboardsettingschanged"
- "com.apple.managedconfiguration.clientrestrictionschanged"
- "com.apple.managedconfiguration.webFilterUIActiveDidChange"
- "com.apple.ManagedConfiguration.managedAppsChanged"
- "MCManagedBooksChanged"
- "com.apple.managedconfiguration.allowpasscodemodificationchanged"
- "com.apple.mediaserverd.up"
- "com.apple.hangtracer.prefchangednotification"
- "com.apple.accessibility.cache.enhance.background.contrast"
- "com.apple.system.thermalpressurelevel"
- "com.apple.backboardd.backlight.changed"
- "com.apple.accessibility.QuickSpeakEnabled"
- "com.apple.accessibility.cache.quick.speak"
- "com.apple.powerlog.state_changed"
- "com.apple.powerlog.clientPermissionState"
(编辑:威海站长网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|