Uploaded image for project: 'AeroGear'
  1. AeroGear
  2. AEROGEAR-4727

Cordova Push Plugin crashes Android app in background when a notification with an empty alert string is sent

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • None
    • None
    • push
    • None

    Description

      If a configuration string with either no alert field or an alert field with an empty string is sent to a cordova Android app that is in the background, the plugin crashes the app. When the App is in the foreground, the notification works OK.

      e.g. if the following confirmation payload is passed to the Android variant on a Push server

      {
      variants => [ "Android variant String" ] ,
      alias => [ "Android device" ] ,
      ttl => 600 ,
      message => {
      data =>

      { Verb => "GetDisruptions" }
      }

      when the Android Cordova app is simply in the background, then a message pops up saying the app has stopped.

      {
      variants => [ "Android variant String" ] ,
      alias => [ "Android device" ] ,
      ttl => 600 ,
      message => {
      alert => "Notification" ,
      data => { Verb => "GetDisruptions" }

      }

      If you add an alert string with something in it, then there is no crash. However alert => "" will still cause a crash.

      It appears to be related to this line
      54 if (!PushPlugin.isInForeground() && message.getString("alert").length() != 0)

      in the github repository aerogear-cordova-push/src/android/org/jboss/aerogear/cordova/push/NotificationMessageHandler.java

      I think the behaviour should be that when a notification is received in the background without and alert field OR and an empty alert field string, a call is simply made to the notification handler and NO notification is displayed. This would mimic the content-available:1 flag in iOS.

      Rob

      Attachments

        Activity

          People

            edewit1@redhat.com Erik Jan de Wit
            rwillett_jira Rob Willett (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: