-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Adds support for localized push notification in push payload #4129
Conversation
- passign alert-[lang|locale] or title-[lang|locale] will inject the proper locale on the push body based on the installation
Codecov Report
@@ Coverage Diff @@
## master #4129 +/- ##
==========================================
+ Coverage 90.79% 90.81% +0.02%
==========================================
Files 116 116
Lines 7941 7993 +52
==========================================
+ Hits 7210 7259 +49
- Misses 731 734 +3
Continue to review full report at Codecov.
|
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.
lgtm. some optional nits for you.
src/Controllers/PushController.js
Outdated
@@ -61,7 +61,7 @@ export class PushController { | |||
}).catch((err) => { | |||
return pushStatus.fail(err).then(() => { | |||
throw err; | |||
}); |
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 revert this.
src/Push/PushWorker.js
Outdated
map[badge].push(installation); | ||
function groupBy(key, objects) { | ||
return objects.reduce((map, object) => { | ||
const value = object[key] + ''; |
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.
toString() ?
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.
actually I should revert that.
if (!data) { | ||
return []; | ||
} | ||
return [...new Set(Object.keys(data).reduce((memo, key) => { |
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.
slick
src/Routers/PushRouter.js
Outdated
@@ -28,6 +28,8 @@ export class PushRouter extends PromiseRouter { | |||
result: true | |||
} | |||
}); | |||
}).catch((err) => { | |||
req.config.loggerController.error(err); | |||
}); |
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 just .catch(req.config.loggerController.error)
?
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.
yep
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.
found a typo in a comment.
spec/PushWorker.spec.js
Outdated
}); | ||
}); | ||
|
||
it('should properly handle defaut cases', () => { |
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.
defaut is a typo. Should be default.
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.
good catch!
src/Push/utils.js
Outdated
if (added) { | ||
return; | ||
} | ||
if (installation.localeIdentifier && installation.localeIdentifier.indexOf(locale) == 0) { |
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.
prefer ===
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.
yep!
Thanks for the quick review @acinader ! |
Is this somehow compatible with the "notification" field in the FCM/Android payload? I'd like to easily send localized push notifications to that platform as well. |
Yes, it’s 100% compatible with android. |
proper locale on the push body based on the installation
ex:
I'll need to update the docs accordingly, with that feature, we'll be able to restore those in the dashboard as well, being able to add localized alerts etc...