React Native - 来自 Native Modules for Android 的 iOS CustomUserAgent

React Native - iOS CustomUserAgent from Native Modules for Android

提问人:paulalexandru 提问时间:11/10/2023 更新时间:11/10/2023 访问量:13

问:

所以我有一个 reactnative 项目,当 platfrom 是 iOS 时,正在执行一些代码行:

import { NativeModules, Platform } from "react-native";
if (Platform.OS === "ios") {
    const { CustomUserAgent } = NativeModules;
    CustomUserAgent.registerCustomUserAgent('a new user agent');
}

我想为 Android 设备提供类似的东西。由于我不是 reactnative 开发人员,我认为我所要做的就是复制它并用“android”替换,它应该可以工作,但我收到了这个错误。iOSCannot read property 'registerCustomUserAgent' of null

所以我猜 NativeModules 包含一些不同的东西,具体取决于平台,但在这里看 https://reactnative.dev/docs/native-modules-ios,在这里 https://reactnative.dev/docs/native-modules-android 我没有找到任何东西。

如何为 Android 设备构建这样的流程?

javascript android 反应原生

评论


答: 暂无答案