Skip to content

Commit d7e5397

Browse files
committed
feat: Add input-push-channel and input-push-token to APS
1 parent 34b756b commit d7e5397

File tree

4 files changed

+88
-0
lines changed

4 files changed

+88
-0
lines changed

index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ interface Aps {
133133
timestamp?: number
134134
event?: string
135135
"dismissal-date"?: number
136+
"input-push-channel": string
137+
"input-push-token": number
136138
"attributes-type"?: string
137139
attributes?: Object
138140
}

lib/notification/apsProperties.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,30 @@ module.exports = {
179179
}
180180
},
181181

182+
set filterCriteria(value) {
183+
if (typeof value === 'string' || value === undefined) {
184+
this.aps['filter-criteria'] = value;
185+
}
186+
},
187+
188+
set inputPushChannel(value) {
189+
if (typeof value === 'string' || value === undefined) {
190+
this.aps['input-push-channel'] = value;
191+
}
192+
},
193+
194+
set inputPushToken(value) {
195+
if (typeof value === 'number' || value === undefined) {
196+
this.aps['input-push-token'] = value;
197+
}
198+
},
199+
200+
set attributesType(value) {
201+
if (typeof value === 'string' || value === undefined) {
202+
this.aps['attributes-type'] = value;
203+
}
204+
},
205+
182206
prepareAlert: function () {
183207
if (typeof this.aps.alert !== 'object') {
184208
this.aps.alert = { body: this.aps.alert };

lib/notification/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ Notification.prototype = require('./apsProperties');
5757
'event',
5858
'contentState',
5959
'dismissalDate',
60+
'filterCriteria',
61+
'inputPushChannel',
62+
'inputPushToken',
63+
'attributesType',
6064
].forEach(propName => {
6165
const methodName = 'set' + propName[0].toUpperCase() + propName.slice(1);
6266
Notification.prototype[methodName] = function (value) {

test/notification/apsProperties.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,64 @@ describe('Notification', function () {
10991099
});
11001100
});
11011101

1102+
describe('input-push-token', function () {
1103+
it('defaults to undefined', function () {
1104+
expect(compiledOutput()).to.not.have.nested.property('aps.input-push-token');
1105+
});
1106+
1107+
it('can be set to a number', function () {
1108+
note.inputPushToken = 1;
1109+
1110+
expect(compiledOutput()).to.have.nested.property('aps.input-push-token', 1);
1111+
});
1112+
1113+
it('can be set to undefined', function () {
1114+
note.inputPushToken = 1;
1115+
note.inputPushToken = undefined;
1116+
1117+
expect(compiledOutput()).to.not.have.nested.property('aps.input-push-token');
1118+
});
1119+
1120+
describe('setInputPushToken', function () {
1121+
it('is chainable', function () {
1122+
expect(note.setDismissalDate(1)).to.equal(note);
1123+
expect(compiledOutput()).to.have.nested.property('aps.input-push-token', 1);
1124+
});
1125+
});
1126+
});
1127+
1128+
describe('filter-criteria', function () {
1129+
it('defaults to undefined', function () {
1130+
expect(compiledOutput()).to.not.have.nested.property('aps.filter-criteria');
1131+
});
1132+
1133+
it('can be set to a string', function () {
1134+
note.filterCriteria = 'the-filter-criteria';
1135+
1136+
expect(compiledOutput()).to.have.nested.property(
1137+
'aps.interruption-level',
1138+
'the-interruption-level'
1139+
);
1140+
});
1141+
1142+
it('can be set to undefined', function () {
1143+
note.filterCriteria = 'filter-criteria';
1144+
note.filterCriteria = undefined;
1145+
1146+
expect(compiledOutput()).to.not.have.nested.property('aps.filter-criteria');
1147+
});
1148+
1149+
describe('setfilterCriteria', function () {
1150+
it('is chainable', function () {
1151+
expect(note.setß('the-filter-criteria')).to.equal(note);
1152+
expect(compiledOutput()).to.have.nested.property(
1153+
'aps.filter-criteria',
1154+
'the-filter-criteria'
1155+
);
1156+
});
1157+
});
1158+
});
1159+
11021160
context('when no aps properties are set', function () {
11031161
it('is not present', function () {
11041162
expect(compiledOutput().aps).to.be.undefined;

0 commit comments

Comments
 (0)