Improve wording for push notifications (#11378)

This commit is contained in:
Phillip Thelen
2019-09-29 18:45:30 +02:00
committed by Matteo Pagliazzi
parent b142225a5a
commit 17e8b0a0fd
6 changed files with 13 additions and 11 deletions

View File

@@ -25,7 +25,7 @@
"inviteParty": "Invite Party to Quest", "inviteParty": "Invite Party to Quest",
"questInvitation": "Quest Invitation: ", "questInvitation": "Quest Invitation: ",
"questInvitationTitle": "Quest Invitation", "questInvitationTitle": "Quest Invitation",
"questInvitationInfo": "Invitation for the Quest <%= quest %>", "questInvitationNotificationInfo": "You were invited to join a quest",
"invitedToQuest": "You were invited to the Quest <span class=\"notification-bold-blue\"><%= quest %></span>", "invitedToQuest": "You were invited to the Quest <span class=\"notification-bold-blue\"><%= quest %></span>",
"askLater": "Ask Later", "askLater": "Ask Later",
"questLater": "Quest Later", "questLater": "Quest Later",

View File

@@ -111,7 +111,7 @@
"emailNotifications": "Email Notifications", "emailNotifications": "Email Notifications",
"wonChallenge": "You won a Challenge!", "wonChallenge": "You won a Challenge!",
"newPM": "Received Private Message", "newPM": "Received Private Message",
"newPMInfo": "New Message from <%= name %>: <%= message %>", "newPMNotificationTitle": "New Message from <%= name %>",
"giftedGems": "Gifted Gems", "giftedGems": "Gifted Gems",
"giftedGemsInfo": "<%= name %> gifted you <%= amount %> Gems", "giftedGemsInfo": "<%= name %> gifted you <%= amount %> Gems",
"giftedGemsFull": "Hello <%= username %>, <%= sender %> has sent you <%= gemAmount %> gems!", "giftedGemsFull": "Hello <%= username %>, <%= sender %> has sent you <%= gemAmount %> gems!",
@@ -119,8 +119,8 @@
"giftedSubscriptionInfo": "<%= name %> gifted you a <%= months %> month subscription", "giftedSubscriptionInfo": "<%= name %> gifted you a <%= months %> month subscription",
"giftedSubscriptionFull": "Hello <%= username %>, <%= sender %> has sent you <%= monthCount %> months of subscription!", "giftedSubscriptionFull": "Hello <%= username %>, <%= sender %> has sent you <%= monthCount %> months of subscription!",
"giftedSubscriptionWinterPromo": "Hello <%= username %>, you received <%= monthCount %> months of subscription as part of our holiday gift-giving promotion!", "giftedSubscriptionWinterPromo": "Hello <%= username %>, you received <%= monthCount %> months of subscription as part of our holiday gift-giving promotion!",
"invitedParty": "Invited To Party", "invitedParty": "You were invited to a Party",
"invitedGuild": "Invited To Guild", "invitedGuild": "You were invited to a Guild",
"importantAnnouncements": "Reminders to check in to complete tasks and receive prizes", "importantAnnouncements": "Reminders to check in to complete tasks and receive prizes",
"weeklyRecaps": "Summaries of your account activity in the past week (Note: this is currently disabled due to performance issues, but we hope to have this back up and sending e-mails again soon!)", "weeklyRecaps": "Summaries of your account activity in the past week (Note: this is currently disabled due to performance issues, but we hope to have this back up and sending e-mails again soon!)",
"onboarding": "Guidance with setting up your Habitica account", "onboarding": "Guidance with setting up your Habitica account",

View File

@@ -124,8 +124,8 @@ api.inviteToQuest = {
sendPushNotification( sendPushNotification(
member, member,
{ {
title: res.t('questInvitationTitle', member.preferences.language), title: quest.text(member.preferences.language),
message: res.t('questInvitationInfo', {quest: quest.text(member.preferences.language)}, member.preferences.language), message: res.t('questInvitationNotificationInfo', member.preferences.language),
identifier: 'questInvitation', identifier: 'questInvitation',
category: 'questInvitation', category: 'questInvitation',
} }

View File

@@ -17,8 +17,8 @@ export async function sentMessage (sender, receiver, message, translate) {
sendPushNotification( sendPushNotification(
receiver, receiver,
{ {
title: translate('newPM', receiver.preferences.language), title: translate('newPMNotificationTitle', {name: getUserInfo(sender, ['name']).name}, receiver.preferences.language),
message: translate('newPMInfo', {name: getUserInfo(sender, ['name']).name, message}, receiver.preferences.language), message,
identifier: 'newPM', identifier: 'newPM',
category: 'newPM', category: 'newPM',
payload: {replyTo: sender._id}, payload: {replyTo: sender._id},

View File

@@ -19,7 +19,7 @@ if (APN_ENABLED) {
keyId: nconf.get('PUSH_CONFIGS_APN_KEY_ID'), keyId: nconf.get('PUSH_CONFIGS_APN_KEY_ID'),
teamId: nconf.get('PUSH_CONFIGS_APN_TEAM_ID'), teamId: nconf.get('PUSH_CONFIGS_APN_TEAM_ID'),
}, },
production: nconf.get('IS_PROD'), production: true,
}) : undefined; }) : undefined;
} }
@@ -56,7 +56,9 @@ function sendNotification (user, details = {}) {
case 'ios': case 'ios':
if (apnProvider) { if (apnProvider) {
const notification = new apn.Notification({ const notification = new apn.Notification({
alert: details.message, alert: {title: details.title,
body: details.message,
},
sound: 'default', sound: 'default',
category: details.category, category: details.category,
topic: 'com.habitrpg.ios.Habitica', topic: 'com.habitrpg.ios.Habitica',

View File

@@ -699,7 +699,7 @@ schema.methods.startQuest = async function startQuest (user) {
const memberLang = member.preferences.language; const memberLang = member.preferences.language;
sendPushNotification(member, { sendPushNotification(member, {
title: quest.text(memberLang), title: quest.text(memberLang),
message: `${shared.i18n.t('questStarted', memberLang)}: ${quest.text(memberLang)}`, message: shared.i18n.t('questStarted', memberLang),
identifier: 'questStarted', identifier: 'questStarted',
}); });
} }