标签: react-native-android

React Native,使用纵向模式检测屏幕旋转变化

我在 react-native 应用程序中使用纵向模式。但我想捕获屏幕的旋转事件。有没有办法做到这一点?

谢谢...

react-native react-native-android react-native-ios

5
推荐指数
3
解决办法
1万
查看次数

无法从 Web 视图中恢复控制以在 OAuth 流程中对本机应用程序做出反应

我正在尝试使用 FormidableLab 的react-native-app-auth库在我的 react native android 应用程序中实现 Google OAuth 2 登录,如下所示:

  googleLoginPressed = async () => {
    const config = {
      serviceConfiguration: {
        authorizationEndpoint: 'https://accounts.google.com/o/oauth2/v2/auth', tokenEndpoint: 'https://accounts.google.com/o/oauth2/v2/auth', 
      },
      clientId: app_params.GOOGLE_CLIENT_ID, redirectUrl: 'https://<my_domain>/oauth/google',
      scopes: ['openid', 'profile', 'email'], additionalParameters: { 'response-type': 'code' },
    };
    try {
      const result = await authorize(config);
    } catch (error) {
      console.log(error);
    }
  }
Run Code Online (Sandbox Code Playgroud)

这会使用 Google 的登录页面调用 Web 视图,我可以成功验证自己的身份。然后 Google 正确地重定向到我的 oauth 回调端点,并code像它应该的那样在重定向 url 中填充 oauth 。在这一点上,我希望react-native-app-auth将控制权从 webview 恢复到应用程序。相反,Web 视图在重定向 url 页面上保持打开状态。 …

oauth-2.0 react-native appauth react-native-android

5
推荐指数
1
解决办法
1089
查看次数

如何从错误中找到标签:在 React Native Android 中尝试使用标签 85273 更新不存在的视图

在 React Native 应用程序的生产中,从 firebase 的 crashlytics 获取 Android 上的错误:


    Fatal exception: com.facebook.react.uimanager.IllegalViewOperationException.
    Trying to update non-existent view with tag 85273.

Run Code Online (Sandbox Code Playgroud)

并且没有崩溃的情况,因此无法检测到它。我在模拟器和真正的 Android 设备上检查了很多次。

我们从这次事故中发现了什么?

  • 导致异常的 updateView 方法位于 node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java; 
  

    public void updateView(int tag, String className, ReadableMap props) {
        ViewManager viewManager = mViewManagers.get(className);
        if (viewManager == null) {
          throw new IllegalViewOperationException("Got unknown view type: " + className);
        }
        ReactShadowNode cssNode = mShadowNodeRegistry.getNode(tag);
        if (cssNode == null) {
          throw new IllegalViewOperationException("Trying to update non-existent view with tag " + tag);
        }
    
        if …
Run Code Online (Sandbox Code Playgroud)

debugging crash-reports crashlytics react-native react-native-android

5
推荐指数
0
解决办法
365
查看次数

试图注册两个同名的视图

我知道以前有人问过这种问题,但它们与第三方库有关,我的与 requireNativeComponent

我已经React Native从本地iOS组件创建了一个组件

这是我的iOS代码

CanvasView 文件

class CanvasView: UIView {
    
    var lines = [[CGPoint]]()
    
    override init(frame: CGRect) {
        super.init(frame:frame)
        backgroundColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 0)
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func draw(_ rect: CGRect) {
        super.draw(rect)
        
        guard let context = UIGraphicsGetCurrentContext() else {
            return
        }
        
        context.setStrokeColor(#colorLiteral(red: 0.9529411793, green: 0.6862745285, blue: 0.1333333403, alpha: 1))
        context.setLineWidth(10)
        context.setLineCap(.butt)
        
        lines.forEach { (line) in
            for(i,p) in line.enumerated() …
Run Code Online (Sandbox Code Playgroud)

react-native react-native-android react-native-ios react-native-native-module

5
推荐指数
1
解决办法
1156
查看次数

无法从 node_modules\uuidv4\build\lib\uuidv4.js 解析模块 util:在项目中找不到 util

我已经更新了 package.json 中的模块,现在出现错误“无法从 node_modules\uuidv4\build\lib\uuidv4.js 解析模块 util:在项目中找不到 util。”

在下面的步骤中,我已经完成了#2。我没有为 #1 使用 watchman,我在 #3 中使用的是 npm 而不是 yarn,我不知道 #4 指的是什么路径。这是我的完整输出。

PS C:\Dev\myProj> react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --资产目标 android/app/src/main/res/

(节点:16148)警告:访问循环依赖中模块导出的不存在的属性“padLevels”(node --trace-warnings ...用于显示警告的创建位置)欢迎使用 React Native!一次学习,随处书写

错误无法util从node_modules\uuidv4\build\lib\uuidv4.js以下位置解析模块:在项目中找不到 util。

如果您确定该模块存在,请尝试以下步骤:

  1. 清除守望者手表:watchman watch-del-all
  2. 删除 node_modules: rm -rf node_modules 并运行 yarn install
  3. 重置 Metro 的缓存:yarn start --reset-cache
  4. 删除缓存:rm -rf /tmp/metro-*。使用 --verbose 标志运行 CLI 以获取更多详细信息。错误:无法util从node_modules\uuidv4\build\lib\uuidv4.js以下位置解析模块:在项目中找不到 util。

如果您确定该模块存在,请尝试以下步骤:

  1. 清除守望者手表:watchman watch-del-all
  2. 删除 node_modules: rm -rf …

react-native react-native-android

5
推荐指数
1
解决办法
3554
查看次数

React Native(意图重定向修复):检查恶意重定向的 getCallingActivity() 相当于什么?

当更新版本提交到 Google Play 商店时,我们被要求对我们的 React Native 应用程序进行更改。突出显示的问题是“意图重定向”漏洞。这是遗留代码,但尽管如此,迟到总比不到好。

Google 帮助指南中建议的方法之一是:

选项 2:确保提取的 Intent 来自可信赖的来源。

您可以使用 >getCallingActivity 之类的方法来验证是否可以信任发起的 Activity。例如:

 // check if the originating Activity is from trusted package
 if (getCallingActivity().getPackageName().equals(“known”)) {
   Intent intent = getIntent();
   // extract the nested Intent
   Intent forward = (Intent) intent.getParcelableExtra(“key”);
   // redirect the nested Intent
   startActivity(forward);
 }
Run Code Online (Sandbox Code Playgroud)

根据本指南更改代码时,构建显示了getCallingActivity一个未知符号的错误。代码已经使用getCurrentActivity和getApplicationContext。

我们在 React Native 应用程序中纠正本机 Java 代码中的这个漏洞的最佳方法是什么?

将深深感谢您在这里的快速支持。谢谢!

android google-play react-native android-security react-native-android

5
推荐指数
1
解决办法
1221
查看次数

React Native (Android) - 找不到符号类 ReactInstanceManager

我刚刚升级到 React Native 0.63.3..... 我也升级了 Android studio4.1.1和 gradle 插件到4.1.0. 当我尝试构建时
出现错误cannot find symbol class ReactInstanceManager。

错误在文件中MainApplication.java......请参阅下面的代码。
出现错误是与行initializeFlipper(this,getReactNativeHost().getReactInstanceManager());。似乎是说我提供com.facebook.react.ReactInstanceManager....但是程序想要的是ReactInstanceManager.
它说Get the current ReactInstanceManager instance, or create one.

  @Override
  public void onCreate() {
    super.onCreate();
    SoLoader.init(this, /* native exopackage */ false);
    initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
  }

  /**
   * Loads Flipper in React Native templates. Call this in the onCreate method with something like
   * initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
   *
   * @param context …
Run Code Online (Sandbox Code Playgroud)

react-native react-native-android

5
推荐指数
1
解决办法
442
查看次数

如何解决这个问题 - 任务 :react-native-push-notification:compileDebugJavaWithJavac FAILED ,导入 com.google.firebase.iid 问题

在此处输入图片说明![\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotification.java:40: 错误:找不到符号

导入 com.google.firebase.iid.InstanceIdResult

react-native react-native-android firebase-cloud-messaging

5
推荐指数
4
解决办法
3821
查看次数

console.ignoredYellowBox如何知道要使用的前缀?

我有一个一般性问题和两个更具体的问题.

  1. 如何从黄色框警告消息中告诉我如何在React-Native中忽略它?
  2. 如何忽略此特定警告?

在此输入图像描述 3.我如何忽略这一具体警告?

在此输入图像描述

所有关于忽略特定警告的React-Native文档都说:

"通过使用console.disableYellowBox = true;可以在开发期间禁用YellowBoxes.通过设置应忽略的前缀数组,可以以编程方式忽略特定警告:console.ignoredYellowBox = ['Warning:...'] ;."

所以React-Native提供了这段代码,但我不知道如何指定警告的名称:

console.ignoredYellowBox = ['Warning: ReactNative.createElement'];
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-native react-native-android react-native-ios

4
推荐指数
1
解决办法
4050
查看次数

反应本机应用程序以接收来自youtube等应用程序的共享链接

我是React Native的新手。我正在开发一个应用程序,以接收共享URL的YouTube共享中的共享URL。像这样 我添加了代码来像这样在xml中注册接收活动

 <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
          <action android:name="android.intent.action.SEND" />
          <category android:name="android.intent.category.DEFAULT" />
          <data android:mimeType="text/plain" />
 </intent-filter>
Run Code Online (Sandbox Code Playgroud)

但是在我的App.js代码中,我如何接收数据并进行进一步处理。

android react-native react-native-android

4
推荐指数
1
解决办法
996
查看次数