我正在使用以下代码在 Android 上为我的 expo react 应用程序创建两个通道:
Notifications.setNotificationChannelAsync("default", {
name: "default",
importance: Notifications.AndroidImportance.MAX,
vibrationPattern: [0, 250, 250, 250],
lightColor: "#FF231F7C",
})
Notifications.setNotificationChannelAsync("gameupdates", {
name: "gameupdates",
importance: Notifications.AndroidImportance.MAX,
vibrationPattern: [0, 250, 250, 250],
lightColor: "#FF231F7C",
})
Run Code Online (Sandbox Code Playgroud)
频道已成功创建,当我进入 Expo 应用程序通知选项时,我什至可以找到它。
当我使用没有任何频道 ID 的expo 工具发送通知时,它工作正常。但是,当我使用频道 ID“gameupdates”时,通知永远不会到达我的手机。
知道为什么吗?
我在博览会 sdk 38 上。
我正在与Expo一起开发本机消息应用程序。每当用户收到新消息时,我都会从服务器发送通知。
如果应用程序当前处于打开状态,有什么方法不显示通知?
现在,我会在收到通知后立即使用它:
Notifications.dismissNotificationAsync(notification.notificationId);
Run Code Online (Sandbox Code Playgroud)
但是有0.5秒的延迟,通知有时间出现在托盘中并在被取消之前触发声音。我完全不想显示它。
我希望两个不同的切片能够交叉引用彼此的操作,如下所示:
const sliceA = createSlice({
name: "sliceA",
initialState: null,
reducers: {
someReducer: (state, action) => {
// do something
},
},
extraReducers: {
[sliceB.actions.anotherReducer]: (state, action) => {
// do something
},
},
});
const sliceB = createSlice({
name: "sliceB",
initialState: null,
reducers: {
anotherReducer: (state, action) => {
// do something else
},
},
extraReducers: {
[sliceA.actions.someReducer]: (state, action) => {
// do something else
},
},
});
Run Code Online (Sandbox Code Playgroud)
问题是我在尝试为 sliceA 设置 extraReducers 时收到 sliceB 未定义的错误。
为了清楚起见,我想将切片分开,但它们的某些操作会相互影响。
实现这一目标的好方法是什么?
我正在构建一个聊天应用程序,使用倒置的Flatlist. 我在onEndReached调用时将新项目添加到列表顶部,并且一切正常。
问题是,如果将项目添加到底部,它会立即滚动到列表底部。这意味着用户必须向上滚动才能阅读刚刚添加的消息(这很糟糕)。
我试图调用scrollToOffsetin onContentSizeChange,但这有 1 秒的延迟,滚动来回跳跃。
当我将项目添加到顶部和底部时,如何通过在屏幕上保留相同的消息而不是显示新消息来使列表行为相同?
升级到 expo SDK 43 后,我在 Android 上收到此错误:
Invariant Violation: requireNativeComponent: "AndroidCheckBox" was not found in the UIManager.
This error is located at:
in AndroidCheckBox (created by CheckBox)
in CheckBox
in CheckBoxWithRef (at SimpleCheckbox.js:18) <-- custom component
in SimpleCheckbox (at LoginScreen.js:76) <-- custom component
Run Code Online (Sandbox Code Playgroud)
我正在"@react-native-community/checkbox": "^0.5.9"托管工作流程上使用 , 。
我尝试运行,expo install @react-native-community/checkbox因为我看到其他帖子以这种方式解决了他们自己的“在 UIManager 中找不到”错误,但它并没有解决问题。
我正在构建一个聊天应用程序,从React-Native版本开始0.63,当Android上的倒置 Flatlist 中涉及长文本时,我的性能很差。
这是展示该问题的小吃再现(仅在尝试使用物理 Android 手机时可见)。
我为它报告了一个错误。对于正在使用倒置 Flatlist 构建聊天应用程序的任何人来说,这应该是相当公然的,但不知何故,我没有看到任何地方都在谈论这个问题。
这让我觉得也许其他人已经以某种方式解决了它?如果是,我该如何解决?它使我的应用程序现在几乎无法使用。
我正在将 ReactNative 移动应用程序改编为 ReactNative Web。该应用程序完成了react-navigation。
目前,每次我设置路由的参数(通过navigate或setParams)时,这些参数都会显示在 URL 中。我最终得到的网址看起来很糟糕,如下所示:
http://localhost:19006/me/undefined?user=%5Bobject%20Object%5D
或者 URL 包含与用户无关的数据,并且通常看起来很混乱。
有没有办法不显示 URL 中的路由参数?
我目前收到以下错误的垃圾邮件:
dictionary update sequence element #0 has length 14; 2 is required 这似乎是由 ('SessionStore' object has no attribute '_session_cache')
我在这个问题中读到:Django 项目正在寻找“属性 '_session_cache'”,问题可能是我没有django_session表,但我有,而且里面充满了内容。
知道什么会引起这种情况吗?
我在 Python 上3.6.7,django2.1.7
这是完整的错误堆栈:
File "/path/to/venv/lib/python3.6/site-packages/django/contrib/sessions/backends/base.py" in _get_session
190. return self._session_cache
During handling of the above exception ('SessionStore' object has no attribute '_session_cache'), another exception occurred:
File "/path/to/venv/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
34. response = get_response(request)
File "/path/to/venv/lib/python3.6/site-packages/django/utils/deprecation.py" in __call__
90. response = self.process_request(request)
File "/path/to/venv/lib/python3.6/site-packages/django/middleware/locale.py" in process_request
21. language = translation.get_language_from_request(request, …Run Code Online (Sandbox Code Playgroud) 我有一个与Django频道进行通讯的React Native应用(android)。通过连接到我的开发服务器时ws,一切正常。但是,当我尝试wss使用相同的代码连接到远程服务器时,没有任何反应。
套接字连接显示为OPEN。我什至收到"connected"从服务器发送到我的应用程序的第一条消息:
class RGConsumer(AsyncWebsocketConsumer):
rooms = []
async def connect(self):
self.rooms = []
await self.join_room('all')
await self.accept()
await self.send(text_data=json.dumps({'event': 'connected'}))
async def join_room(self, room_name):
if room_name not in self.rooms:
self.rooms.append(room_name)
await self.channel_layer.group_add(
room_name,
self.channel_name
)
Run Code Online (Sandbox Code Playgroud)
问题在于,除了第一个消息之外,没有其他消息通过。例如,无论我通过此函数发送的内容如何,都不会被应用程序接收:
def send_to_all(event, data=None):
message = {'type': 'channel_event', 'message': {'event': event, 'data': data}}
channel_layer = get_channel_layer()
async_to_sync(channel_layer.group_send)(
'all',
message
)
Run Code Online (Sandbox Code Playgroud)
以相同的方式,当我调用websocket.send我的应用程序时,receive根本不会触发我的使用者的功能。
再一次,这在我的本地服务器上工作得很好,所以我认为代码是正确的。只有将应用程序连接到生产wss服务器时,它才会停止工作(除了connected收到第一条消息外)
此外,websocket.onclose如果我决定重新启动生产服务器,则该函数也不会被调用。
是否有其他设置可以允许我正确丢失与wss服务器的正确连接?
让我知道是否需要更多代码。我不确定还需要什么。
我想在用户点击按钮时显示一个模式,而不是关闭键盘。不幸的是,一旦模态出现,键盘就会消失。
最小再现案例:
import * as React from "react";
import { Button, Modal, Text, TextInput, View } from "react-native";
function TestComp() {
const [showingModal, setshowingModal] = React.useState(false);
return (
<View style={{ flex: 1, justifyContent: "center", alignItems: "center", marginTop: 22 }}>
<Modal visible={showingModal} transparent onRequestClose={() => setshowingModal(false)}>
<View style={{ flex: 1, marginTop: 22 }}>
<Button title={"hide modal"} onPress={() => setshowingModal(false)} />
</View>
</Modal>
<TextInput placeholder="Focus to show keyboard" />
<Button title={"Show modal"} onPress={() => setshowingModal(true)} />
</View>
);
}
Run Code Online (Sandbox Code Playgroud)
仅供参考,我正在使用世博会。
如何强制键盘持久化?