From d0ae7aa00c9154c3518761d1b20fc7878fcac1a0 Mon Sep 17 00:00:00 2001 From: Stefan Trauth Date: Sat, 13 Jul 2019 16:05:52 +0200 Subject: [PATCH] add test case for apns priority MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit should be set to 10 if not defined explicitly. The priority of the notification. If you omit this header, APNs sets the notification priority to 10. Specify 10 to send the notification immediately. A value of 10 is appropriate for notifications that trigger an alert, play a sound, or badge the app’s icon. It's an error to specify this priority for a notification whose payload contains the content-available key. Specify 5 to send the notification based on power considerations on the user’s device. Use this priority for notifications whose payload includes the content-available key. Notifications with this priority might be grouped and delivered in bursts to the user’s device. They may also be throttled, and in some cases not delivered. --- spec/APNS.spec.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/spec/APNS.spec.js b/spec/APNS.spec.js index 679cacb..00f8ed3 100644 --- a/spec/APNS.spec.js +++ b/spec/APNS.spec.js @@ -156,6 +156,24 @@ describe('APNS', () => { done(); }); + it('sets priority to 10 if not set explicitly', (done) => { + let data = { + 'alert': 'alert', + 'title': 'title', + 'badge': 100, + 'sound': 'test', + 'content-available': 1, + 'mutable-content': 1, + 'category': 'INVITE_CATEGORY', + 'threadId': 'a-thread-id', + 'key': 'value', + 'keyAgain': 'valueAgain' + }; + let notification = APNS._generateNotification(data, { }); + expect(notification.priority).toEqual(10); + done(); + }); + it('can generate APNS notification', (done) => { //Mock request data let data = {