Skip to content

Add macOS and tvOS push notification support #58

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

Merged
merged 20 commits into from
Mar 14, 2017
Merged

Add macOS and tvOS push notification support #58

merged 20 commits into from
Mar 14, 2017

Conversation

funkenstrahlen
Copy link
Contributor

@funkenstrahlen funkenstrahlen commented Feb 26, 2017

Make push notifications work for macOS and tvOS.

This is linked to this issue: #11

  • Add support for osx and tvos deviceTypes to installation
  • Add support to ParsePushAdapter and APNS.js to accept more than just iOS certificates.
  • Add support to ParsePushAdapter and APNS.js to send to tvOS, which reuses the same certificate as iOS.
  • Update spec

@funkenstrahlen
Copy link
Contributor Author

@flovilmart This is what I came up with. Can you please take a look?

@funkenstrahlen
Copy link
Contributor Author

Is tvos actually the correct deviceType for the Apple TV? Or do I have to use appletv?

@funkenstrahlen
Copy link
Contributor Author

funkenstrahlen commented Feb 27, 2017

I need some help on the last spec test. I do not know why it fails with cannot found valid connection.

I added some debug logging and saw this:

.ERR! parse-server-push-adapter calling send for devices [object Object],[object Object]
ERR! parse-server-push-adapter APNS found conn iosbundleId for: 0d72a1baa92a2febd9a254cbd6584f750c70b2350af5fc9052d1d12584b738e6
ERR! parse-server-push-adapter APNS found conn iosbundleId for: ff3943ed0b2090c47e5d6f07d8f202a10427941d7897fda5a6b18c6d9fd07d48
ERR! parse-server-push-adapter calling send for devices [object Object]
ERR! parse-server-push-adapter APNS found conn osxbundleId for: 5cda62a8d88eb48d9111a6c436f2e326a053eb0cd72dfc3a0893089342602235
ERR! parse-server-push-adapter calling send for devices [object Object]
ERR! parse-server-push-adapter APNS found conn iosbundleId for: 3e72a1baa92a2febd9a254cbd6584f750c70b2350af5fc9052d1d12584b738e6
ERR! parse-server-push-adapter calling send for devices [object Object]
ERR! parse-server-push-adapter APNS cannot find vaild connection for ff3943ed0b2090c47e5d6f07d8f202a10427941d7897fda5a6b18c6d9fd07d48
ERR! parse-server-push-adapter APNS cannot find vaild connection for 0d72a1baa92a2febd9a254cbd6584f750c70b2350af5fc9052d1d12584b738e6
ERR! parse-server-push-adapter APNS cannot find vaild connection for 3e72a1baa92a2febd9a254cbd6584f750c70b2350af5fc9052d1d12584b738e6

It groups devices correctly: ios, osx, android, tvos. It also finds matching connection configuration for each group and uses the ios configurated connection for tvos deviceType.

However it reports invalid connection for ios and tvos devices later. Any idea what part in the code causes this problem?

@funkenstrahlen
Copy link
Contributor Author

funkenstrahlen commented Mar 3, 2017

I spend hours trying to figure out why this test case does fail. Because I did not know what change caused the test case to fail I switched back to the master branch. Result: The test case does not run either!

npm test

> [email protected] test /Users/funkenstrahlen/Projects/podlive/parse-server-push-adapter
> TESTING=1 babel-node ./node_modules/.bin/isparta cover --root src/ ./node_modules/jasmine/bin/jasmine.js

Started
...................ERR! parse-server-push-adapter GCM send errored: 401
........ERR! parse-server-push-adapter APNS no qualified connections for anotherBundle c5ee8fae0a1c
ERR! parse-server-push-adapter APNS no qualified connections for anotherBundle c5ee8fae0a1c5805e731cf15496d5b2b3f9b9c577353d3239429d3faaee01c79
ERR! parse-server-push-adapter GCM send errored: 401
.


28 specs, 0 failures
Finished in 0.448 seconds

No coverage information was collected, exit without writing coverage information

So I do not see how I can make this test pass if it does not even work in your current master.

@flovilmart I really need help on this PR now. I do not see what I can improve now.

@flovilmart
Copy link
Contributor

The print out shows that the tests are passing. (0 failures)

@funkenstrahlen
Copy link
Contributor Author

funkenstrahlen commented Mar 3, 2017 via email

@flovilmart
Copy link
Contributor

I'll check it out on my machine and see what can fail

@flovilmart
Copy link
Contributor

I found the reason of the failures (APNs is throwing an exception when the certificate is missing), and I'Ll try to provide a fix on the top of your branch, Is that ok for you?

@funkenstrahlen
Copy link
Contributor Author

funkenstrahlen commented Mar 3, 2017

I found the reason of the failures (APNs is throwing an exception when the certificate is missing), and I'Ll try to provide a fix on the top of your branch, Is that ok for you?

@flovilmart This is great news! Of course you can add your changes. I granted you push access to my fork in case it is required.

Thank you for looking into it and helping me out! :)

@flovilmart
Copy link
Contributor

I granted you push access to my fork in case it is required.

That's not required, I can push on the PR branch directly :) Thanks!

@flovilmart
Copy link
Contributor

@funkenstrahlen I uncovered additional inconsistencies with our implementation. I'm still working on it :)

let devices = deviceMap[pushType];

if (!sender) {
if (pushType == 'tvos') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure this fallback is required. Even if it leads to redundancy for all 'apple' push types.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this as it was suggested in the related issue. However I also think it is better to not add redundancy and require the admin to define a certificate for each plattform he wants to support.

sender = this.senderMap['ios'];
} else if (pushType == 'ios') {
// if there is only a tvos push configuration available reuse it for ios
sender = this.senderMap['tvos'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it may also be 'macos'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you suggesting to also add macos into this redundancy?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I'm not sure if we should automatically do that. Do you Think of any real world use case?

Copy link
Contributor Author

@funkenstrahlen funkenstrahlen Mar 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally think it is is more transparent if we do not add this redundancy. If someone needs support for multiple push targets he needs to define all of them in his config. He can use the same certificate of course.

Copy link
Contributor Author

@funkenstrahlen funkenstrahlen Mar 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you agree on this I will remove the redundancy code and adjust the spec.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fully agreed! less code, better code!

@funkenstrahlen
Copy link
Contributor Author

funkenstrahlen commented Mar 13, 2017

I uncovered additional inconsistencies with our implementation. I'm still working on it :)

@flovilmart Thanks for fixing the spec! Anything further I can do to help getting this merged? What inconsistencies did you recognize?

@funkenstrahlen
Copy link
Contributor Author

@flovilmart I removed the redundancy push configuration code as we discussed and also adjusted the spec.

@flovilmart
Copy link
Contributor

Yeah! Took some commits but we're there!!

@flovilmart flovilmart merged commit fd16ccc into parse-community:master Mar 14, 2017
@funkenstrahlen
Copy link
Contributor Author

Awesome! Thanks for helping me getting this done! :)

Do you think this is worth a version bump?

@flovilmart
Copy link
Contributor

flovilmart commented Mar 14, 2017

Yep definitely! We should probably release it :)

Do you want to open a PR with the version bump and CHANGELOG?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants