标签: react-native-firebase

在 React Native android 中从图库中选择图像后,应用程序重新启动

我正在使用 react-native-image-picker 模块。从图库中挑选照片。然后重新启动(有时)应用程序而不显示任何错误,从相机拍摄照片工作正常。我尝试在 firebase 数据库中上传图像。

javascript firebase react-native firebase-realtime-database react-native-firebase

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

您试图通过调用 firebase.storage() 来使用未安装在您的 android 项目上的 firebase 模块

我尝试使用 react-native-firebase 模块在 React Native 上使用 firebase 存储,当你调用 firebase 存储时,我收到此错误:

您试图通过调用firebase.storage () 2IM.png使用未安装在您的 android 项目上的firebase 模块

我已经添加了所有必要的依赖项。

android/app/build.gradle

apply plugin: "com.android.application"
import com.android.build.OutputFile

project.ext.react = [
    entryFile: "index.js"
]

apply from: "../../node_modules/react-native/react.gradle"
def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"

    defaultConfig {
        applicationId "com.detecta.detecta"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 5
        versionName "1.1.6"
        vectorDrawables.useSupportLibrary = true
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    signingConfigs {
        release {
            if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
                storeFile file(MYAPP_RELEASE_STORE_FILE) …
Run Code Online (Sandbox Code Playgroud)

react-native-android react-native-firebase

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

为什么在 React Native 中收到来自 firebase 的推送通知时应用程序崩溃?

我正在使用 react-native-firebase 进行远程推送通知。当应用程序打开或在后台时,我能够收到通知。但是,当我终止应用程序并将其从内存中删除时,一旦我从 Firestore 应用程序发送消息,手机就会崩溃。我遵循了完整的文档并按照文档进行了操作。应用程序崩溃的原因是什么,我该如何解决?

我的 App.js

import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View} from 'react-native';
import firebase from 'react-native-firebase';
import type { Notification, NotificationOpen } from 'react-native-firebase';
const instructions = Platform.select({
  ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu',
  android:
    'Double tap R on your keyboard to reload,\n' +
    'Shake or press menu button for dev menu',
});
export default class App extends Component {
    async componentDidMount() {
        const notificationOpen: NotificationOpen = …
Run Code Online (Sandbox Code Playgroud)

push-notification react-native react-native-firebase

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

使用 Firebase Crashlytics 反应本机错误日志记录 - 如何获取 javascript 堆栈跟踪

我有一个使用 react native firebase lib配置的 React Native 应用程序,并添加了Crashlytics模块。一切正常,但是当我尝试使用recordError()方法crash()记录错误时,或者当我仅使用它时,只会以本机形式在仪表板中记录错误。我试图找到一种将 js 错误发送到仪表板的方法,但到目前为止没有任何效果。


这是可能的还是我应该尝试不同的方式?也许是另一个平台,如 bugsnag 或 sentry?

firebase crashlytics react-native react-native-firebase

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

React Native Firebase,当应用程序处于前台时不显示通知,仅在 Android 8 或更高版本上使用 bundle build

我有一个带有 react-native-firebase 通知的应用程序,消息已成功接收,通知已成功创建并显示在 Android Nougat 或更旧版本、Android Oreo 或更高版本上我添加了 channelId 它在使用 react-native run 时运行良好- android,但是当使用 bundle (cd android && ./gradlew installRelease) 时,我的通知不仅仅在 Android Oreo 或更高版本的前台显示,在后台工作。不知道问题出在消息侦听器上还是在创建通知时。这是我的代码...

我在获得权限后调用下面的函数,当应用程序在前台时收听消息

export const listening_message = () => {
return firebase.notifications().onNotification((notification) => {
    display_notification({
        notification_param: {
            sound: 'default',
            show_in_foreground: true,
        },
        title: notification.title,
        subtitle: notification.subtitle,
        body: notification.body,
        data: notification.data,
    });
});
}
Run Code Online (Sandbox Code Playgroud)

那么这是显示通知的代码

async function display_notification(parameter) {
let realmUser = await Realm.open(RealmData.User);

if(realmUser.objects(RealmDataName.User).length > 0) {
    let realmNotification = await Realm.open(RealmData.NotificationID);

    if(realmNotification.objects(RealmDataName.NotificationID).length == 0) {
        realmNotification.write(() => …
Run Code Online (Sandbox Code Playgroud)

javascript android-notifications firebase react-native react-native-firebase

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

使用 Async Storage 存储大量数据是否可以?[反应原生]

我正在开发一个 react native 应用程序,我的 firebase 数据库存储了大约 10000 个项目的库存。所以我需要在本地存储这些数据,我正在考虑使用异步存储将每个项目保存到他自己的密钥中。没关系还是有更有效的方法?

javascript react-native firebase-realtime-database asyncstorage react-native-firebase

5
推荐指数
2
解决办法
5228
查看次数

通知 - 清除 android 通知托盘中的所有通知

我正在向我的应用程序发送多个通知。我想要实现的是每当用户单击一个通知时,通知托盘中的所有通知都会消失。

我试过添加

notification.android.setAutoCancel(true)
Run Code Online (Sandbox Code Playgroud)

它只对一个通知(被点击的那个)起作用

我也试过:

firebase.notifications().removeAllDeliveredNotifications() 
Run Code Online (Sandbox Code Playgroud)

这没有任何影响。

我怎样才能做到这一点?

这是我的完整代码:

      componentDidMount() {
    firebase.notifications().removeAllDeliveredNotifications()

    this.notificationDisplayedListener = firebase.notifications().onNotificationDisplayed((notification) => {
    });

    this.notificationListener = firebase.notifications().onNotification(async (notification) => {
      // Process your notification as required
      notification.android.setAutoCancel(true)
      firebase.notifications().removeAllDeliveredNotifications()
  }



    async componentWillMount() {
    this.notificationDisplayedListener = firebase.notifications().onNotificationDisplayed((notification) => {
    });
    this.notificationListener = firebase.notifications().onNotification((notification) => {
    });

    this.notificationDisplayedListener();
    this.notificationListener();
    }
Run Code Online (Sandbox Code Playgroud)

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

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

如何使用 Firebase Firestore 在客户端上缓存 getDownloadUrl() 调用?

我在后端数据库中存储了一些图像/视频的 Firebase 存储路径,移动客户端使用这些路径在我的视图需要时获取下载 URL:

import {firebase} from '@react-native-firebase/storage';

// e.g. 'images/stars.jpg'
const getDownloadUrlForFilePath = (filePath: string | null): Promise<string> => {
  if (filePath === null) {
    throw 'Path is null!';
  }
  return getDownloadUrlForRef(firebase.storage().ref(filePath));
};

const getDownloadUrlForRef = (ref): Promise<string> => {
  return ref.getDownloadURL();
};
Run Code Online (Sandbox Code Playgroud)

问题是我在很多地方都需要相同的图像。因此,我经常打电话getDownloadURL()来检索相同的下载网址。这会导致手机对我调试网络流量时出现的同一资源发出多个 http 请求。

在我当前的实现中,我没有将检索到的下载 URL 存储在移动客户端中的任何位置。

我想找到一种方法让应用程序只为同一路径获取一次下载 URL 并缓存它。Firebase SDK 是否支持此功能?

google-cloud-storage typescript react-native firebase-storage react-native-firebase

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

如何从 React Native Firebase Analytics 的屏幕跟踪中删除 MainActivity 和 UIViewController?

我已经成功地为一个使用 react-navigation 和 react-native-firebase/analytics 的 react native 项目实现了屏幕跟踪。

查看事件下的仪表板,我看到以下事件(下图)。如您所见,前 2 个事件会被自动跟踪 1. MainActivity、2. UIViewController 并且它们占据了总数的大部分。我想从跟踪中删除这些屏幕,只显示应用程序 JS 端的屏幕(反应导航)。

这可能吗?我怎样才能做到这一点?

先感谢您 ?????

屏幕追踪截图

analytics firebase react-native react-navigation react-native-firebase

5
推荐指数
2
解决办法
774
查看次数

@react-native-firebase/messaging : TypeError: (0 , _messaging.default)(...).registerForRemoteNotifications 不是函数

我正在使用 @react-native-firebase/app": "^8.2.0", @react-native-firebase/messaging 和 react-native v0.61.0。也使用 @react-native-community/push-notification-ios ": "^1.4.0" 和 "react-native-push-notification": "^4.0.0"

我最近将我的 react-native 版本从 0.63.0 降级到 0.61.0。在android中一切正常,但在ios模拟器&&真实设备中messaging().registerForRemoteNotifications()抛出错误。

TypeError: (0 , _messaging.default)(...).registerForRemoteNotifications 不是函数 TypeError: (0 , _messaging.default)(...).registerForRemoteNotifications 不是 App.componentDidMount 的函数

在此处输入图片说明

反应本机信息

系统:操作系统:macOS 10.15.5 CPU:(4) x64 Intel(R) Core(TM) i5-3470S CPU @ 2.90GHz 内存:45.55 MB / 16.00 GB 外壳:3.2.57 - /bin/bash 二进制文件:节点: 12.15.0 - /usr/local/bin/node npm: 6.13.4 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: 平台: iOS 13.5, DriverKit 19.0、macOS 10.15、tvOS 13.4、watchOS 6.2 IDE:Xcode:11.5/11E608c - /usr/bin/xcodebuild npmPackages:react:16.9.0 => …

push-notification ios react-native react-native-firebase

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