Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
…push into v2.0.x
  • Loading branch information
macdonst committed Apr 29, 2017
2 parents 7371f3b + 3a1806a commit 96af638
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 11 deletions.
31 changes: 20 additions & 11 deletions docs/PAYLOAD.md
Original file line number Diff line number Diff line change
Expand Up @@ -401,22 +401,31 @@ Finally the Material UI guidelines recommend using a circular icon for the large
}
```

Here is an example using node-gcm that sends the above JSON:
Here is an example using fcm-node that sends the above JSON:

```javascript
var gcm = require('node-gcm');
var FCM = require('fcm-node');
// Replace these with your own values.
var apiKey = "replace with API key";
var deviceID = "my device id";
var service = new gcm.Sender(apiKey);
var message = new gcm.Message();
message.addData('title', 'Large Circular Icon');
message.addData('message', 'Loaded from URL');
message.addData('image', 'https://pbs.twimg.com/profile_images/837060031895896065/VHIQ4oUf_400x400.jpg');
message.addData('image-type', 'circular');
service.send(message, { registrationTokens: [ deviceID ] }, function (err, response) {
if(err) console.error(err);
else console.log(response);
var fcm = new FCM(apiKey);

var message = {
to: deviceID,
data: {
title: 'Large Icon',
message: 'Loaded from URL',
image: 'https://dl.dropboxusercontent.com/u/887989/antshot.png'
}
};

fcm.send(message, function(err, response){
if (err) {
console.log(err);
console.log("Something has gone wrong!");
} else {
console.log("Successfully sent with response: ", response);
}
});
```

Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"name": "phonegap-plugin-push",
"description": "Register and receive push notifications.",
<<<<<<< HEAD
"types": "./types/index.d.ts",
=======
>>>>>>> 3a1806aaec5d3c76f7fcd30ddfd85d576fb6d197

This comment has been minimized.

Copy link
@gianpaj

gianpaj May 4, 2017

Contributor

merge conflict :/

This comment has been minimized.

Copy link
@fredgalvao

fredgalvao May 4, 2017

Collaborator

Thanks, fixed in 974d2e2

This comment has been minimized.

Copy link
@macdonst

macdonst via email May 5, 2017

Author Member
"version": "2.0.0-rc2",
"homepage": "http://github.com/phonegap/phonegap-plugin-push#readme",
"repository": {
Expand Down
12 changes: 12 additions & 0 deletions src/android/com/adobe/phonegap/push/FCMService.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,18 @@ public void onMessageReceived(RemoteMessage message){
extras.putString(entry.getKey(), entry.getValue());
}

Log.d(LOG_TAG, "onMessage - from: " + message.getFrom());

Bundle extras = new Bundle();

if (message.getNotification()!=null) {
extras.putString(TITLE,message.getNotification().getTitle());
extras.putString(MESSAGE,message.getNotification().getBody());
}
for (Map.Entry<String, String> entry : message.getData().entrySet()) {
extras.putString(entry.getKey(), entry.getValue());
}

if (extras != null && isAvailableSender(from)) {
Context applicationContext = getApplicationContext();

Expand Down

0 comments on commit 96af638

Please sign in to comment.