Skip to content

Commit

Permalink
Issue phonegap#207: Use default type_ringtone for android
Browse files Browse the repository at this point in the history
  • Loading branch information
macdonst authored and sud80 committed Jan 29, 2016
1 parent 2301364 commit e0c4697
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/PAYLOAD.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ Produces the following notification.

## Sound

For Android there are two special values for sound you can use. The first is `default` which will play the phones default notification sound. Then second is `ringtone` which will play the phones default ringtone sound.

In order for your your notification to play a custom sound you will need to add the files to your Android project's `res/raw` directory. Then send the follow JSON from GCM:

```javascript
Expand Down
4 changes: 3 additions & 1 deletion src/android/com/adobe/phonegap/push/GCMIntentService.java
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,9 @@ private void setNotificationSound(Context context, Bundle extras, NotificationCo
if (soundname == null) {
soundname = extras.getString(SOUND);
}
if (soundname != null && !soundname.contentEquals(SOUND_DEFAULT)) {
if (SOUND_RINGTONE.equals(soundname)) {
mBuilder.setSound(android.provider.Settings.System.DEFAULT_RINGTONE_URI);
} else if (soundname != null && !soundname.contentEquals(SOUND_DEFAULT)) {
Uri sound = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE
+ "://" + context.getPackageName() + "/raw/" + soundname);
Log.d(LOG_TAG, sound.toString());
Expand Down
1 change: 1 addition & 0 deletions src/android/com/adobe/phonegap/push/PushConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public interface PushConstants {
public static final String ICON_COLOR = "iconColor";
public static final String SOUND = "sound";
public static final String SOUND_DEFAULT = "default";
public static final String SOUND_RINGTONE = "ringtone";
public static final String VIBRATE = "vibrate";
public static final String ACTIONS = "actions";
public static final String CALLBACK = "callback";
Expand Down

0 comments on commit e0c4697

Please sign in to comment.