Skip to content

Commit

Permalink
fix(apn): Fix issue with non-sending pushes
Browse files Browse the repository at this point in the history
Fixes #53
  • Loading branch information
ghaiklor committed Feb 4, 2016
1 parent 5a04d4c commit c9811d1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/APNNotification.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default class APNNotification extends BaseNotification {
let predefinedNotification = this.get('notification') || {};
let customNotification = _notification || {};
let notification = new apn.Notification(customNotification.payload || predefinedNotification.payload || {});

notification.sound = customNotification.sound || predefinedNotification.sound;
notification.badge = customNotification.badge || predefinedNotification.badge;
notification.setAlertTitle(customNotification.title || predefinedNotification.title);
Expand Down
40 changes: 20 additions & 20 deletions test/unit/APNNotification.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,16 @@ const CONFIG = {
};

const NOTIFICATION_SHOULD_BE = {
aps: {
alert: {
title: 'TITLE',
body: 'BODY'
},
sound: 'SOUND',
badge: 'BADGE'
},
payload: {
foo: 'bar',
bar: 'foo'
}
encoding: 'utf8',
payload: {foo: 'bar', bar: 'foo'},
expiry: 0,
priority: 10,
retryLimit: -1,
device: undefined,
compiled: false,
truncateAtWordEnd: false,
_sound: 'SOUND',
_alert: {title: 'TITLE', body: 'BODY'}
};

describe('APNNotification', () => {
Expand All @@ -51,7 +49,9 @@ describe('APNNotification', () => {
.send(['b2', 'c3'])
.then(() => {
assert.ok(ios.getProvider().pushNotification.calledThrice);
assert.deepEqual(ios.getProvider().pushNotification.getCall(0).args[0].payload, NOTIFICATION_SHOULD_BE);
assert.deepEqual(ios.getProvider().pushNotification.getCall(0).args[0].payload, {foo: 'bar', bar: 'foo'});
assert.deepEqual(ios.getProvider().pushNotification.getCall(0).args[0]._sound, 'SOUND');
assert.deepEqual(ios.getProvider().pushNotification.getCall(0).args[0]._alert, {title: 'TITLE', body: 'BODY'});
assert.equal(ios.getProvider().pushNotification.getCall(0).args[1], 'a1');
assert.equal(ios.getProvider().pushNotification.getCall(1).args[1], 'b2');
assert.equal(ios.getProvider().pushNotification.getCall(2).args[1], 'c3');
Expand All @@ -74,8 +74,8 @@ describe('APNNotification', () => {
})
.then(() => {
assert.ok(ios.getProvider().pushNotification.calledThrice);
assert.deepPropertyVal(ios.getProvider().pushNotification.getCall(0).args[0], 'payload.aps.alert.body', 'OVERRIDE_BODY');
assert.deepPropertyVal(ios.getProvider().pushNotification.getCall(0).args[0], 'payload.aps.sound', 'SOUND');
assert.deepPropertyVal(ios.getProvider().pushNotification.getCall(0).args[0], '_alert.body', 'OVERRIDE_BODY');
assert.deepPropertyVal(ios.getProvider().pushNotification.getCall(0).args[0], '_sound', 'SOUND');
assert.equal(ios.getProvider().pushNotification.getCall(0).args[1], 'a1');
assert.equal(ios.getProvider().pushNotification.getCall(1).args[1], 'b2');
assert.equal(ios.getProvider().pushNotification.getCall(2).args[1], 'c3');
Expand All @@ -100,7 +100,7 @@ describe('APNNotification', () => {
})
.then(() => {
assert.ok(ios.getProvider().pushNotification.calledTwice);
assert.deepPropertyVal(ios.getProvider().pushNotification.getCall(0).args[0], 'payload.aps.alert.body', 'OVERRIDE_BODY');
assert.deepPropertyVal(ios.getProvider().pushNotification.getCall(0).args[0], '_alert.body', 'OVERRIDE_BODY');
assert.deepPropertyVal(ios.getProvider().pushNotification.getCall(0).args[0], 'priority', 5);
assert.equal(ios.getProvider().pushNotification.getCall(0).args[1], 'a1');
assert.equal(ios.getProvider().pushNotification.getCall(1).args[1], 'b2');
Expand Down Expand Up @@ -137,8 +137,8 @@ describe('APNNotification', () => {
.send(['a1'])
.then(() => {
assert.ok(ios.getProvider().pushNotification.calledOnce);
assert.deepPropertyVal(ios.getProvider().pushNotification.getCall(0).args[0], 'payload.aps.alert.title', undefined);
assert.deepPropertyVal(ios.getProvider().pushNotification.getCall(0).args[0], 'payload.aps.alert.body', undefined);
assert.deepPropertyVal(ios.getProvider().pushNotification.getCall(0).args[0], '_alert.title', undefined);
assert.deepPropertyVal(ios.getProvider().pushNotification.getCall(0).args[0], '_alert.body', undefined);
assert.deepPropertyVal(ios.getProvider().pushNotification.getCall(0).args[0], 'priority', 10);
assert.equal(ios.getProvider().pushNotification.getCall(0).args[1], 'a1');

Expand All @@ -163,8 +163,8 @@ describe('APNNotification', () => {
})
.then(() => {
assert.ok(ios.getProvider().pushNotification.calledOnce);
assert.deepPropertyVal(ios.getProvider().pushNotification.getCall(0).args[0], 'payload.aps.alert.title', 'CUSTOM_TITLE');
assert.deepPropertyVal(ios.getProvider().pushNotification.getCall(0).args[0], 'payload.aps.alert.body', 'CUSTOM_BODY');
assert.deepPropertyVal(ios.getProvider().pushNotification.getCall(0).args[0], '_alert.title', 'CUSTOM_TITLE');
assert.deepPropertyVal(ios.getProvider().pushNotification.getCall(0).args[0], '_alert.body', 'CUSTOM_BODY');
assert.deepPropertyVal(ios.getProvider().pushNotification.getCall(0).args[0], 'priority', 5);
assert.equal(ios.getProvider().pushNotification.getCall(0).args[1], 'a1');

Expand Down

0 comments on commit c9811d1

Please sign in to comment.