( targetedNotifications: $ReadOnlyArray<TargetedAndroidNotification>, notificationInfo: NotificationInfo, )
| 1250 | invalidTokens?: $ReadOnlyArray<string>, |
| 1251 | }; |
| 1252 | async function sendAndroidNotification( |
| 1253 | targetedNotifications: $ReadOnlyArray<TargetedAndroidNotification>, |
| 1254 | notificationInfo: NotificationInfo, |
| 1255 | ): Promise<AndroidResult> { |
| 1256 | const collapseKey = notificationInfo.collapseKey |
| 1257 | ? notificationInfo.collapseKey |
| 1258 | : null; // for Flow... |
| 1259 | const { source, codeVersion, stateVersion } = notificationInfo; |
| 1260 | const response = await fcmPush({ |
| 1261 | targetedNotifications, |
| 1262 | collapseKey, |
| 1263 | codeVersion, |
| 1264 | }); |
| 1265 | const deviceTokens = targetedNotifications.map( |
| 1266 | ({ deliveryID }) => deliveryID, |
| 1267 | ); |
| 1268 | const androidIDs = response.fcmIDs ? response.fcmIDs : []; |
| 1269 | const delivery: AndroidDelivery = { |
| 1270 | source, |
| 1271 | deviceType: 'android', |
| 1272 | androidIDs, |
| 1273 | deviceTokens, |
| 1274 | codeVersion, |
| 1275 | stateVersion, |
| 1276 | }; |
| 1277 | if (response.errors) { |
| 1278 | delivery.errors = response.errors; |
| 1279 | } |
| 1280 | const result: AndroidResult = { |
| 1281 | info: notificationInfo, |
| 1282 | delivery, |
| 1283 | }; |
| 1284 | if (response.invalidTokens) { |
| 1285 | result.invalidTokens = response.invalidTokens; |
| 1286 | } |
| 1287 | return result; |
| 1288 | } |
| 1289 | |
| 1290 | type WebDelivery = { |
| 1291 | +source: NotificationInfo['source'], |
no test coverage detected