Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android: JSON shown instead of notification body and title #135

Closed
plato-cambrian opened this issue Jul 1, 2015 · 4 comments
Closed

Android: JSON shown instead of notification body and title #135

plato-cambrian opened this issue Jul 1, 2015 · 4 comments

Comments

@plato-cambrian
Copy link

I'm trying to deliver chat messages to my mobile app. Here is the generated message, right before I call sender.send():

{ collapseKey: undefined,
  delayWhileIdle: undefined,
  timeToLive: undefined,
  dryRun: undefined,
  data:
   { message:
      { soproModel: 'message',
        authorId: 'identity-jimmy',
        text: 'u work',
        ts: '1435773467.318',
        attachments: [],
        channelId: 'channel-ship-devs',
        _id: '289e3dbc-976d-4311-b2f3-4c32136c4ce0',
        _rev: '1-710404eeaf81565bed1ed33891d61a57' } },
  notification:
   { title: 'Message from #ship-devs',
     body: 'u work',
     icon: 'myicon.png',
     sound: 'https://ship.hn/web/audio/cuak.mp3' } }

The message is delivered to the phone, and if the app is in the background, a notification pops up in my drawer.

The problem is the notification has no title, and the body string is the json representation of my message field.

I'm handling the notification with AppGyver/push-notifications. I'm calling pushNotification.onMessageInBackground(messageInBackgroundHandler,errorHandler); and logging the notification object that these functions get, it looks like this:

"{
  "timestamp": "2015-07-01T17:57Z",
  "message": "{\"_rev\":\"1-710404eeaf81565bed1ed33891d61a57\",\"soproModel\":\"message\",\"text\":\"u work\",\"_id\":\"289e3dbc-976d-4311-b2f3-4c32136c4ce0\",\"ts\":\"1435773467.318\",\"channelId\":\"channel-ship-devs\",\"attachments\":[],\"authorId\":\"identity-jimmy\"}",
  "collapse_key": "do_not_collapse",
  "coldstart": false,
  "payload": {
    "message": {
      "_rev": "1-710404eeaf81565bed1ed33891d61a57",
      "soproModel": "message",
      "text": "u work",
      "ts": "1435773467.318",
      "_id": "289e3dbc-976d-4311-b2f3-4c32136c4ce0",
      "channelId": "channel-ship-devs",
      "attachments": [],
      "authorId": "identity-jimmy",
      "$$hashKey": "object:64"
    },
    "gcm.notification.title": "Message from #ship-devs",
    "gcm.notification.icon": "myicon.png",
    "gcm.notification.sound": "https://ship.hn/web/audio/cuak.mp3",
    "gcm.notification.body": "u work"
  },
  "uuid": "0be45002-dbb3-4ece-9755-e4a89ab6bc4f",
  "from": "156632312728",
  "foreground": false
}"

What must I do to configure my notification?

@plato-cambrian
Copy link
Author

Possibly relevant #131

@hypesystem
Copy link
Collaborator

The functionality in #131 was added in version 0.10 (PR #127). I assume this is the code you are using.

I have no idea about AppGyver, etc., so I am at a bit of a loss here.

@plato-cambrian
Copy link
Author

Thanks @hypesystem. I am using 0.10.
So, assuming a correct reference implementation on the phone, what I'm sending should automatically show up in the notification drawer with body and title, right?

@hypesystem
Copy link
Collaborator

Yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants