Commit 92924a7
authored
feat: update notification services to support mobile. (#5120)
## Explanation
This is a large PR that enables support for push notifications on
mobile.
**Makes Push Notification Controller Platform Agnostic**
The `NotificationServicesPushController` was highly tied to web and was
not compatible for react-native.
We now have isolated the web logic in`web/push-utils.ts`, and allow
platforms to overwrite and inject a push service into the controller.
E.g. Mobile can inject push services using react-native modules.
**Add support to toggle push notifications on/off in isolation**
This allows us to decouple in-app notifications from push notifications.
It is done by adding a `isPushEnabled` boolean inside the
`NotificationServicesPushController`.
We have also added public methods `enablePushNotifications` and
`disablePushNotifications` inside the `NotificationServicesController`
to allow us tie it to UI Actions.
## References
## Changelog
### `@metamask/notification-services-controller`
- **ADDED**: `isPushEnabled` state to
`NotificationServicesPushControllerState` to enable and disable this
controller/
- **ADDED**: `isUpdatingFCMToken` state to
`NotificationServicesPushControllerState` to track when the controller
is updating for firebase registration token.
- **ADDED**: `PushService` interface and default web implementation for
push notifciations
- **CHANGED (BREAKING)**: `NotificationServicesPushController` config
now allows injecting of a `PushService` interface during controller
creation.
- **ADDED**: `/push-services/web` subpath export to import web specific
push services.
- **ADDED**: `/shared` folder including some shared utils used in
controllers for this package.
- **ADDED**: public method `enablePushNotifications` and
`disablePushNotifications` in `NotificationServicesController` to enable
and disable push notifications in isolation.
## Checklist
- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've highlighted breaking changes using the "BREAKING" category
above as appropriate
- [x] I've prepared draft pull requests for clients and consumer
packages to resolve any breaking changes1 parent a9c6e11 commit 92924a7
File tree
23 files changed
+1238
-425
lines changed- packages/notification-services-controller
- push-services/web
- src
- NotificationServicesController
- processors
- utils
- NotificationServicesPushController
- __fixtures__
- services
- push
- types
- utils
- web
23 files changed
+1238
-425
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
70 | 80 | | |
71 | 81 | | |
72 | 82 | | |
| |||
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
Lines changed: 83 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | 39 | | |
43 | 40 | | |
44 | | - | |
45 | 41 | | |
46 | 42 | | |
47 | 43 | | |
| |||
50 | 46 | | |
51 | 47 | | |
52 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
53 | 55 | | |
54 | 56 | | |
55 | 57 | | |
| |||
206 | 208 | | |
207 | 209 | | |
208 | 210 | | |
209 | | - | |
| 211 | + | |
210 | 212 | | |
211 | 213 | | |
212 | 214 | | |
| |||
471 | 473 | | |
472 | 474 | | |
473 | 475 | | |
474 | | - | |
| 476 | + | |
475 | 477 | | |
476 | 478 | | |
477 | 479 | | |
| |||
482 | 484 | | |
483 | 485 | | |
484 | 486 | | |
485 | | - | |
| 487 | + | |
486 | 488 | | |
487 | 489 | | |
488 | 490 | | |
| |||
1017 | 1019 | | |
1018 | 1020 | | |
1019 | 1021 | | |
| 1022 | + | |
1020 | 1023 | | |
1021 | 1024 | | |
1022 | 1025 | | |
| |||
1065 | 1068 | | |
1066 | 1069 | | |
1067 | 1070 | | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
1068 | 1138 | | |
1069 | 1139 | | |
1070 | 1140 | | |
| |||
1101 | 1171 | | |
1102 | 1172 | | |
1103 | 1173 | | |
| 1174 | + | |
1104 | 1175 | | |
1105 | 1176 | | |
1106 | 1177 | | |
| |||
1123 | 1194 | | |
1124 | 1195 | | |
1125 | 1196 | | |
1126 | | - | |
| 1197 | + | |
1127 | 1198 | | |
1128 | 1199 | | |
1129 | | - | |
| 1200 | + | |
1130 | 1201 | | |
1131 | 1202 | | |
1132 | | - | |
| 1203 | + | |
1133 | 1204 | | |
1134 | 1205 | | |
1135 | | - | |
| 1206 | + | |
1136 | 1207 | | |
1137 | 1208 | | |
1138 | 1209 | | |
| |||
1184 | 1255 | | |
1185 | 1256 | | |
1186 | 1257 | | |
1187 | | - | |
| 1258 | + | |
1188 | 1259 | | |
1189 | 1260 | | |
1190 | 1261 | | |
| |||
0 commit comments