MCPcopy Index your code
hub / github.com/callstack/agent-device / pushAndroidNotification

Function pushAndroidNotification

src/platforms/android/notifications.ts:11–41  ·  view source on GitHub ↗
(
  device: DeviceInfo,
  packageName: string,
  payload: AndroidBroadcastPayload,
)

Source from the content-addressed store, hash-verified

9};
10
11export async function pushAndroidNotification(
12 device: DeviceInfo,
13 packageName: string,
14 payload: AndroidBroadcastPayload,
15): Promise<{ action: string; extrasCount: number }> {
16 const action =
17 typeof payload.action === 'string' && payload.action.trim()
18 ? payload.action.trim()
19 : `${packageName}.TEST_PUSH`;
20 const args = ['shell', 'am', 'broadcast', '-a', action, '-p', packageName];
21 const receiver = typeof payload.receiver === 'string' ? payload.receiver.trim() : '';
22 if (receiver) {
23 args.push('-n', receiver);
24 }
25 const rawExtras = payload.extras;
26 if (
27 rawExtras !== undefined &&
28 (typeof rawExtras !== 'object' || rawExtras === null || Array.isArray(rawExtras))
29 ) {
30 throw new AppError('INVALID_ARGS', 'Android push payload extras must be an object');
31 }
32 const extras = rawExtras ?? {};
33 let extrasCount = 0;
34 for (const [key, rawValue] of Object.entries(extras)) {
35 if (!key) continue;
36 appendBroadcastExtra(args, key, rawValue);
37 extrasCount += 1;
38 }
39 await runAndroidAdb(device, args);
40 return { action, extrasCount };
41}
42
43function appendBroadcastExtra(args: string[], key: string, value: unknown): void {
44 if (typeof value === 'string') {

Callers 2

index.test.tsFile · 0.90
handlePushCommandFunction · 0.85

Calls 3

runAndroidAdbFunction · 0.90
appendBroadcastExtraFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected