标签: react-native-firebase

无法在 DebugView 中查看设备和事件日志

我正在尝试在我的React Native 应用程序上使用firebase设置分析。

我尝试过来自不同论坛(例如StackOverflowGithub)的多种解决方案。
这是我在代码中添加的内容:

import analytics from '@react-native-firebase/analytics';

analytics().logEvent('TEST_EVENT');
Run Code Online (Sandbox Code Playgroud)
这是我尝试的解决方案:

  • 使IS_ANALYTICS_ENABLEDGoogleService-Info变为true不是false

  • 使用以下命令在调试视图中查看我的事件:

adb shell setprop debug.firebase.analytics.app .none.        //disable
adb shell setprop debug.firebase.analytics.app [app_name]    //enable
Run Code Online (Sandbox Code Playgroud)
  • 使用以下命令查看日志:
adb shell setprop log.tag.FA VERBOSE
adb shell setprop log.tag.FA-SVC VERBOSE
adb logcat -v time -s FA FA-SVC
Run Code Online (Sandbox Code Playgroud)
  • 这是我的日志:
09-08 18:21:23.401 V/FA      (26224): Connecting to remote service
09-08 18:21:23.456 D/FA      (26224): Connected to remote service
09-08 18:21:23.457 V/FA      (26224): Processing queued up …
Run Code Online (Sandbox Code Playgroud)

android firebase react-native firebase-analytics react-native-firebase

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

当应用程序打开时,React Native Firebase 推送通知不起作用

我正在使用@react-native-firebase来处理推送通知。问题是当应用程序在后台时它正在工作。如果应用程序处于前台或打开状态,则推送通知不起作用。另外,我正在使用notifee创建自定义通知。它也不起作用。

这是版本详细信息。

"@react-native-firebase/app": "^8.3.1",
"@react-native-firebase/messaging": "^7.7.2",
"@notifee/react-native": "^0.12.3",
Run Code Online (Sandbox Code Playgroud)

实施代码

componentDidMount() {
        console.log('componentDidMount App ');

        // AppState.addEventListener('change', this._handleAppStateChange);

        messaging()
            .getInitialNotification()
            .then(remoteMessage => {
                console.log('Notification caused app to open from quit state:');
                if (remoteMessage) {
                    console.log(remoteMessage.notification);
                }
            });

        const unsubscribe = messaging().onMessage(async remoteMessage => {
            console.log('A new FCM message arrived!');
            console.log(remoteMessage);
        });

        // Register background handler
        messaging().setBackgroundMessageHandler(async remoteMessage => {
            console.log('Message handled in the background!');
            console.log(remoteMessage);

        });

        messaging().onNotificationOpenedApp(remoteMessage => {
            console.log('Notification caused app to open from background state:'); …
Run Code Online (Sandbox Code Playgroud)

react-native react-native-firebase

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

尝试在 React Native 中使用 GoogleSignIn 时出现错误:DEVELOPER_ERROR

我已在 Firebase 上启用 Google SignIn,并且还添加了 SHA-1 密钥。我的应用程序编译得很好,但是当我按下登录按钮并选择 Google 帐户进行登录时,我得到了Possible Unhandled Promise Rejection (id: 0): Error: DEVELOPER_ERROR
当我尝试使用匿名登录时我没有收到任何错误。我使用的是 Android,并且所有模块都有最新版本。这是完整的错误代码:

[Fri Oct 23 2020 18:08:26.174]  WARN     Possible Unhandled Promise Rejection (id: 0):
Error: DEVELOPER_ERROR
promiseMethodWrapper@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:2242:45
signIn$@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:102709:72
tryCatch@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:24976:23
invoke@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:25149:32
tryCatch@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:24976:23
invoke@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:25049:30
http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:25059:21
tryCallOne@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:27056:16
http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:27157:27
_callTimer@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:30596:17
_callImmediatesPass@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:30635:17
callImmediates@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:30852:33
__callImmediates@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:2736:35
http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:2522:34
__guard@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:2719:15
flushedQueue@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:2521:21
flushedQueue@[native code]
callFunctionReturnFlushedQueue@[native code]

Run Code Online (Sandbox Code Playgroud)

这是我的App.js

import React, {useState, useEffect} from 'react';
import {View, Text, Button} from 'react-native';

import auth from '@react-native-firebase/auth';
import firebase from '@react-native-firebase/app';
import {GoogleSignin} from '@react-native-community/google-signin'; …
Run Code Online (Sandbox Code Playgroud)

firebase react-native google-signin react-native-firebase

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

在 React Native 中经过一定时间后删除通知 (@react-native-firebase/messaging)

我使用 @react-native-firebase/messaging 在 React Native 中工作推送通知。我在后端使用 FCM,它当前在 iOS 和 Android 上显示操作系统锁定屏幕通知。

我想在一段时间后或经过一段时间后清除给定的通知。有没有办法做到这一点?现在,当我发送通知时,如果我不点击它,它会保留几天。我想在一个小时后或下午 4 点或其他时间后记下通知。欢迎前端和/或后端解决方案。

我曾假设“ttl”(生存时间)参数执行此操作,但事实并非如此。

firebase react-native react-native-firebase

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

Notifee Android 通知图标不起作用

通知人通知图标在通知人显示通知中不起作用

notifee.displayNotification({
        title: remoteMessage.notification.title,
        body: remoteMessage.notification.body,
        android: {
          channelId: 'android_id',
        },
      });
Run Code Online (Sandbox Code Playgroud)

我已经使用了很多东西,例如小图标,大图标和其他方式,但通知图标没有显示,它只是显示默认图像。

我还检查了 AndroidManifest 元数据标签,它们也不起作用。

push-notification react-native-firebase

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

React Native firebase auth().useEmulator 未定义

我正在尝试在 android studio 模拟器(Pixel 4 API 29)上的 React Native(0.63.3)上使用新的 firebase 身份验证模拟器。在最新的重大更新react-native-firebase(V 10.0.0)中,添加了对此的支持,我可以在包中看到函数和类型定义node-modules。但是当我尝试使用该函数时,它根本没有在对象上定义。许多其他函数已定义并按预期工作(在生产数据上),但不是该useEmulator函数。我尝试了几种访问该对象的方法:

直接导入:

import app from "@react-native-firebase/app";
import auth from "@react-native-firebase/auth";
app.initializeApp(...);
console.log(auth().useEmulator);
Run Code Online (Sandbox Code Playgroud)

像这样导入模块:

import app from "@react-native-firebase/app"
import "@react-native-firebase/auth";
const auth = app.auth();
console.log(auth.useEmulator);
Run Code Online (Sandbox Code Playgroud)

他们都记录了undefined。如果我能得到一些关于如何让它发挥作用的提示,我将不胜感激。与在生产数据中创建测试用户相比,在开发时访问模拟器使一切变得更加容易。和工作良好并且已定义,因此看起来 auth 函数有一些特定的内容functions.useEmulatorfirestore.settings

我与这个问题相关的 npm 依赖项:

"react": "16.13.1",
"react-native": "0.63.3",
"@react-native-firebase/app": "^10.5.0",
"@react-native-firebase/auth": "^10.5.1",
"firebase": "^8.2.4",
Run Code Online (Sandbox Code Playgroud)

我的 android firebase auth 实现版本,如果有必要的话:

implementation "com.google.firebase:firebase-auth:20.0.2"
Run Code Online (Sandbox Code Playgroud)

javascript react-native firebase-authentication react-native-firebase

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

反应本机 firebase fcm setBackgroundMessageHandler 不工作

我正在创建一个函数,通过 FCM 的 setBackgroundMessageHandler 事件中的异步存储来存储数据。

我正在使用@react-native-firebase/messaging。SetBackgroundMessageHandler 不起作用。

我按照https://rnfirebase.io/messaging/usage/ios-setup上的教程操作,并从 firebase 网站发送了它。

除了当前的 setBackgroundMessageHandler 函数之外,一切正常。

我找了很久,却找不到答案。

我用真实设备进行了测试。推送消息正常显示,但没有发生setBackgroundMessageHandler事件。

Xcode 背景模式屏幕截图

包.json

"@react-native-firebase/app": "^11.2.0",
"@react-native-firebase/messaging": "^11.2.0",
"@react-native-firebase/ml": "^11.2.0",
Run Code Online (Sandbox Code Playgroud)

索引.js

import React from 'reactn';
import messaging from '@react-native-firebase/messaging';
import {AppRegistry} from 'react-native';
import App from './App';

messaging().setBackgroundMessageHandler(async remoteMessage => {
  // ...is not working
  console.log('Message handled in the background!', remoteMessage);
});

function HeadlessCheck({isHeadless}) {
  if (isHeadless) {
    return null;
  }

  return <App />;
}

AppRegistry.registerComponent('AppName', () => HeadlessCheck);
Run Code Online (Sandbox Code Playgroud)

应用程序.tsx

  React.useEffect(() => {
    var _resultList …
Run Code Online (Sandbox Code Playgroud)

javascript firebase-cloud-messaging react-native-firebase

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

@react-native-firebase/admob 的基本用法给出:“TypeError: (0, _admob.default) 不是一个函数”。它已被弃用吗?或为什么不起作用?

@react-native-firebase/admob 是否已弃用?或者只是......为什么它不起作用?

我正在使用@react-native-firebase/admob(https://rnfb-docs.netlify.app/admob/usage)。在使用“admob()”之前一切正常。当我将 admob() 添加到代码中时出现此错误:

“类型错误:(0,_admob.default)不是函数”

有人知道为什么吗?

我的代码如下(基本用法):

import React from 'react';
import { Text, View} from 'react-native';
import admob, { MaxAdContentRating } from '@react-native-firebase/admob';
import { InterstitialAd, RewardedAd, BannerAd, TestIds } from '@react-native- 
firebase/admob';
import { BannerAdSize} from '@react-native-firebase/admob';



class App extends React.Component{

componentDidMount(){

// this was taked of official page: https://rnfb-docs.netlify.app/admob/usage#installation
admob()
  .setRequestConfiguration({
    // Update all future requests suitable for parental guidance
    maxAdContentRating: MaxAdContentRating.PG,

    // Indicates that you want your content treated as child-directed for purposes …
Run Code Online (Sandbox Code Playgroud)

android admob google-play-services react-native react-native-firebase

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

Google 和 Apple 登录 Firebase 无法在 Expo 应用程序的 TestFlight 中运行

我正在开发一个需要通过 FireBase 使用 Apple 和 Google 登录的应用程序。在开发模式下,signIn 与两者都可以正常工作。但在 TestFlight 中部署后,我无法再使用它们登录。

还有 SignIn with Google 和 Apple 的代码:

Google:
import * as Google from "expo-google-app-auth";
try {
  const result = await Google.logInAsync({
    iosClientId:
      "##############.apps.googleusercontent.com",
    scopes: ["profile", "email"],
  });

  if (result.type === "success") {
    const { idToken, accessToken } = result;
    const credential = firebase.auth.GoogleAuthProvider.credential(
      idToken,
      accessToken
    );

    var user = firebase.auth().currentUser;
    user.linkWithCredential(credential).then(async () => {}
Run Code Online (Sandbox Code Playgroud)
Apple:
import * as AppleAuthentication from "expo-apple-authentication";
import * as Crypto from "expo-crypto";
    try {
      const …
Run Code Online (Sandbox Code Playgroud)

single-sign-on react-native expo react-native-firebase

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

React Native 构建失败 ios/Pods/Headers/Public/glog/glog/logging.h:509:1:注意:命名空间“google”从此处开始命名空间 google

我想让我的应用程序为推送通知做好准备。因此,我将 Expo Notifications 与 React-Native-Firebase 一起使用(它是一个裸工作流程应用程序)。Mi错误来自Podfile。对于 firebase 我需要添加use_frameworks!

但比我得到这个错误:

node_modules/react-native/React/Base/RCTBridge.m:17:9: fatal error: 'RCTDevLoadingViewProtocol.h' file not found
#import "RCTDevLoadingViewProtocol.h"
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Run Code Online (Sandbox Code Playgroud)

在 Github 上,我发现要修复此错误,我需要删除use_frameworks!. 但如果我删除它,我会收到以下错误:

ios/Pods/Headers/Public/glog/glog/logging.h:509:1: note: namespace 'google' begins here
namespace google {
^
1 error generated.
Run Code Online (Sandbox Code Playgroud)

有解决方案来解决这个问题吗?这是我的版本:

  • "@expo/react-native-action-sheet": "^3.13.0",
  • "@fortawesome/free-brands-svg-icons": "^6.1.1",
  • "@fortawesome/pro-light-svg-icons": "^6.1.1",
  • "@fortawesome/pro-regular-svg-icons": "^6.1.1",
  • "@fortawesome/pro-solid-svg-icons": "^6.1.1",
  • "@fortawesome/react-native-fontawesome": "^0.2.7",
  • "@invertase/react-native-apple-authentication": "^2.2.0",
  • "@openspacelabs/react-native-zoomable-view": "^2.0.4",
  • "@react-native-community/netinfo": "^8.3.0",
  • "@react-native-firebase/app": "^14.11.0",
  • "@react-native-google-signin/google-signin": "^7.2.2",
  • "@react-navigation/bottom-tabs": "^6.3.1",
  • "@react-navigation/stack": "^6.2.1",
  • "日期-fns": "^2.28.0",
  • "世博会": "~45.0.0",
  • "expo-image-picker": "^13.1.1",
  • "expo-localization": "^13.0.0",
  • "博览会地点": "^14.2.2",
  • "expo-notifications": …

react-native expo react-native-firebase expo-notifications

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