Play song in Notification
问题 I want to play a song. When a notification comes. My code is working fine when the app is foreground mode. I want to play a song when the app is in background mode. Please help. 回答1: Add custom sound to your local notification Swift 3.0 func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) { var state: UIApplicationState = application.applicationState if state == .active { var soundID: SystemSoundID var mainBundle: CFBundleRef =