Skip to content

Commit 652d50b

Browse files
committed
Setting sound to "null" or "nil" now disables it
1 parent 11dc754 commit 652d50b

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

OneSignalSDK.jar

999 Bytes
Binary file not shown.

OneSignalSDK/onesignal/src/main/java/com/onesignal/GenerateNotification.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ private static NotificationCompat.Builder getBaseNotificationCompatBuilder(JSONO
251251
if (bigPictureIcon != null)
252252
notifBuilder.setStyle(new NotificationCompat.BigPictureStyle().bigPicture(bigPictureIcon).setSummaryText(message));
253253

254-
if (OneSignal.getSoundEnabled(currentContext)) {
254+
if (isSoundEnabled(gcmBundle)) {
255255
Uri soundUri = getCustomSound(gcmBundle);
256256
if (soundUri != null)
257257
notifBuilder.setSound(soundUri);
@@ -677,10 +677,17 @@ private static int getDrawableId(String name) {
677677
return contextResources.getIdentifier(name, "drawable", packageName);
678678
}
679679

680+
private static boolean isSoundEnabled(JSONObject gcmBundle) {
681+
String sound = gcmBundle.optString("sound", null);
682+
if ("null".equals(sound) || "nil".equals(sound))
683+
return false;
684+
return OneSignal.getSoundEnabled(currentContext);
685+
}
686+
680687
private static Uri getCustomSound(JSONObject gcmBundle) {
681688
int soundId;
682689
String sound = gcmBundle.optString("sound", null);
683-
690+
684691
if (isValidResourceName(sound)) {
685692
soundId = contextResources.getIdentifier(sound, "raw", packageName);
686693
if (soundId != 0)

OneSignalSDK/onesignal/src/main/java/com/onesignal/OneSignal.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public void init() {
167167
private static TrackGooglePurchase trackGooglePurchase;
168168
private static TrackAmazonPurchase trackAmazonPurchase;
169169

170-
public static final String VERSION = "030101";
170+
public static final String VERSION = "030200";
171171

172172
private static AdvertisingIdentifierProvider mainAdIdProvider = new AdvertisingIdProviderGPS();
173173

0 commit comments

Comments
 (0)