I figured out a solution. This is not available through Parse's API yet but they do have documentation which explains how to extend their ParsePushBroadcastReceiver.
So create a class which extends the ParsePushBroadcastReceiver, and onReceive call a method generateNotification and write the custom code to create a custom notification of your own there. This way, you can include a sound. First of all, you would need to add the new sound file (ex mp3) to a raw directory in the resources / res folder.
By the way, don't forget to change the ParsePushBroadcastReceiver receiver from the manifest to reflect your new file. Example:
<receiver android:name="com.parse.ParsePushBroadcastReceiver"
android:exported="false">
to
<receiver android:name="com.*my_package_name*.MyBroadcastReceiver"
android:exported="false">
Here's my code. It works and it's reusable.
public class MyBroadcastReceiver extends ParsePushBroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
try {
String jsonData = intent.getExtras().getString("com.parse.Data");
JSONObject json = new JSONObject(jsonData);
String title = null;
if(json.has("title")) {
title = json.getString("title");
}
String message = null;
if(json.has("alert")) {
message = json.getString("alert");
}
if(message != null) {
generateNotification(context, title, message);
}
} catch(Exception e) {
Log.e("NOTIF ERROR", e.toString());
}
}
private void generateNotification(Context context, String title, String message) {
Intent intent = new Intent(context, MainActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, intent, 0);
NotificationManager mNotifM = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
if(title == null) {
title = context.getResources().getString(R.string.app_name);
}
final NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.icon)
.setContentTitle(title)
.setContentText(message)
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(message))
.addAction(0, "View", contentIntent)
.setAutoCancel(true)
.setDefaults(new NotificationCompat().DEFAULT_VIBRATE)
.setSound(Uri.parse("android.resource://" + context.getPackageName() + "/" + R.raw.whistle));
mBuilder.setContentIntent(contentIntent);
mNotifM.notify(NOTIFICATION_ID, mBuilder.build());
}
}