标签: react-native-firebase

尝试在 React-Native Firebase 中使用电话身份验证时,iOS 模拟器中的应用程序崩溃

我已按照文档进行操作并进行了必要的设置,但应用程序在启动时崩溃了。我无法弄清楚为什么会发生这种情况。有人使用过 rnfirebase 吗?面临这个问题?

import React, { Component } from 'react';
import { View, Button, Text, TextInput, Image } from 'react-native';

import firebase from 'react-native-firebase';

const successImageUri = 'https://cdn.pixabay.com/photo/2015/06/09/16/12/icon-803718_1280.png';

export default class App extends Component {
  constructor(props) {
    super(props);
    this.unsubscribe = null;
    this.state = {
      user: null,
      message: '',
      codeInput: '',
      phoneNumber: '+44',
      confirmResult: null
    };
    firebase.initializeApp({
      apiKey: 'AIzaSyAvKPtsqqqGjkGLkXD8BeqOR6GwJaI2AcE',
      appId: '1:170852024080:ios:9bb19d2f74715186',
      messagingSenderId: '170852024080',
      projectId: 'chatapp-7c693',
      authDomain: 'chatapp-7c693.firebaseapp.com',
      databaseURL: 'https://chatapp-7c693.firebaseio.com',
      storageBucket: 'chatapp-7c693.appspot.com'
    });
  }

  componentDidMount() {
    this.unsubscribe = firebase.auth().onAuthStateChanged(user => {
      if …
Run Code Online (Sandbox Code Playgroud)

react-native react-native-firebase

2
推荐指数
1
解决办法
2280
查看次数

[React-Native-Firebase]如何移除 onMessage 存在事件?

我声明了一个 onMessage 函数来做某事。但是当我导航到另一个屏幕并想要删除 ComponentWillUnmount() 中的 FCM.onMessage() 时。我怎样才能删除它?

const rnfirebase = RNFirebase.initializeApp()

export const FCM = rnfirebase.messaging()

ComponentDidMount(){
    FCM.onMessage((notif)=>{

        //Do something

    })

}
ComponentWillUnmount(){
    //I want to remove here

}
Run Code Online (Sandbox Code Playgroud)

react-native react-native-firebase

2
推荐指数
1
解决办法
1535
查看次数

存储错误/未知将图片上传到 Firebase 存储

在开发新的 React-Native 项目并使用 React-Native-Firebase 库时遇到此错误。遵循所有教程设置步骤并收到此错误。在非反应本机项目中也可能会遇到此错误。

firebase firebase-storage react-native-firebase

2
推荐指数
1
解决办法
2394
查看次数

React Native Firebase Storage - 尝试使用 .putFile() 保存图像时出现错误

我正在尝试将本地图像从手机保存到 firebase 存储,但收到以下错误。

Permission Denial: reading com.google.android.apps.photos.contentprovider/........uid=XXXXX requires the provider be exported, or grantUriPermission()
Run Code Online (Sandbox Code Playgroud)

请参阅下面的代码。 await imageRef.putFile(localUri, {contentType: 'image/jpg'});是问题发生的地方

const uploadImageAndGetUrl = async (localUri, firebasePath) => {
  try {
    const imageRef = storage().ref(firebasePath);
    await imageRef.putFile(localUri, {contentType: 'image/jpg'});
    const url = await imageRef.getDownloadURL();
    return url;
  } catch (err) {
    Alert.alert('Profile.js.....Error getting image url from FB', err);
  }
};
Run Code Online (Sandbox Code Playgroud)

清单如下:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name = "android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 
Run Code Online (Sandbox Code Playgroud)

react-native firebase-storage react-native-firebase

2
推荐指数
1
解决办法
949
查看次数

添加react-native-firebase/admob时应用程序崩溃

如何添加react-native-firebase admob以反应原生(“0.60.x”)。添加 admob 时应用程序崩溃。是否有其他选项可以将 admob 添加到反应本机应用程序。React-native-admob 也有同样的崩溃问题。

crash admob react-native react-native-firebase

2
推荐指数
1
解决办法
799
查看次数

RNFIREBASE MESSENGER 无法在 iOS 上运行,但可以在 Android 上运行

推送通知适用于 Android,但不适用于 iOS。我已经在设备上进行了测试并通过测试飞行,因为不支持模拟器

我已经完成了 iOS 所需的额外设置。

以下是我的 package.json 文件中的相关信息

包.json

  "name": "####",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "@react-native-community/async-storage": "*",
    "@react-native-community/masked-view": "*",
    "@react-native-firebase/analytics": "*",
    "@react-native-firebase/app": "*",
    "@react-native-firebase/auth": "*",
    "@react-native-firebase/firestore": "*",
    "@react-native-firebase/messaging": "*",
    "prop-types": "*",
    "react": "16.13.1",
    "react-dom": "^17.0.2",
    "react-native": "0.63.4",
    "react-native-fbsdk": "*",
    "react-native-gesture-handler": "*",
    "react-native-reanimated": "^1.0.0-alpha",
    "react-native-render-html": "*",
    "react-native-safe-area-context": "*",
    "react-native-screens": "*",
    "react-navigation": "^4.4.4",
    "react-navigation-drawer": "^2.7.1",
    "react-navigation-stack": "^2.10.4",
    "react-navigation-tabs": "^2.11.1",
    "typescript": "^4.2.4"
  }, …
Run Code Online (Sandbox Code Playgroud)

ios react-native firebase-cloud-messaging react-native-firebase

2
推荐指数
1
解决办法
6939
查看次数

Firebase Firestore:在集合中创建集合

如何在集合中创建集合,如下所示:

    firestore().collection('users').doc(user.uid).collection("account").doc('doc-account').set({...});
Run Code Online (Sandbox Code Playgroud)

怎么做 ?

firebase typescript google-cloud-platform google-cloud-firestore react-native-firebase

2
推荐指数
1
解决办法
1051
查看次数

React本机firebase电话号码验证在发送短信之前打开safari.糟糕的UX

电话号码认证工作正常,但是当我打电话时

firebase.auth().signInWithPhoneNumber(phoneNumber)
Run Code Online (Sandbox Code Playgroud)

它打开safari浏览器并显示很少的重定向显示"验证你不是一个机器人",然后关闭自己.使用"react-native-firebase"时是否是正常行为?是否有任何选项可以隐藏这种奇怪的UX行为?

注意:在ios上测试它,还没试过Android.

PS

我之前在网上使用了firebase电话号码auth,它有ReCaptcha.在本机应用程序中使用它我会期望更多的静默行为.

谢谢.

ios firebase firebase-authentication react-native-firebase

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

firebase.notifications()在react-native-firebase中引发错误

我已成功将Firebase集成到我的移动应用程序中。目前,我正在android上对其进行测试。我已成功收到通知。我的下一步是在应用程序处于前台和后台时触发事件并读取数据。为此,我看了文档并使用了firebase.notifications().displayNotification()。但这会引发错误。

确保您具有:

1)在“ android / app / build.gradle”文件中安装了必需的Firebase Android SDK依赖项“ com.google.firebase:firebase-notifications”。

2)在您的“ MainApplication.java”文件中导入了“ io.invertase.firebase.notifications.RNFirebaseNotificationsPackage”模块。3)在RN'getPackages()'方法列表内添加了'new RNFirebaseNotificationsPackage()'行。

android firebase react-native-firebase

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

无法使用react-native-firebase在Android 8的前台接收通知

我无法仅在Android 8的Foreground中获得通知。也无法控制后台通知。 但是在低于8的Android版本上,可以在当前实现中正常工作。

遵循的步骤:-

  1. 将react-native-firebase插件版本5.0.0安装到应用程序中。
  2. 在Firebase控制台上创建了项目,并将google_service.json文件添加到android / app文件夹中。
  3. 在AndroidManifest中添加以下代码:-
     <service android:name="io.invertase.firebase.messaging.RNFirebaseMessagingService">
      <intent-filter>
          <action android:name="com.google.firebase.MESSAGING_EVENT" />
      </intent-filter>
    </service>
    <service android:name="io.invertase.firebase.messaging.RNFirebaseInstanceIdService>
      <intent-filter>
          <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
      </intent-filter>
    </service>
<service android:name="io.invertase.firebase.messaging.RNFirebaseBackgroundMessagingService"/>

   <receiver android:name="io.invertase.firebase.notifications.RNFirebaseNotificationReceiver"/>
   <receiver android:enabled="true" android:exported="true" android:name="io.invertase.firebase.notifications.RNFirebaseNotificationsRebootReceiver">
      <intent-filter>
          <action android:name="android.intent.action.BOOT_COMPLETED"/>
          <action android:name="android.intent.action.QUICKBOOT_POWERON"/>
          <action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
          <category android:name="android.intent.category.DEFAULT" />
      </intent-filter>
   </receiver>
   <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@mipmap/ic_launcher"/>
   <meta-data android:name="com.google.firebase.messaging.default_notification_channel_id" android:value="test_app"/>
Run Code Online (Sandbox Code Playgroud)
  1. 在App.js页面上添加了以下函数,并在componentDidMountMethod()中调用:
performNotificationOperations(){
  this.messageListener = firebase.messaging().onMessage((message: RemoteMessage) => {
    console.log("Message",message);
    alert("Notification Message Arrived");
    if(this.state.isLogin){
      const notification = new firebase.notifications.Notification()
                        .setNotificationId(message.messageId)
                        .setTitle(message.data.show_name)
                        .setBody(message.data.description)
                        .setData(message.data)
                        .android.setChannelId('test_app')
                        .android.setBigPicture(message.data.showImage)
                        .android.setPriority(firebase.notifications.Android.Priority.High);
      firebase.notifications().displayNotification(notification).catch(err => alert("Error On Message")); …
Run Code Online (Sandbox Code Playgroud)

android-notifications react-native android-8.0-oreo react-native-firebase

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