Git Product home page Git Product logo

Comments (3)

noman404 avatar noman404 commented on August 27, 2024

Similar Problem Here

from phonegap-parse-plugin.

grrrian avatar grrrian commented on August 27, 2024

Did you try the instructions in plugin.xml to allow notifications when the app is closed?

from phonegap-parse-plugin.

BarakChamo avatar BarakChamo commented on August 27, 2024

I fixed this problem with some help on SO.

The problem, as described in the thread, is that Parse uses a different data structure for their Push service and assigns the message to the alert key with different handlers assigned to handle notifications. What I ended up doing is cloning PushPlugin and editing the problematic lines in place:

if (extras != null) {
  /*
    Original Interceptor
  */ 

  // // if we are in the foreground, just surface the payload, else post it to the statusbar
  // if (PushPlugin.isInForeground()) {
  //   extras.putBoolean("foreground", true);
  //   PushPlugin.sendExtras(extras);
  // } else {
  //   extras.putBoolean("foreground", false);

  //   // Send a notification if there is a message
  //   if (extras.getString("message") != null && extras.getString("message").length() != 0) {
  //     createNotification(context, extras);
  //   }
  // }


  /*
    Parse Fix
  */ 
  if (PushPlugin.isInForeground()) {

    extras.putBoolean("foreground", true);
    PushPlugin.sendExtras(extras);

  } else if (extras.getString("message") != null && !extras.getString("message").isEmpty()) {

    extras.putBoolean("foreground", false);
    createNotification(context, extras);

  } else {
    try{
      JSONObject data = new JSONObject(extras.getString("data"));
      // JSONObject data = payload.getJSONObject("data");
      String message = data.getString("alert"); //parse puts the message as an alert if you don't use custom json payload
      extras.putString("message", message);
      createNotification(context, extras);
    }
    catch (JSONException e)
    {
      Log.d(TAG, "Notification JSON Prase Error");
    }     
  }
}

from phonegap-parse-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.