Notification Sound/Ringtone

I would like to give the user the ability to change the notification sound through the use of a RingtonePreference. Currently I am using the NotificationFactory to set the sound like so:

 

    DefaultNotificationFactory factory = (DefaultNotificationFactory)

                    UAirship.shared().getPushManager().getNotificationFactory();

    factory.setSound(Uri.parse(path));

 

But this method only seems to set the ringtone if the app is open, as soon as the app is closed the notification sound reverts to the device default.

I am currently running the latest version, 7.0.3, but I had been running 6.3.1 with the same issue.

Didn't find what you were looking for?

New post

Comments

1 comment

  • Hello Bryan,

    The way you're setting the new sound and when the notification sound reverts to the device default sounds like this is expected.

    I'm guessing the way you have it set right now is that when the user chooses a sound, you set the sound straight away and leave it at that. However, you haven't set reset the notification factory that is defined in your Application class. Thus, when the app starts back up, it uses the sound it had before, which was the default sound.

     

    So, there are two ways you can do this:

    1) When you set the new sound on the factory, make sure you tell Airship about the new factory and set it

    airship.getPushManager().setNotificationFactory(factory);

    2) Use the SharedPreferences class to store the path to the sound file your user just specified, and tell your Application class to use that path from the SharedPreferences class.

    http://developer.android.com/guide/topics/data/data-storage.html

     

    0

Please sign in to leave a comment.