-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
feat: mobile push notifications #13006
Draft
Prithpal-Sooriya
wants to merge
36
commits into
main
Choose a base branch
from
feat/add-controller-push-notifications
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,008
−768
Draft
Changes from 7 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
b6471fc
feat: use reusable utilities to create push notification messages
Prithpal-Sooriya fbea0e4
feat: add metametric events for push notifications
Prithpal-Sooriya f2b8cac
refactor: notification services and manager cleanup
Prithpal-Sooriya 764e051
feat: use preview build
Prithpal-Sooriya d8525a4
refactor: remove UI push initialisation hook
Prithpal-Sooriya a9e2ad6
fix: fix type issues
Prithpal-Sooriya 350367b
refactor: clean up example env files
Prithpal-Sooriya 8663d91
feat: bump preview package
Prithpal-Sooriya e6395ca
Merge branch 'main' of github.com:MetaMask/metamask-mobile into feat/…
Prithpal-Sooriya d6bbb57
Merge branch 'main' of github.com:MetaMask/metamask-mobile into feat/…
Prithpal-Sooriya 4883a35
Merge branch 'main' of github.com:MetaMask/metamask-mobile into feat/…
Prithpal-Sooriya 07b0886
feat: add push click effect subscriptions
Prithpal-Sooriya 5ab1c22
chore: add TODO comment to remove duplicate code that is available in…
Prithpal-Sooriya 9501f3d
Merge branch 'main' of github.com:MetaMask/metamask-mobile into feat/…
Prithpal-Sooriya 4047bb1
feat: add guard for push subscription effect
Prithpal-Sooriya 01624eb
feat: add logic to turn off notifications if push notifications are n…
Prithpal-Sooriya 944b69e
feat: more cleanup work
Prithpal-Sooriya 3f5d8b0
Merge branch 'main' of github.com:MetaMask/metamask-mobile into feat/…
Prithpal-Sooriya 6579cfa
feat: update preview package
Prithpal-Sooriya 8157803
Merge branch 'main' of github.com:MetaMask/metamask-mobile into feat/…
Prithpal-Sooriya c37f677
refactor: clean up FCM service
Prithpal-Sooriya 541a754
Merge branch 'main' of github.com:MetaMask/metamask-mobile into feat/…
Prithpal-Sooriya 7b6934f
Merge branch 'main' of github.com:MetaMask/metamask-mobile into feat/…
Prithpal-Sooriya 108075a
fix: update notifee data prop error
Prithpal-Sooriya 39417e6
fix: fix engine not loading bug
Prithpal-Sooriya 172ffd2
feat: add background notifications headless check
Prithpal-Sooriya dc4e8d5
feat: remove app config change
Prithpal-Sooriya b35578f
refactor: FCM cleanup
Prithpal-Sooriya b4fa86a
feat: notification service - add id when displaying a notification
Prithpal-Sooriya e5dacc3
feat: add android default notification icon and color
Prithpal-Sooriya dec9945
fix: add android tag to prevent duplicate notifications
Prithpal-Sooriya c728ad5
refactor: FCM service cleanup
Prithpal-Sooriya f87de99
Merge branch 'main' of github.com:MetaMask/metamask-mobile into feat/…
Prithpal-Sooriya 84ec599
revert: remove app.config.js changes
Prithpal-Sooriya d2236f7
feat: remove background message subscriptions
Prithpal-Sooriya a5cf8a7
ci: update notification codeowners
Prithpal-Sooriya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,4 @@ | ||
export MM_FOX_CODE="EXAMPLE_FOX_CODE" | ||
export MM_BRANCH_KEY_TEST= | ||
export MM_BRANCH_KEY_LIVE= | ||
export METAMASK_BUILD_TYPE= | ||
# Firebase | ||
export FCM_CONFIG_API_KEY= | ||
export FCM_CONFIG_AUTH_DOMAIN= | ||
export FCM_CONFIG_PROJECT_ID= | ||
export FCM_CONFIG_STORAGE_BUCKET= | ||
export FCM_CONFIG_MESSAGING_SENDER_ID= | ||
export FCM_CONFIG_APP_ID= | ||
export GOOGLE_SERVICES_B64_ANDROID= | ||
#Notifications Feature Announcements | ||
export FEATURES_ANNOUNCEMENTS_ACCESS_TOKEN= | ||
export FEATURES_ANNOUNCEMENTS_SPACE_ID= | ||
|
||
export METAMASK_BUILD_TYPE= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,3 @@ | ||
MM_FOX_CODE = EXAMPLE_FOX_CODE | ||
MM_BRANCH_KEY_TEST = | ||
MM_BRANCH_KEY_LIVE = | ||
# Firebase | ||
FCM_CONFIG_API_KEY= | ||
FCM_CONFIG_AUTH_DOMAIN= | ||
FCM_CONFIG_PROJECT_ID= | ||
FCM_CONFIG_STORAGE_BUCKET= | ||
FCM_CONFIG_MESSAGING_SENDER_ID= | ||
FCM_CONFIG_APP_ID= | ||
GOOGLE_SERVICES_B64_IOS= | ||
#Notifications Feature Announcements | ||
FEATURES_ANNOUNCEMENTS_ACCESS_TOKEN= | ||
FEATURES_ANNOUNCEMENTS_SPACE_ID= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
app/core/Engine/controllers/PushNotificationController/get-notification-message.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import { | ||
type TranslationKeys, | ||
createOnChainPushNotificationMessage, | ||
} from '@metamask/notification-services-controller/push-services'; | ||
import type { INotification } from '@metamask/notification-services-controller/notification-services'; | ||
import { strings } from '../../../../../locales/i18n'; | ||
import type Translations from '../../../../../locales/languages/en.json'; | ||
|
||
type NotificationTranslations = (typeof Translations)['notifications']; | ||
type FlattenToString<TObj> = { | ||
[K in keyof TObj]: TObj[K] extends string | ||
? `${K & string}` | ||
: `${K & string}.${FlattenToString<TObj[K]>}`; | ||
}[keyof TObj]; | ||
|
||
type NotificationStrings = | ||
`notifications.${FlattenToString<NotificationTranslations>}`; | ||
|
||
const t = (name: NotificationStrings, params?: object) => | ||
strings(name, params) ?? ''; | ||
|
||
const translations: TranslationKeys = { | ||
pushPlatformNotificationsFundsSentTitle: () => | ||
t('notifications.push_notification_content.funds_sent_title'), | ||
pushPlatformNotificationsFundsSentDescriptionDefault: () => | ||
t('notifications.push_notification_content.funds_sent_default_description'), | ||
pushPlatformNotificationsFundsSentDescription: (amount, symbol) => | ||
t('notifications.push_notification_content.funds_sent_description', { | ||
amount, | ||
symbol, | ||
}), | ||
pushPlatformNotificationsFundsReceivedTitle: () => | ||
t('notifications.push_notification_content.funds_received_title'), | ||
pushPlatformNotificationsFundsReceivedDescriptionDefault: () => | ||
t( | ||
'notifications.push_notification_content.funds_received_default_description', | ||
), | ||
pushPlatformNotificationsFundsReceivedDescription: (amount, symbol) => | ||
t('notifications.push_notification_content.funds_received_description', { | ||
amount, | ||
symbol, | ||
}), | ||
pushPlatformNotificationsSwapCompletedTitle: () => | ||
t('notifications.metamask_swap_completed_title'), | ||
pushPlatformNotificationsSwapCompletedDescription: () => | ||
t( | ||
'notifications.push_notification_content.metamask_swap_completed_description', | ||
), | ||
pushPlatformNotificationsNftSentTitle: () => | ||
t('notifications.push_notification_content.nft_sent_title'), | ||
pushPlatformNotificationsNftSentDescription: () => | ||
t('notifications.push_notification_content.nft_sent_description'), | ||
pushPlatformNotificationsNftReceivedTitle: () => | ||
t('notifications.push_notification_content.nft_received_title'), | ||
pushPlatformNotificationsNftReceivedDescription: () => | ||
t('notifications.push_notification_content.nft_received_description'), | ||
pushPlatformNotificationsStakingRocketpoolStakeCompletedTitle: () => | ||
t('notifications.rocketpool_stake_completed_title'), | ||
pushPlatformNotificationsStakingRocketpoolStakeCompletedDescription: () => | ||
t( | ||
'notifications.push_notification_content.rocketpool_stake_completed_description', | ||
), | ||
pushPlatformNotificationsStakingRocketpoolUnstakeCompletedTitle: () => | ||
t('notifications.rocketpool_unstake_completed_title'), | ||
pushPlatformNotificationsStakingRocketpoolUnstakeCompletedDescription: () => | ||
t( | ||
'notifications.push_notification_content.rocketpool_unstake_completed_description', | ||
), | ||
pushPlatformNotificationsStakingLidoStakeCompletedTitle: () => | ||
t('notifications.lido_stake_completed_title'), | ||
pushPlatformNotificationsStakingLidoStakeCompletedDescription: () => | ||
t( | ||
'notifications.push_notification_content.lido_stake_completed_description', | ||
), | ||
pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnTitle: () => | ||
t('notifications.lido_stake_ready_to_be_withdrawn_title'), | ||
pushPlatformNotificationsStakingLidoStakeReadyToBeWithdrawnDescription: () => | ||
t( | ||
'notifications.push_notification_content.lido_stake_ready_to_be_withdrawn_description', | ||
), | ||
pushPlatformNotificationsStakingLidoWithdrawalRequestedTitle: () => | ||
t('notifications.lido_withdrawal_requested_title'), | ||
pushPlatformNotificationsStakingLidoWithdrawalRequestedDescription: () => | ||
t( | ||
'notifications.push_notification_content.lido_withdrawal_requested_description', | ||
), | ||
pushPlatformNotificationsStakingLidoWithdrawalCompletedTitle: () => | ||
t('notifications.lido_withdrawal_completed_title'), | ||
pushPlatformNotificationsStakingLidoWithdrawalCompletedDescription: () => | ||
t( | ||
'notifications.push_notification_content.lido_withdrawal_completed_description', | ||
), | ||
}; | ||
|
||
export function createNotificationMessage(notification: INotification) { | ||
return createOnChainPushNotificationMessage(notification, translations); | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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'm removing these events for mobile, they are not feasible.
Context:
Mobile background and killed push notifications currently will not run headless JS for us to then intercept and send events for receive and clicks