Beaconstac / NearBee-iOS-SDK

Beaconstac NearBee SDK for iOS
https://www.beaconstac.com
MIT License
1 stars 1 forks source link

Adding sound when receiving notifications #8

Closed JoeyBodnar closed 5 years ago

JoeyBodnar commented 5 years ago

I am looking into adding a sound to when the notification is received. From what I can see, it looks like this must be added on the sending end of the notification when creating an instance of UNMutableNotificationContent (https://developer.apple.com/documentation/usernotifications/unmutablenotificationcontent)

Is there currently a sound being specified? If not is there some way to add that ability? See also https://stackoverflow.com/questions/42318209/swift-unusernotification-does-not-trigger-sound

sachinmobstac commented 5 years ago

@JoeyBodnar, I have included a notificationSoundName property in the SDK. Please go through the documentation for integration notes.

JoeyBodnar commented 5 years ago

I have tried that method but it doesn't seem to be working. No sound is played. This is my code:

if let url = Bundle.main.url(forResource: "notification", withExtension: "mp3") {
    nearBee.notificationSound = UNNotificationSoundName(rawValue: url.lastPathComponent)
}

and here is the location of the mp3 file in my project tree:

Screen Shot 2019-06-20 at 1 42 01 AM

Also, I tested with local notifications (custom notifications I can create using UNMutableNotificationContent, and the sound did work for me. But it doesn't with the actual notifications from NearBee.

sachinmobstac commented 5 years ago

Hi @JoeyBodnar, Please enable the sound by set UserDefaults.standard.setValue(true, forKey: "NearBeeToggleSound")