expo: [expo-notifications][bare] Android push handling crashes due to SoundResolver

πŸ› Bug Report

@sjchmiela I’m seeing this crash in my bare app when upgrading expo-notifications from 1.2 -> 1.4. I think the issue was introduced when you added support for custom sound on android. Now, I can’t get the push to work if I dont have a custom sound configured (i.e. I just want the default sound)

Environment


  Expo CLI 3.20.1 environment info:
    System:
      OS: macOS 10.15.3
      Shell: 5.7.1 - /bin/zsh
    Binaries:
      Node: 12.14.0 - ~/.nodenv/versions/12.14.0/bin/node
      Yarn: 1.12.1 - ~/.yarn/bin/yarn
      npm: 6.13.4 - ~/.nodenv/versions/12.14.0/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    IDEs:
      Android Studio: 3.5 AI-191.8026.42.35.6010548
      Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild
    npmPackages:
      @expo/webpack-config: 0.11.17 => 0.11.17 
      expo: ^37.0.0 => 37.0.3 
      react: ~16.9.0 => 16.9.0 
      react-dom: 16.9.0 => 16.9.0 
      react-native: ~0.61.5 => 0.61.5 
      react-native-web: ^0.11.7 => 0.11.7 

Bare expo

Steps to Reproduce

Send a push notification to android via expo push tool with expo-notifications@1.4.0.

fetch("https://exp.host/--/api/v2/push/send", {
  "headers": {
    "accept": "application/json",
    "accept-language": "en-US,en;q=0.9,es-US;q=0.8,es;q=0.7",
    "content-type": "application/json",
    "sec-fetch-dest": "empty",
    "sec-fetch-mode": "cors",
    "sec-fetch-site": "cross-site"
  },
  "referrer": "https://expo.io/",
  "referrerPolicy": "origin",
  "body": "[{\"to\":\"ExponentPushToken[...]\",\"title\":\"test\",\"body\":\"this\",\"sound\":\"default\",\"data\":{},\"channelId\":\"bedtime-checklist\"}]",
  "method": "POST",
  "mode": "cors",
  "credentials": "omit"
});

Expected Behavior

Push is displayed in notification tray

Actual Behavior

05-04 14:11:55.223 29457 29526 E AndroidRuntime: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
05-04 14:11:55.223 29457 29526 E AndroidRuntime:        at java.lang.String.substring(String.java:2064)
05-04 14:11:55.223 29457 29526 E AndroidRuntime:        at expo.modules.notifications.notifications.SoundResolver.resolve(SoundResolver.java:35)
05-04 14:11:55.223 29457 29526 E AndroidRuntime:        at expo.modules.notifications.notifications.JSONNotificationContentBuilder.getSound(JSONNotificationContentBuilder.java:109)
05-04 14:11:55.223 29457 29526 E AndroidRuntime:        at expo.modules.notifications.notifications.JSONNotificationContentBuilder.shouldPlayDefaultSound(JSONNotificationContentBuilder.java:96)
05-04 14:11:55.223 29457 29526 E AndroidRuntime:        at expo.modules.notifications.notifications.JSONNotificationContentBuilder.setPayload(JSONNotificationContentBuilder.java:41)
05-04 14:11:55.223 29457 29526 E AndroidRuntime:        at expo.modules.notifications.FirebaseListenerService.createNotification(FirebaseListenerService.java:94)
05-04 14:11:55.223 29457 29526 E AndroidRuntime:        at expo.modules.notifications.FirebaseListenerService.onMessageReceived(FirebaseListenerService.java:85)
05-04 14:11:55.223 29457 29526 E AndroidRuntime:        at com.google.firebase.messaging.FirebaseMessagingService.zzc(com.google.firebase:firebase-messaging@@20.1.0:78)
05-04 14:11:55.223 29457 29526 E AndroidRuntime:        at com.google.firebase.messaging.zze.run(com.google.firebase:firebase-messaging@@20.1.0:2)
05-04 14:11:55.223 29457 29526 E AndroidRuntime:        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
05-04 14:11:55.223 29457 29526 E AndroidRuntime:        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
05-04 14:11:55.223 29457 29526 E AndroidRuntime:        at com.google.android.gms.common.util.concurrent.zza.run(Unknown Source:6)
05-04 14:11:55.223 29457 29526 E AndroidRuntime:        at java.lang.Thread.run(Thread.java:919)

Reproducible Demo

Can work on a minimal repro if the issue isn’t apparent.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (11 by maintainers)

Commits related to this issue

Most upvoted comments

Hi @awinograd! Thanks again for the detailed issue report! We will get on this. πŸ˜„