-
-
Notifications
You must be signed in to change notification settings - Fork 105
Update apn to version 2.1.2 #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@Schwobaland thanks for your contribution! It seems that the tests are failing. Can you take a look why? |
Seems that apn 2.1.2 is not compatible with node 4.3. Tests are running with node 5. Parse-server has node 4.3 as minimum requirement. So - should i close this pull request? Or can minimum requirements be changed to node 5 or 6 (lts-version). |
@Schwobaland we bumped the min version to 4.6, and now everything looks good on the tests. |
spec/APNS.spec.js
Outdated
@@ -1,68 +1,31 @@ | |||
var APNS = require('../src/APNS'); | |||
let APNS = require('../src/APNS'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
spec/APNS.spec.js
Outdated
key: 'prodKey.pem', | ||
it('can initialize with cert', (done) => { | ||
let args = { | ||
cert: new Buffer('testCert'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should still work with a string no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should work, if the string contains a (resolvable) filename or a string, that matches against /-----BEGIN ([A-Z\s*]+)-----/
. See here for details.
Will change one of the test-cases to test this.
spec/APNS.spec.js
Outdated
production: true, | ||
bundleId: 'bundleId' | ||
topic: 'topic' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd keep bundleId as the main option with topic being optional to maximize backwards compatibility.
perhaps if using bundleId we could log a warning: bundleId is deprecated, use topic instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was already a mapping of bundleId to topic. I will add a warning, if bundleId is used.
spec/APNS.spec.js
Outdated
expect(prodApnsOptions.cert).toBe(args.cert); | ||
expect(prodApnsOptions.key).toBe(args.key); | ||
expect(prodApnsOptions.production).toBe(args.production); | ||
done(); | ||
}); | ||
|
||
it('can initialize with multiple certs', (done) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not supported anymore? I personally rely on that capability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is supported for different topics/bundleIds.
But I haven't found any possibility, to implement a retry for notifications, that a rejected by apns because of wrong provider or wrong production- / test-device.
Example: You have two provider, one for production use and one for development. Both share the same topic/bundleId. So _chooseProviders
would return [prodProvider, devProvider]
based on priority-sorting in constructor. So send
-Method uses the first one to send the notification. If device is registered using apple-development-provisioning-profile, the notification would not be delivered, because of wrong provider. In parse-device-object is no flag, that describes, wether this device is using development- or production-profile.
In "old" parse-push-adapter (using apn version 1.X), there was a retry-functionality. This isn't available in my version.
I will add this test-case again to test different topics.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for multiple certs
done(); | ||
}); | ||
|
||
it('can choose conns for device with valid appIdentifier', (done) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not supported anymore either?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see it('can choose providers for device with valid appIdentifier'....
src/APNS.js
Outdated
conn.on('timeout', () => { | ||
log.verbose(LOG_PREFIX, 'APNS Connection %d Timeout', conn.index); | ||
}); | ||
let provider = this._createProvider(apnsArgs); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the _createProvider should be 'static' as it doesn't need this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/APNS.js
Outdated
* @param {String} topic Topic the Notification is sent to | ||
* @returns {Object} A apns Notification | ||
*/ | ||
_generateNotification(coreData, expirationTime, topic) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should stay static as well as is doesn't require this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/APNS.js
Outdated
log.verbose(LOG_PREFIX, 'APNS transmitted to %s', token); | ||
return this._createSuccesfullPromise(token); | ||
}); | ||
response.failed.forEach((failure) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will just be a no-op as it will create promises that are never handled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will return a Promise.all
with all promises
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's better :)
Hi @Schwobaland, thanks for that Pull Request! We have a few things here and there before we can merge that one! Thanks again! |
…sh-adapter into apn2 * 'apn2' of https://github.com/Schwobaland/parse-server-push-adapter: Update .travis.yml Update package.json
Hi @flovilmart, thanks for commenting. Fixed some of your requested changes. Please review this comment. I'm not sure, how to handle this, because of backward-compatibility. I will be using two instances of parse-server: One for production and one for development. So for my use-cases this is not a problem, but... |
@Schwobaland I'll have a look for multiple certs for a single topic, and I'll open a Pr on your branche before we get to merge that what do you think? |
@flovilmart Sounds good! I'll wait for your PR 👍 |
src/APNS.js
Outdated
response.failed.forEach((failure) => { | ||
if (failure.error) { | ||
log.error(LOG_PREFIX, 'APNS error transmitting to device %s with error %s', failure.device, failure.error); | ||
promises.push(PNS._createErrorPromise(failure.device, failure.error)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo. PNS should be APNS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jeacott1 thanks. Fixed this.
I've been playing with apn 2.1.3, and thus far its been pretty unreliable unfortunately. the existing apn 1.x is more stable, but tracking doesn't work well. |
@jeacott1 what do you mean by unstable? |
http2 errors, and other sporadic exceptions. many have been mitigated by downgrading node to 5.11.1, but that causes other performance issues. |
Anything worth reporting to the APN maintainer? Or related to the current implementation? |
I think most of the issues are already documented either with apn, http2, or nodejs. |
@Schwobaland seems that it's getting updated to 2.1.3 last month, can you bump? I may takeover your branch as I'm in the midst of removing babel altogether from the package. |
Codecov Report
@@ Coverage Diff @@
## master #52 +/- ##
=======================================
Coverage ? 100%
=======================================
Files ? 5
Lines ? 249
Branches ? 0
=======================================
Hits ? 249
Misses ? 0
Partials ? 0
Continue to review full report at Codecov.
|
Closing as superset by #72 , thanks @Schwobaland for getting the ball rolling on that, one! |
Update to apn. This enables parse to use http2-API from Apple. Tokens can be used instead of certificates. So one push-config enables to push to different apps.
There are some new options for configuring push-adapter:
Old property
bundleId
is mapped totopic
for backward-compatibility.