Skip to content

Commit af07b14

Browse files
android notification completed
1 parent c0afdd9 commit af07b14

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

lib/android.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,8 @@ function buildPayload(data) {
8686
if(data.title) {
8787
message.notification.title = data.title;
8888
}
89-
if(data.title) {
90-
message.notification.title = data.title;
91-
}
92-
if(data.icon_file) {
93-
message.notification.icon = data.icon_file;
89+
if(data.icon_file || data.icon) {
90+
message.notification.icon = data.icon_file || data.icon;
9491
}
9592
}
9693
message.data = {};

tests/index.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,23 @@ describe("Notification", function() {
88
this.timeout(15000);
99
var Notification = require("../index"), notification;
1010
before(function() {
11+
1112
notification = new Notification();
1213
global.RootPath = path.resolve("");
1314
var key = global.RootPath + "/tests/assets/key.pem";
1415
var cert = global.RootPath + "/tests/assets/cert.pem";
1516
notification.setupIOSClient(key,cert,key,cert);
16-
var apiKey = "AIzaSyDQYDoblHHlcT8p6E6cfsMDlNAOYTX6QY4";
17+
var apiKey = "please you api key here";
1718
notification.setupAndroidClient(apiKey);
1819

1920
notification.onTransmitted = function onTransmitted() {
20-
console.log("its done android");
2121
console.log("onTransmitted", JSON.stringify(arguments));
2222
};
23+
2324
notification.onTransmissionError = function onTransmissionError() {
2425
console.log("onTransmissionError", arguments);
2526
};
27+
2628
console.log("init");
2729
});
2830

@@ -36,12 +38,11 @@ describe("Notification", function() {
3638
});
3739

3840
it("sendNotificationGCM", function(done) {
39-
40-
notification.send([{push_token : "eg54Hko_H0A:APA91bFESaL7T_wBOrGePKhRm7NGkmpxkyP3SZffOH9HsixhJryEIc8OZpbBY69q0ccU5MW7y0cTX9ghUDJBxK-TV3Ft9ZDcLaK6FJGQAcjr1QCnSMItX-rk4Kp4ig2KI7ixsim6ZLV9",platform : "android"}], { message : "this is new message"});
41+
var push_token = "eg54Hko_H0A:APA91bH_OOXXmffIBusKXvIaDKzDIqXEzEQZ-rly_Ujysud-fOSMZ4L1gHteAvam765DDcFv3RMy7ojagNBO5ipkyY-S81KqFUwNrm1BUhhVqxNj13t9LhgVbxpk-cn6e4S1agRtNRbR";
42+
notification.send([{push_token : push_token,platform : "android"}], { message : "from nodeJS Application 3 with icon/title", title: "nodeJS", icon: "icon", not_payload: {extra: "sdfsdf"}});
4143
setTimeout(function () {
4244
done();
4345
}, 5000);
44-
4546
});
4647

4748
});

0 commit comments

Comments
 (0)