使用 Detox 打开本地通知时出错

Har*_*kka 5 react-native detox

我正在尝试使用排毒打开模拟本地通知,但出现错误。

我的代码:

it('Notif', async () => {
const localNotification = {
  trigger: {
    type: 'push',
  },
  title: 'From push',
  body: 'Body',
  action: 'IDEAS',
  payload: {
    title: 'From push',
    body: 'Body',
    action: 'PROFILE',
  },
};
await device.sendUserNotification(localNotification);
// await device.launchApp({
//   newInstance: true,
//   userNotification: localNotification,
// });
});
Run Code Online (Sandbox Code Playgroud)

测试失败并出现以下错误:

Test Failed: No Activity found to handle Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x24000000 pkg=com.detoxproj2 (has extras) }

detox[17158] ERROR: [cli.js] Error: Command failed: jest --config e2e/config.json --testNamePattern '^((?!:ios:).)*$' --maxWorkers 1 e2e
Run Code Online (Sandbox Code Playgroud)

代码中的注释部分也无法按预期工作,它应该通过通知参数打开应用程序,但这里不会发生。另外我不知道问题是否是由于某些本机 android 错误引起的..?

有谁帮忙...!