I am trying to change the sound of a deleted message
I added the file to my project, see figure 1

I also added everything to my AppDelegate. In didFinishLaunchingWithOptions, I added:
if (UIDevice.currentDevice().systemVersion as NSString).floatValue >= 8.0 {
UIApplication.sharedApplication().registerUserNotificationSettings(UIUserNotificationSettings(forTypes: .Sound | .Alert | .Badge, categories: nil))
UIApplication.sharedApplication().registerForRemoteNotifications()
} else {
UIApplication.sharedApplication().registerForRemoteNotificationTypes(.Badge | .Sound | .Alert)
}
UIApplication.sharedApplication().applicationIconBadgeNumber = 0
UIApplication.sharedApplication().cancelAllLocalNotifications()
Other methods implemented by me:
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
let deviceTokenString = deviceToken.hexString
println(deviceTokenString)
let task = service.writeForNotifications(token: deviceTokenString, completionHandler: {
})
task.resume()
}
func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {
println("Failed to get token: \(error)")
}
Received from Json service I:
{"aps":{"alert":"The push message!", "sound":"ice.caf"}}
I'm not sure I decided to forget to change the notification sound? When I receive a notification, it always plays the default sound.
source
share