我正在React Native上构建VoIP应用程序,该应用程序使用推送通知检测来电。我需要启动应用程序,并在收到推送通知时将其置于前台。我能够在以下情况下实现:
我无法处理的唯一情况是设备被锁定并且应用被杀死时。该应用程序启动,但未显示在锁定屏幕上。相反,用户需要解锁手机才能访问应用程序。
这是收到通知时运行的代码,
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Intent notificationIntent = new Intent(this, MainActivity.class);
// Check if app is running
if(MainActivity.isAppRunning) {
startActivity(notificationIntent);
Intent messagingEvent = new Intent(MESSAGE_EVENT);
messagingEvent.putExtra("message", remoteMessage);
// Broadcast it so it is only available to the RN Application
LocalBroadcastManager
.getInstance(this)
.sendBroadcast(messagingEvent);
} else {
startActivity(notificationIntent);
try {
// If the app is in the background we send it to the Headless JS Service
Intent headlessIntent = new Intent(
this.getApplicationContext(), …Run Code Online (Sandbox Code Playgroud) java android react-native react-native-android react-native-navigation
我正在使用 Yarn v2 (berry) 来管理具有以下结构的 monorepo:
project-root
/packages
react-native-app
(dependencies: my-hooks-lib, react@17.0.1)
my-hooks-lib
(dependency: react@17.0.1)
Run Code Online (Sandbox Code Playgroud)
这是我的 .yarnrc.yml:
yarnPath: ".yarn/releases/yarn-berry.cjs"
nodeLinker: "node-modules"
nmHoistingLimits: "workspaces"
Run Code Online (Sandbox Code Playgroud)
自从我使用 React Native 应用程序以来,我已经禁用了提升。但正因为如此,react-native-app并且my-hooks-lib有单独的副本react@17.0.1,即使版本相同。这会导致Invalid Hooks call错误:
Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You …Run Code Online (Sandbox Code Playgroud) 我有一个React Native项目设置使用,react-native init并且正在使用Storybook隔离开发我的组件。我getstorybook在该项目中运行了该命令,然后CLI生成了一个storybook包含所有必需文件的目录,如Storybook docs中所述。
当我运行npm run storybookcommand后跟时react-native run-android,我可以在模拟器上查看故事。现在,如果我需要运行我的主要应用程序(而非传奇故事,但是这是由所产生的一个react-native init命令),我要运行npm run start之后react-native run-android。
每当我从Storybook切换到主应用程序时,是否有不必不必构建应用程序的方法?我在这里错过明显的东西吗?
提前致谢!
我正在尝试实现这种阴影效果,其中阴影就像图像本身的模糊版本:
我能够通过将相同的图像堆叠两次并应用于下面的图像来实现它filter: blur(20px),但这感觉就像一种低效的方式:
.cover-wrapper {
position: relative;
margin: 50px;
width: 200px;
height: 200px;
}
.cover {
z-index: 1;
border-radius: 10px;
position: absolute;
width: 200px;
height: 200px;
}
.cover-shadow-wrapper {
position: absolute;
filter: blur(20px);
overflow: hidden;
height: 200px;
width: 200px;
}
.cover-shadow {
transform: scale(1.5)
}Run Code Online (Sandbox Code Playgroud)
<div class="cover-wrapper">
<img src="https://picsum.photos/200/200?image=871" alt="cover" class="cover">
<div class="cover-shadow-wrapper">
<img src="https://picsum.photos/200/200?image=871" alt="shadow" class="cover-shadow">
</div>
</div>Run Code Online (Sandbox Code Playgroud)
有更有效的方法吗?此外,这个效果实际上叫什么?
我使用Acer Aspire E1-530搭配Intel 2117U处理器和6GB RAM.
我按照React Native网站中给出的步骤安装了React Native和Android Studio 2.3,并且还按照此Ubuntu文档中的说明安装了KVM .Android Studio启动没有问题,我成功地设置了AVD,但是当我启动AVD时,一个小窗口显示一小段时间然后消失.我也试过运行emulator从~/Android/Sdk/tools,但它显示了这个错误:
libGL error: unable to load driver: i965_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: i965
libGL error: unable to load driver: i965_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: i965
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
X Error of failed request: GLXBadContext
Major opcode …Run Code Online (Sandbox Code Playgroud) ubuntu android-emulator android-studio react-native ubuntu-16.04
仅当我将PWA添加到主屏幕并从那里运行应用程序时才会发生这种情况.当我在移动或桌面浏览器上运行应用程序时,我没有看到这种行为.
我正在使用create-react-app构建的React应用程序.运行npm run build并使用任何本地http服务器提供后,它工作正常.一旦我将其部署到Firebase或now在Firefox或Chrome移动浏览器上打开网站,它似乎也能正常工作.但是,当我点击弹出窗口中的"添加到主屏幕"按钮时,它会被添加,但是从主屏幕图标打开它会呈现404路线.
<Switch/>如果没有路径匹配URL,我使用react-router的组件路由到自定义404页面.以下是我定义路由器"配置"的方法:
<Router>
<Switch>
<Route exact path="/" component={Login} />
<Route path="/login" component={Login} />
<Route path="/sign-up" component={SignUp} />
<Route
render={() => (
<div>
<h1>Error 404: Not Found</h1>
<Link to="/">Go Home</Link>
</div>)}
/>
</Switch>
</Router>
Run Code Online (Sandbox Code Playgroud)
我的软件包版本package.json:
react:^ 16.2.0 react-scripts:1.1.0 react-router-dom:^ 4.2.2javascript reactjs react-router progressive-web-apps create-react-app
我正在使用@remote-ui/react库在 Web Worker 中呈现我的 React 代码。我在项目中使用 Vite,但每当我尝试在工作脚本中使用 JSX 时,我都会看到以下错误:
Uncaught Error: @vitejs/plugin-react can't detect preamble. Something is wrong. See https://github.com/vitejs/vite-plugin-react/pull/11#discussion_r430879201
Run Code Online (Sandbox Code Playgroud)
我在这里创建了一个最小的复制品。
react-native ×4
reactjs ×3
android ×2
css ×1
html ×1
java ×1
javascript ×1
react-router ×1
storybook ×1
ubuntu ×1
ubuntu-16.04 ×1
vite ×1
yarnpkg ×1
yarnpkg-v2 ×1