Skip to content

Commit e92e21d

Browse files
committed
Merge pull request #4 from faizulhaque/master
minor changes
2 parents 318ccc0 + 7688b62 commit e92e21d

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

.idea/scopes/scope_settings.xml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ function onTransmissionError(ctx, client, errorCode, notificationObj, recipient)
1515
}
1616

1717
Notification.prototype.setupIOSClient = function setupIOSClient(
18-
dev_key_path, dev_cert_path, prod_key_path, prod_cert_path) {
18+
dev_key_path, dev_cert_path, prod_key_path, prod_cert_path, prod_pass_phrase, stg_pass_phrase) {
1919
var self = this;
20-
self.clients.ios = new Ios(dev_key_path, dev_cert_path, prod_key_path, prod_cert_path);
20+
self.clients.ios = new Ios(dev_key_path, dev_cert_path, prod_key_path, prod_cert_path, prod_pass_phrase, stg_pass_phrase);
2121
self.clients.ios.onTransmitted = function (client, notificationObj, recipient) {
2222
onTransmitted(self, client, notificationObj, recipient);
2323
};

lib/ios.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@ var initApnSend = function initApnSend(ctx) {
226226
"batchFeedback": true,
227227
"production": true
228228
};
229+
if(ctx.apn.prod_pass_phrase) {
230+
options.passphrase = ctx.apn.prod_pass_phrase;
231+
}
229232
}
230233
else {
231234
options = {
@@ -235,6 +238,9 @@ var initApnSend = function initApnSend(ctx) {
235238
"batchFeedback": true,
236239
"production": false
237240
};
241+
if(ctx.apn.stg_pass_phrase) {
242+
options.passphrase = ctx.apn.stg_pass_phrase;
243+
}
238244
}
239245
ctx.apn_connection = new Apn.Connection(options);
240246
ctx.apn_connection.on("transmissionError", function(errorCode, notification, recipient) {
@@ -354,12 +360,14 @@ function push(ctx, tokens, payload) {
354360
* @returns {*}
355361
* @version 0.1
356362
*/
357-
function Ios(dev_key_path, dev_cert_path, prod_key_path, prod_cert_path) {
363+
function Ios(dev_key_path, dev_cert_path, prod_key_path, prod_cert_path, prod_pass_phrase, stg_pass_phrase) {
358364
this.apn = {
359365
prod_key: prod_key_path,
360366
prod_cert: prod_cert_path,
361367
dev_key: dev_key_path,
362-
dev_cert: dev_cert_path
368+
dev_cert: dev_cert_path,
369+
prod_pass_phrase: prod_pass_phrase,
370+
stg_pass_phrase: stg_pass_phrase
363371
};
364372
}
365373

tests/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ describe("Notification", function() {
1313
global.RootPath = path.resolve("");
1414
var key = global.RootPath + "/tests/assets/key.pem";
1515
var cert = global.RootPath + "/tests/assets/cert.pem";
16-
notification.setupIOSClient(key,cert,key,cert);
16+
var prodPassPhrase = "";
17+
var stgPassPhrase = "";
18+
notification.setupIOSClient(key,cert,key,cert,prodPassPhrase,stgPassPhrase);
1719
var apiKey = "please you api key here";
1820
notification.setupAndroidClient(apiKey);
1921

0 commit comments

Comments
 (0)