Skip to content

Push handling cleanup #732

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 5 commits into from
Sep 10, 2017
Merged

Push handling cleanup #732

merged 5 commits into from
Sep 10, 2017

Conversation

natario1
Copy link
Contributor

@natario1 natario1 commented Sep 2, 2017

Following #729 , this does not solve the issue but makes it easier to think of a fix, and also introduce FCM in the future.

  • General clean up, renaming some classes
  • PPNS is ripped out
  • PushHandler interface for handling payloads of different providers (GCM, FCM)
  • PushService acts as a router and streamlines payloads to handlers in a single thread

To fix 729 I would probably act on ServiceUtils to launch PushService either as a Service or as a job depending on API level

@codecov
Copy link

codecov bot commented Sep 2, 2017

Codecov Report

Merging #732 into master will increase coverage by 0.43%.
The diff coverage is 33.62%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #732      +/-   ##
============================================
+ Coverage     52.98%   53.42%   +0.43%     
- Complexity     1730     1745      +15     
============================================
  Files           132      131       -1     
  Lines         10261    10258       -3     
  Branches       1433     1435       +2     
============================================
+ Hits           5437     5480      +43     
+ Misses         4375     4325      -50     
- Partials        449      453       +4
Impacted Files Coverage Δ Complexity Δ
Parse/src/main/java/com/parse/ServiceUtils.java 8.57% <ø> (+8.57%) 2 <0> (+2) ⬆️
Parse/src/main/java/com/parse/GcmRegistrar.java 0% <ø> (-6.1%) 0 <0> (-3)
...in/java/com/parse/ParsePushChannelsController.java 6.45% <0%> (ø) 2 <0> (ø) ⬇️
Parse/src/main/java/com/parse/GcmPushHandler.java 1.58% <1.58%> (ø) 1 <1> (?)
Parse/src/main/java/com/parse/Parse.java 48.37% <100%> (-1.4%) 21 <0> (-2)
...ain/java/com/parse/ParsePushBroadcastReceiver.java 4.83% <54.54%> (+4.83%) 3 <3> (+3) ⬆️
Parse/src/main/java/com/parse/PushType.java 76.92% <66.66%> (+3.58%) 5 <0> (ø) ⬇️
Parse/src/main/java/com/parse/PushHandler.java 71.42% <71.42%> (ø) 0 <0> (?)
Parse/src/main/java/com/parse/PushService.java 85.93% <90%> (+85.93%) 18 <6> (+18) ⬆️
... and 7 more

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 a69d994...d6f4e08. Read the comment docs.

@@ -173,14 +167,14 @@ private static boolean usesPushBroadcastReceivers() {
intentsRegistered++;
}

if (intentsRegistered != 0 && intentsRegistered != NUMBER_OF_PUSH_INTENTS) {
if (intentsRegistered != 0 && intentsRegistered != 3) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why delete this constant?

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 had my brain in cleanup mode :) and this looked already clear from the method implementation to me. I can add again.

I can also add some tests to the patch but first wanted to know if there's consensus over this being merged

Copy link
Contributor

Choose a reason for hiding this comment

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

PR works for me. It looks like you removed PPNS while also refactoring to a PushHandler interface with an eye towards allowing the FCM handler? The only thing is that FCM/GCM shouldn't co-exist so we may need to move hasAnyGcmSpecificDeclaration() out too as part of the interface? (canHandlePush?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That sounds good! I will do it. In the future we might even make the handler public so people can provide their adapters like parse server.

By the way, is parse-server ready to send FCM-like messages? AFAIK currently the handlers here need to update the ParseInstallation pushType to tell parse server adapter how to send the push. What happens when we start setting pushType = 'fcm' ?

Copy link
Contributor

@rogerhu rogerhu Sep 4, 2017

Choose a reason for hiding this comment

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

Yeah parse server may need to be upgraded. But the push tokens should be interoperable so hopefully the changes are minimal.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The actual send implementation is still GCM based though? https://github.com/parse-server-modules/parse-server-push-adapter/blob/master/src/GCM.js I don't know if that's a problem and how we should manage

@natario1
Copy link
Contributor Author

natario1 commented Sep 7, 2017

This got bigger than I expected but seems solid to me. Makes it easy to fix #729 (I hope), and to add FCM (I hope).

I was very tempted to rip out PushRouter and PushHistory but resisted, though I'm not 100% sure they are still useful. I hope this can be done in the future.

I also think we could add PushService to our own manifest to ease the developer set-up. The developer would still be able to choose not to support push, by not registering any ParsePushBroadcastReceiver. But I don't know what would happen when merging manifests that both have a push service declared, so I gave up.

I also think we could add GcmBroadcastReceiver (or FCM in the future) to our manifest and remove a lot of boilerplate from everyone (would have to take care of #638 use case)

@rogerhu
Copy link
Contributor

rogerhu commented Sep 10, 2017

Thanks for doing this!

@rogerhu rogerhu merged commit 6dbf4ba into parse-community:master Sep 10, 2017
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