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

Adds support for localized push notification in push payload #4129

Merged
merged 5 commits into from
Sep 1, 2017

Conversation

flovilmart
Copy link
Contributor

@flovilmart flovilmart commented Sep 1, 2017

  • passign alert-[lang|locale] or title-[lang|locale] will inject the
    proper locale on the push body based on the installation

ex:

{
   where: {...} // your query,
   data: {
     alert: 'Default alert',
     alert-fr: 'Alerte en Francais',
     ...
   }
}

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...

- passign alert-[lang|locale] or title-[lang|locale] will inject the
  proper locale on the push body based on the installation
@flovilmart flovilmart requested a review from acinader September 1, 2017 18:10
@codecov
Copy link

codecov bot commented Sep 1, 2017

Codecov Report

Merging #4129 into master will increase coverage by 0.02%.
The diff coverage is 98.07%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
src/Routers/PushRouter.js 96.15% <ø> (ø) ⬆️
src/Push/PushWorker.js 93.54% <100%> (+1.09%) ⬆️
src/Push/utils.js 98.36% <97.67%> (-1.64%) ⬇️
src/RestWrite.js 92.81% <0%> (-0.38%) ⬇️

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 540daa4...4887f88. Read the comment docs.

acinader
acinader previously approved these changes Sep 1, 2017
Copy link
Contributor

@acinader acinader left a 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.

@@ -61,7 +61,7 @@ export class PushController {
}).catch((err) => {
return pushStatus.fail(err).then(() => {
throw err;
});
Copy link
Contributor

Choose a reason for hiding this comment

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

could revert this.

map[badge].push(installation);
function groupBy(key, objects) {
return objects.reduce((map, object) => {
const value = object[key] + '';
Copy link
Contributor

Choose a reason for hiding this comment

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

toString() ?

Copy link
Contributor Author

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) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

slick

@@ -28,6 +28,8 @@ export class PushRouter extends PromiseRouter {
result: true
}
});
}).catch((err) => {
req.config.loggerController.error(err);
});
Copy link
Contributor

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)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep

Copy link
Contributor

@acinader acinader left a 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.

});
});

it('should properly handle defaut cases', () => {
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch!

if (added) {
return;
}
if (installation.localeIdentifier && installation.localeIdentifier.indexOf(locale) == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

prefer ===

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep!

@flovilmart
Copy link
Contributor Author

Thanks for the quick review @acinader !

@flovilmart flovilmart merged commit 6df9447 into master Sep 1, 2017
@flovilmart flovilmart deleted the localized-push-notifications branch September 1, 2017 19:22
@julianvogels
Copy link

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.

parse-community/parse-server-push-adapter#41

@flovilmart
Copy link
Contributor Author

Yes, it’s 100% compatible with android.

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.

3 participants