Skip to content

Instantly share code, notes, and snippets.

@soapyigu
Last active September 17, 2019 16:57
Show Gist options
  • Save soapyigu/11b1c85051b1c43b32c44d814d34f6f3 to your computer and use it in GitHub Desktop.
Save soapyigu/11b1c85051b1c43b32c44d814d34f6f3 to your computer and use it in GitHub Desktop.
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
NotificationCenter.default.addObserver(self, selector: Selector(("volumeDidChange:")), name: NSNotification.Name(rawValue: "AVSystemController_SystemVolumeDidChangeNotification"), object: nil)
return true
}
func volumeDidChange(notification: NSNotification) {
let volume = notification.userInfo!["AVSystemController_AudioVolumeNotificationParameter"] as! Float
// Volume at your service
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment