Comparing version 0.9.9 to 0.9.10
@@ -52,7 +52,8 @@ // | ||
* If the payload is a string, follow the APNS format as in https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW1 | ||
* @param {number} [payload.badge] The number to display over the app icon. | ||
* @param {string} [payload.alert] The alert text. | ||
* @param {string} [payload.sound] The sound file name. | ||
* @param {object} [payload.payload] The payload object that contains the notification text. | ||
* @param {date} [payload.expiry] The expiration date. (in W3C DTF, YYYY-MM-DDThh:mmTZD (e.g. 1997-07-16T19:20+01:00)) | ||
* @param {object} [payload.aps] If the 'aps' member is provided, the object is delivered to APNS as-is after expiry is processed. The object is assumed to follow the APNS format at https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW1 | ||
* @param {number} [payload.badge] If the 'aps' member is not provided, the number to display over the app icon. | ||
* @param {string} [payload.alert] If the 'aps' member is not provided, the alert text. | ||
* @param {string} [payload.sound] If the 'aps' member is not provided, the sound file name. | ||
* @param {object} [payload.payload] If the 'aps' member is not provided, the payload object that contains the notification text. | ||
* @param {Function(error, response)} callback `error` will contain information | ||
@@ -93,23 +94,12 @@ * if an error occurs; otherwise, `response` | ||
payload = _.clone(payload); | ||
if (payload.payload) { | ||
Object.keys(payload.payload).forEach(function (property) { | ||
payload[property] = payload.payload[property]; | ||
}); | ||
if (!_.isString(payload)) { | ||
payload = _.clone(payload); | ||
delete payload.payload; | ||
} | ||
if (payload.expiry) { | ||
var expiry = new Date(payload.expiry); | ||
headers[HeaderConstants.SERVICE_BUS_NOTIFICATION_APNS_EXPIRY] = expiry.toISOString(); | ||
delete payload.expiry; | ||
} | ||
if (!_.isString(payload)) { | ||
if (!payload.aps) { | ||
payload = { aps: payload }; | ||
if (payload.expiry) { | ||
var expiry = new Date(payload.expiry); | ||
headers[HeaderConstants.SERVICE_BUS_NOTIFICATION_APNS_EXPIRY] = expiry.toISOString(); | ||
delete payload.expiry; | ||
} | ||
payload = JSON.stringify(payload); | ||
payload = this._formatPayload(payload); | ||
} | ||
@@ -180,7 +170,8 @@ | ||
* If the payload is a string, follow the APNS format as in https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW1 | ||
* @param {number} [template.badge] The number to display over the app icon. | ||
* @param {string} [template.alert] The alert text. | ||
* @param {string} [template.sound] The sound file name. | ||
* @param {object} [template.payload] The payload object that contains the notification text. | ||
* @param {date} [template.expiry] The expiration date. | ||
* @param {object} [template.aps] If the 'aps' member is provided, the registration is delivered to NotifcationHub as-is after expiry is processed. The object is assumed to follow the APNS format at https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW1 | ||
* @param {number} [template.badge] If the 'aps' member is not provided, the number to display over the app icon. | ||
* @param {string} [template.alert] If the 'aps' member is not provided, the alert text. | ||
* @param {string} [template.sound] If the 'aps' member is not provided, the sound file name. | ||
* @param {object} [template.payload] If the 'aps' member is not provided, the payload object that contains the notification text. | ||
* @param {object} [options] The request options. | ||
@@ -217,7 +208,8 @@ * @param {Function(error, response)} callback `error` will contain information | ||
* If the payload is a string, follow the APNS format as in https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW1 | ||
* @param {number} [template.badge] The number to display over the app icon. | ||
* @param {string} [template.alert] The alert text. | ||
* @param {string} [template.sound] The sound file name. | ||
* @param {object} [template.payload] The payload object that contains the notification text. | ||
* @param {date} [template.expiry] The expiration date. | ||
* @param {object} [template.aps] If the 'aps' member is provided, the registration is delivered to NotifcationHub as-is after expiry is processed. The object is assumed to follow the APNS format at https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW1 | ||
* @param {number} [template.badge] If the 'aps' member is not provided, the number to display over the app icon. | ||
* @param {string} [template.alert] If the 'aps' member is not provided, the alert text. | ||
* @param {string} [template.sound] If the 'aps' member is not provided, the sound file name. | ||
* @param {object} [template.payload] If the 'aps' member is not provided, the payload object that contains the notification text. | ||
* @param {object} [options] The request options. | ||
@@ -255,7 +247,8 @@ * @param {Function(error, response)} callback `error` will contain information | ||
* If the payload is a string, follow the APNS format as in https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW1 | ||
* @param {number} [template.badge] The number to display over the app icon. | ||
* @param {string} [template.alert] The alert text. | ||
* @param {string} [template.sound] The sound file name. | ||
* @param {object} [template.payload] The payload object that contains the notification text. | ||
* @param {date} [template.expiry] The expiration date. | ||
* @param {object} [template.aps] If the 'aps' member is provided, the registration is delivered to NotifcationHub as-is after expiry is processed. The object is assumed to follow the APNS format at https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW1 | ||
* @param {number} [template.badge] If the 'aps' member is not provided, the number to display over the app icon. | ||
* @param {string} [template.alert] If the 'aps' member is not provided, the alert text. | ||
* @param {string} [template.sound] If the 'aps' member is not provided, the sound file name. | ||
* @param {object} [template.payload] If the 'aps' member is not provided, the payload object that contains the notification text. | ||
* @param {object} [options] The request options. | ||
@@ -366,13 +359,5 @@ * @param {Function(error, response)} callback `error` will contain information | ||
var payload = _.clone(template); | ||
if (payload.payload) { | ||
Object.keys(payload.payload).forEach(function (property) { | ||
payload[property] = payload.payload[property]; | ||
}); | ||
var expiry; | ||
delete payload.payload; | ||
} | ||
if (!_.isString(payload)) { | ||
var expiry; | ||
if (payload.expiry) { | ||
@@ -382,15 +367,12 @@ expiry = payload.expiry; | ||
} | ||
if (!payload.aps) { | ||
payload = { aps: payload }; | ||
} | ||
payload = JSON.stringify(payload); | ||
registration.BodyTemplate = '<![CDATA[' + payload + ']]>'; | ||
if (expiry) { | ||
registration['Expiry'] = expiry; | ||
} | ||
payload = this._formatPayload(payload); | ||
} | ||
registration.BodyTemplate = '<![CDATA[' + payload + ']]>'; | ||
// Expiry member must be set after BodyTemplate | ||
if (expiry) { | ||
registration.Expiry = expiry; | ||
} | ||
} | ||
@@ -415,2 +397,18 @@ | ||
module.exports = ApnsService; | ||
ApnsService.prototype._formatPayload = function (payload) { | ||
if (!payload.aps) { | ||
payload = { aps: payload }; | ||
if (payload.aps.payload) { | ||
Object.keys(payload.aps.payload).forEach(function (innerPayloadMember) { | ||
payload[innerPayloadMember] = payload.aps.payload[innerPayloadMember]; | ||
}); | ||
delete payload.aps.payload; | ||
} | ||
} | ||
return JSON.stringify(payload); | ||
}; | ||
module.exports = ApnsService; |
@@ -13,3 +13,3 @@ { | ||
], | ||
"version": "0.9.9", | ||
"version": "0.9.10", | ||
"description": "Microsoft Azure Service Bus Service Library for node", | ||
@@ -35,12 +35,12 @@ "tags": [ | ||
"dependencies": { | ||
"azure-common": "0.9.6", | ||
"azure-common": "0.9.7", | ||
"underscore": "1.4.x" | ||
}, | ||
"homepage": "http://github.com/WindowsAzure/azure-sdk-for-node", | ||
"homepage": "http://github.com/Azure/azure-sdk-for-node", | ||
"repository": { | ||
"type": "git", | ||
"url": "git@github.com:WindowsAzure/azure-sdk-for-node.git" | ||
"url": "git@github.com:Azure/azure-sdk-for-node.git" | ||
}, | ||
"bugs": { | ||
"url": "http://github.com/WindowsAzure/azure-sdk-for-node/issues" | ||
"url": "http://github.com/Azure/azure-sdk-for-node/issues" | ||
}, | ||
@@ -47,0 +47,0 @@ "scripts": { |
254073
4325
+ Addedazure-common@0.9.7(transitive)
- Removedazure-common@0.9.6(transitive)
Updatedazure-common@0.9.7