Skip to content
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

Add support for apns-push-type #127

Merged
merged 10 commits into from
Jul 26, 2019

Conversation

funkenstrahlen
Copy link
Contributor

@funkenstrahlen funkenstrahlen commented Jun 9, 2019

Required when delivering notifications to devices running iOS 13 and later, or watchOS 6 and later.

Apple docs: https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns

I opened a PR on node-apn to support this key. Support from node-apn is required to make this PR work.

PR: node-apn/node-apn#656

Required when delivering notifications to devices running iOS 13 and later, or watchOS 6 and later.
@codecov
Copy link

codecov bot commented Jun 9, 2019

Codecov Report

Merging #127 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #127   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           5      5           
  Lines         262    266    +4     
=====================================
+ Hits          262    266    +4
Impacted Files Coverage Δ
src/APNS.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e19028a...6421e73. Read the comment docs.

@funkenstrahlen
Copy link
Contributor Author

Is node-apn still alive? No commits to master since one year? 😕

@funkenstrahlen funkenstrahlen changed the title add support for apns-push-type Important: Add support for apns-push-type Jun 18, 2019
@funkenstrahlen
Copy link
Contributor Author

Good news! Node apn package just merged my PR to support this key. I suppose we have to wait for a new release version of the package, link it in dependencies and the this PR is good to be merged.

I started to work on this ASAP because it is required in September when iOS 13 is being released.

@dplewis
Copy link
Member

dplewis commented Jun 20, 2019

@funkenstrahlen They haven't done a releases in a long time, We do have a fork https://github.com/parse-community/node-apn and could use that in the mean time.

@funkenstrahlen
Copy link
Contributor Author

funkenstrahlen commented Jun 21, 2019

@dplewis Great! So you suggest I submit the same PR to your fork as well?

@funkenstrahlen
Copy link
Contributor Author

I opened a PR on the fork you referenced. I noticed the package currently references the node-apn version 3 tag. As I opened the PR on master it will be required to cleanup the branch structure of the fork to allow using it here in package.json.

@funkenstrahlen
Copy link
Contributor Author

funkenstrahlen commented Jun 27, 2019

What do you think about setting a default value for apns-push-type key? Because if no value is set a notification will not be delivered to devices running iOS 13, watchOS 6 or later. I suggest setting a default to alert as this is the most common option when calling this API?

If you agree I am happy to add this change to the PR.

@dplewis
Copy link
Member

dplewis commented Jul 11, 2019

@acinader Thoughts?

@acinader
Copy link
Contributor

Sorry, @dplewis I don't have an opinion at this point and am unsure of the implications. Maybe @davimacedo can help, or use your best judgment and we'll work out any issues that arise.

@davimacedo
Copy link
Member

"(Required when delivering notifications to devices running iOS 13 and later, or watchOS 6 and later. Ignored on earlier system versions.) The type of the notification. The value of this header is alert or background. Specify alert when the delivery of your notification displays an alert, plays a sound, or badges your app's icon. Specify background for silent notifications that do not interact with the user."

I think that "alert" by default makes sense since it is the most common use case. We could maybe have a setting in the adapter to change this default to "background" if wanted?

@funkenstrahlen
Copy link
Contributor Author

We could maybe have a setting in the adapter to change this default to "background" if wanted?

I do not think a setting to change the default is necessary because the push type can be set directly when creating a push notification.

The default is only relevant for users who are not aware of the new push type key required for iOS 13.

  • If we do not define a default push notifications will not be delivered for users on iOS 13 if the developer does not update its server code to define the push type key for each notification explicitly.
  • If we define a default and the developer is not aware of the change some background notifications might not be delivered correctly because they are marked as alert by default.

@davimacedo
Copy link
Member

Nice. So let's go ahead with your proposed solution. Could you please resolve the conflicting files?

@funkenstrahlen
Copy link
Contributor Author

I will update the PR this weekend with the changes and also resolve merge conflicts.

@funkenstrahlen
Copy link
Contributor Author

  • Resolved merge conflicts
  • Set push_type to alert if not defined explicitly and added a test case for that

To be considered before merging: An updated version of node-apn package is required to support the push_type header key.

@funkenstrahlen
Copy link
Contributor Author

I also created a PR for documenting this change: parse-community/docs#639

davimacedo
davimacedo previously approved these changes Jul 14, 2019
@davimacedo
Copy link
Member

The code seems good to me, but, before merging, we need to solve the problem of node-apn. They haven't launched a new version yet. A see two options:

  • Change the dependency to their master
  • Merge the latests commits to our fork and change the dependency to our fork

What do you think?

@funkenstrahlen
Copy link
Contributor Author

funkenstrahlen commented Jul 14, 2019

It took me quite some effort to get the PR with support for the new header key merged into the node-apn repository. I even had to get in touch via Twitter. I feel like the repository is not under active development any more and we can not expect to see a new release there soon.

Pointing to master (or any other branch) is an option but I strongly advise against that. This removes any control on our side about what state of code gets pulled in via npm. You can do this locally in your own projects if you know what your are doing but not in a project like this where this gets pulled in as a sub dependency.

Therefore I think its best to maintain our own fork. I already created a PR with the required changes for the new push_type header key some time ago. However pointing the apn dependency to our fork also means we need to keep an eye on it in the future to merge any required changes from upstream (if they ever happen).

@mman
Copy link
Contributor

mman commented Jul 14, 2019

+1 on forking, I’m on open source parse since the very beginning and node-apn looks pretty much abandoned since the very beginning of parse push adapter...

@davimacedo
Copy link
Member

I also prefer to go with our fork. @dplewis @acinader I don't have access to https://github.com/parse-community/node-apn . Could you please accept parse-community/node-apn#1 ? @funkenstrahlen could you also change our dependency to pin our fork in this PR?

@funkenstrahlen
Copy link
Contributor Author

As soon as our fork is updated with the changes and has a new release I will update this PR to use the fork.

@funkenstrahlen funkenstrahlen changed the title Important: Add support for apns-push-type Add support for apns-push-type Jul 24, 2019
@davimacedo
Copy link
Member

@funkenstrahlen your PR is now merged in our fork. Can you please update this PR and pin to the new release https://github.com/parse-community/node-apn/releases/tag/v2.1.6-parse?

@funkenstrahlen
Copy link
Contributor Author

funkenstrahlen commented Jul 25, 2019

@davimacedo Sure! I updated the PR with the required changes.

I recognized that we referenced ^3.0.0-alpha1 of node-apn before. The new fork only offers code based on version 2. Do you think this is an issue? The diff is not very big but it could cause some regressions?

@funkenstrahlen
Copy link
Contributor Author

I think after this is merged we should also prepare a new release for this repository. I did not want to mix this into this PR.

@davimacedo
Copy link
Member

@funkenstrahlen I think you are right. I am thinking to update our fork's master to be pretty much the same they currently have in their master and release again. Do you agree?

@funkenstrahlen
Copy link
Contributor Author

funkenstrahlen commented Jul 25, 2019

I am thinking to update our fork's master to be pretty much the same they currently have in their master and release again. Do you agree?

I am not sure what's the best approach. 3.0.0-alpha1 tags a commit on the native-http2 branch in the node-apn repository instead of the master. This branch has not been merged with their master for quite some time.

I run parse with node-apn in version 3.0.0-alpha1 on my server for quite some time without any major known issues but this is only my personal experience.

We could start by setting "our" master to their 3.0.0-alpha1 as this has been referenced as a dependency for parse-push-adapter for some time and then just patch this with the apns-push-key changes. This would reduce the chance of surprising braking changes.

In the long run we should take some time and pick some changes from their master and evaluate them to get back on track for the future.

@davimacedo
Copy link
Member

I agree. Now we have our master synced with the last commit of 3.0.0-alpha1. I hope no one (specially @acinader and @dplewis) will kill me because of the push --force I did 😄 . Just in case, I saved our previous master in a branch called oldmaster. Do you mind to open a new PR with the apns-push-key changes?

@funkenstrahlen
Copy link
Contributor Author

funkenstrahlen commented Jul 26, 2019

I created a new PR to add apns-push-type support to the new master in our fork: parse-community/node-apn#2

I can update the package dependency in this PR when the changes got merged there and a new version has been released.

@davimacedo
Copy link
Member

Thanks again. I've just merged and released a new version: https://github.com/parse-community/node-apn/releases/tag/v3.0.1-parse

@funkenstrahlen
Copy link
Contributor Author

Package dependency has been updated to the new release.

@davimacedo davimacedo merged commit 175c261 into parse-community:master Jul 26, 2019
@davimacedo
Copy link
Member

Thank you so much @funkenstrahlen ! I've just merged!

@funkenstrahlen
Copy link
Contributor Author

Awesome! So it's time for a new release?

Thanks for your work too! I enjoy working together with you :)

@davimacedo
Copy link
Member

@parse-github-assistant
Copy link

The label type:feature cannot be used here.

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.

6 participants