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

ForegroundShow flag is being omitted #8

Open
hilariocoelho opened this issue Dec 10, 2021 · 4 comments · May be fixed by #9
Open

ForegroundShow flag is being omitted #8

hilariocoelho opened this issue Dec 10, 2021 · 4 comments · May be fixed by #9

Comments

@hilariocoelho
Copy link

HMS PushKit ForegroundShow flag defaults to true so this field should be sent explicitly with false in order to don't display a notification when the app is in foreground.

Huawei documentation should also be improved in order to say explicitly that the default value of foreground_show flag is true if it is not sent.

Documentation links:
https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/android-fgrd-show-0000001050040126
https://developer.huawei.com/consumer/en/doc/development/HMSCore-References/https-send-api-0000001050986197#EN-US_TOPIC_0000001134031085__p163211583235

@hilariocoelho hilariocoelho linked a pull request Dec 10, 2021 that will close this issue
@Mike-mei
Copy link
Contributor

Thank you for your advice. There is no need to add a default value to a Boolean value, it can be judged according to the meaning of the field.

@hilariocoelho
Copy link
Author

I'm not sure if you understood what I tried to explain.

The problem here is that foreground_show flag is being omitted when the value is false (which is the default value due to Go zero-initialization) but Huawei Mobile Service assume the value as true if it is not sent as part of the request JSON's body.

Using this library it is not possible to create a notification with foreground_show as false because HMS will assume it as true because it was not sent. This is a problem I ran into while using appleboy/gorush which led to this and this fix.

Besides the issue itself, I'm also suggesting improving Huawei's documentation by saying that if the flag is not sent in the request's body then it is considered as true.

@Mike-mei
Copy link
Contributor

Thank you for your advice, we will add the default value of foreground_show in the document.

@hilariocoelho
Copy link
Author

Specifying in HMS documentation that default value for foreground_show is true is a good improvement but it doesn't fix the issue in this library.

The property defined here has an omitempty JSON tag that prevents the flag from being sent on the request when the value is false. Since the flag is not sent and HMS default value is true it is currently impossible to specify it as false.

I opened PR #9 that removes the omitempty tag.

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 a pull request may close this issue.

2 participants