-
Notifications
You must be signed in to change notification settings - Fork 137
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
[Push Notification] Added support for no channels #150
Conversation
## Push Notification: - If there are no channels (default no channel), the push notification is sent to all target devices. - Improved support for targeting by platform: a device type is specified as [where clause](https://www.parse.com/docs/push_guide#options-platform/REST)
- Updated test pattern for new “no channel” support compatibility. - Fixed bug when deviceType and where clause are specified at same time.
@fabiomassimo Could you at least use two spaces instead of tabs(or 4 spaces), please? Current indentation are broken. Second. You might broke backward compatibility by replacing default channel from Why are you double checking for
|
- Reverted tabs to soft-spaces as required from [ruby style guide](https://github.com/styleguide/ruby). - Reverted channel default value to “” - Removed superfluous code.
Thanks for the great links. This is my first ruby experience. I will definitely look into it.
By using
Thanks that was a superfluous code. |
Someone, who is already using a gem, may use |
I don't think an empty string could be a valid channel. |
Empty string is a Broadcast channel |
@@ -1,45 +1,47 @@ | |||
require 'helper' | |||
|
|||
class TestPush < ParseTestCase | |||
|
|||
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.
Could you get rid of trailing whitespaces, please?
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.
Removed trailing whitespaces.
Thanks.
Removed trailing superfluous spaces
@@ -15,7 +15,13 @@ class Push | |||
|
|||
def initialize(data, channel = "") | |||
@data = data | |||
@channel = channel | |||
|
|||
if channel.empty? |
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.
If someone will set channel as nil
explicitly you would get
NoMethodError: undefined method `empty?' for nil:NilClass`
Improved code consistency if `initialize` a push notification with `nil` channel.
@@ -15,7 +15,13 @@ class Push | |||
|
|||
def initialize(data, channel = "") | |||
@data = data | |||
@channel = channel | |||
|
|||
if !channel || channel.empty? |
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.
If you change the default for channel from ""
to nil
, you can simplify this to if channel.nil?
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.
What if an user initiate a new Push object with: Push.new(data, "")
?
The channel parameter is not nil but has the same semantic value of nil.
I used nil
as default parameter value in my first commit but than @ck3g pointed out backward compatibility issues like the one I just show you.
What do you think?
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.
Ok, for bc. But if you take backwards compatibility serious, you should not alter the tests, but add new ones.
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 think the tests were inconsistent with Parse REST documentation. That's why I decided to change them.
Previously a simple request with device type set made the test failed because it checked no where
clause was created but if you want to specify a device type you have to add it as where
clause.
Same goes with nil channel.
If you want to send a broadcast message, you have to add a where
clause, hence a simple request could have a where clause and a channel specification.
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.
Fair point. And even it's not my responsibility to review your PR, I suggest submitting those changes as separate PR's.
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.
Submitting test pattern changes as different PR will make this PR never pass the Travis check. Or should I ignore it and make a new PR for test pattern changes?
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 run into that issue from time to time as well.
What if you rebase and merge some of your commits so that you only have 2 left; one with the test pattern changes and one with the other changes. Then you can force push the first commit, let Travis do its thing, and after that push the second commit.
This way it's easier to see what happened and what's the results on Travis per commit.
Changed order check of included parameters in body request to send to Parse.
@fabiomassimo hey, we can't auto merge this anymore because of other changes. If you'd like to get this in, could you merge master back into your branch and push that? |
@Xavdidtheshadow not sure what problem this PR solves. |
@koenpunt thanks! |
@Xavdidtheshadow thanks for taking care of this pr. Is there anything else I can do to help you out? |
@fabiomassimo thanks for the fix! You just need to update your branch with the current master and fix the conflicts so that your PR can be merged. |
…into no_channel_support
I just merged the latest changes from current master branch but I didn't come across any merge conflict. Am I missing something? |
Did you checkout and git pull each branch before merging? ~DB On Sun, Jun 7, 2015 at 9:25 AM, Fabio [email protected] wrote:
|
Sorry, wasn't clear. I meant pulled current master and merged that. Sometimes people forget to pull and then merge without conflict. But not that though, huh? I'm on mobile now, but I can actually dig into what the conflicts are later if you haven't found them by then. ~DB On Sun, Jun 7, 2015 at 10:37 AM, Fabio [email protected] wrote:
|
@Xavdidtheshadow thanks! I didn't encounter any conflict indeed. Let me know if I'm missing something. It seems good for me.. |
@fabiomassimo nice, the conflict seems to have resolved itself. Merged! |
[Push Notification] Added support for no channels
@Xavdidtheshadow just a thought, with my push and this we should probably start improving the documentation because they are both changes that modify the behavior |
@Xavdidtheshadow done |
Push Notification:
is sent to all target devices. (issue #140)
where
clause
where
clause in it.