标签: react-native-firebase

react-native-firebase vs react-redux-firebase?

背景:我已开始使用带有react-native的react-native-firebase与Cloud Firestore集成。我将开始将redux引入我的测试应用程序。

问题-作为我在这里选择的库,react-native-firebase是否可以继续?(与迁移到react-redux-firebase相比)

当您将一个与另一个相对时,是否有一种简单的方法可以总结两个库之间的差异?我注意到使用react-native-firebase时,IOS和Android的安装相当复杂,因此我不确定react-redux-firebase是否使此操作更容易,但是如果混合使用,您是否会丢失任何东西?

react-native-firebase react-redux-firebase

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

错误:400:您的项目不拥有动态链接域

我正在使用 react-native-firebase 创建动态链接,当我创建标准链接时一切正常,但是当我创建短链接时,它给出了一个错误:“错误:400:你的项目没有动态链接域”。任何想法如何解决这个问题?

更新:问题仅发生在 Android 中,在 IOS 中工作正常

创建短动态链接的代码:

onClickShare= () => {
const link =
    new firebase.links.DynamicLink(redirectLink , Config.FIREBASE_CONFIG.dynamicLink)
      .android.setPackageName(Config.ANDROID_PACKAGE_NAME)
      .ios.setBundleId(Config.IOS_BUNDLE_ID)
      .ios.setAppStoreId(Config.IOS_APP_STORE_ID)
      .social.setDescriptionText(description)
      .social.setTitle(this.props.event.title)

      firebase.links()
      .createShortDynamicLink(link, 'SHORT')
      .then((url) => {
      Share.share({
        message: _('shareLinkMessage') + " " + url,
        title: _('shareLinkTitle'),
       }, {
        // Android only:
        dialogTitle:  _('shareLinkAndroid'),
        })
      }) 
Run Code Online (Sandbox Code Playgroud)

react-native react-native-firebase

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

react-native-firebase 通知中的深层链接

我使用带有消息传递功能的react-native-firebase通过云功能向我的应用程序传递通知,使用admin.messaging().send(message),与这里非常相似: https: //medium.com/the-modern-development -stack/react-native-push-notifications-with-firebase-cloud-functions-74b832d45386

当应用程序在后台时我会收到通知。现在,我正在通知正文中发送一条文本,例如“新位置已添加到地图中”。我希望能够添加某种深层链接,这样当我在通知上滑动视图(例如在 iOS 上)时,它会将我带到应用程序内的特定屏幕。如何将数据从通知传递到应用程序?

我在应用程序中使用react-native-navigation。我只能从应用程序内部找到有关深层链接的代码(https://wix.github.io/react-native-navigation/#/deep-links?id=deep-links)。

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

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

当应用程序在 Firebase 后台运行时,使推送通知显示为弹出窗口

我正在使用 Firebase Cloud Messaging 使用 React Native 应用程序向 Android 用户设置推送通知。到目前为止,我主要遵循了本教程。我设法使推送通知显示在锁定屏幕上,并在应用程序位于前台时处理它们。但是,当应用程序在后台运行时,我无法将通知显示为弹出窗口。它出现在通知托盘上,但不会像 Gmail 或 Whatsapp 的通知那样显示弹出窗口。

我相信我的问题是我没有随消息发送正确的参数。我使用的是 firebase 控制台,所以它不是很灵活。如何配置(以编程方式)通知以在接收时弹出?

编辑:

设置通知通道适用于较新的 Android 设备 - 在 Android 8.1(API 级别 27)上进行了测试。

在较旧的设备上 - 在 Android 6.0(API 级别 23)上进行测试 - 仍然不会出现抬头通知。我使用 aws sns 控制台发送以下消息:

{ 
  priority: 'high',
  content_available: true,
  notification: { 
     title: 'hello',
     body: 'Just test',
     android_channel_id: 'test-channel',
     sound: 'default' 
  },
  data: { title: 'title', body: 'body', sound: 'default' }
}

Run Code Online (Sandbox Code Playgroud)

我还使用 Firebase 控制台设置“优先级高”和“启用声音”发送消息,无论是否带有 Android 通道 ID。这些都不起作用。通知以静默方式到达托盘栏。此讨论显示了相同的问题,但一个人指出的解决方案对我不起作用。我没有太多地编辑react-native库代码。我尝试了 …

android push-notification firebase react-native react-native-firebase

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

如何使用 Firebase 刷新令牌保持用户身份验证?

我正在构建一个 React Native 应用程序,它使用 Firebase 电话身份验证进行用户登录。身份验证工作正常,但令牌在一小时后过期。我读过我需要使用刷新令牌来刷新idToken,但 Firebase文档中没有任何地方解释如何执行此操作。它只解释了如何撤销刷新令牌,我什至找不到它。

我正在使用react-native-firebase包。

我的问题是:如何获取刷新令牌,如何使用它,我是否真的需要每小时调用一次 Firebase 来更新我的idToken?

我目前得到我idToken这样的:

const authenticate = async (credential) => {
  try {
    const { user } = await firebase.auth().signInWithCredential(credential);
    const accessToken = await user.getIdToken();
    return accessToken;
  } catch (error) {
    console.log(error);
  }
}
Run Code Online (Sandbox Code Playgroud)

然后我使用令牌并将其存储在本地,AsyncStorage并在每次启动应用程序时检查令牌是否存在。

提前致谢。

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

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

@react-native-firebase/storage - 上传图像后获取 url

我试图找到一种有效的方法来在上传图像后立即在 firebase 中获取图像的 url。我想避免编写一个完全独立的函数......相反,我想将它包含在承诺链中。请参阅下面的代码

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

storage()
        .ref('path/to/remote/folder')
        .putFile('uri/of/local/image')
        .then(() => {
          //Id like to use getDownloadUrl() function here;
        })
Run Code Online (Sandbox Code Playgroud)

react-native firebase-storage react-native-firebase

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

Firebase messages.getToken() 失败并出现 MISSING_INSTANCEID_SERVICE 错误

我正在尝试将 Firebase Cloud Messaging 集成到正在进行的项目中。我按照此处的安装指南安装了 @react-native-firebase/app 和 @react-native-firebase/messaging。但是,当我尝试获取设备令牌时,await messaging.getToken()它失败并出现此警告 -NativeFirebaseError: [messaging/unknown] MISSING_INSTANCEID_SERVICE

请注意,如果我从 Firebase 控制台发送推送通知,它会在真实手机上发送,这表明问题可能不在于 FCM 设置。

任何有用的建议将不胜感激

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

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

undefined不是一个函数(评估'_iterator2 [typeof Symbol ==="function"

我正在使用react native实现firebase,这是我正在使用的版本

"firebase": "^5.4.1",
"react-native": "0.56.0",
"react": "16.4.1",
Run Code Online (Sandbox Code Playgroud)

但是当我导入firebase时,它显示以下错误:

undefined is not a function (evaluating '_iterator2[typeof Symbol === "function" ? Symbol.iterator : "@@iterator"]()')
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

注意:仅在Android设备上获取此错误,在iOS上它是完美的.

firebase react-native react-native-firebase

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

React-native-firebase:推送通知并不总是适用于 iOS

我在 react-native 中实现了一个通过 Firebase 发送推送通知的应用程序。大多数情况下,它运行良好,但有时,设备(主要是 iOS 13 设备)未收到推送通知。

对于正确接收我的推送通知的设备,每次(前台和后台)都会触发onNotification

对于未收到我的推送通知的设备,会触发onMessage(仅在前台)。

包.json

"react-native-firebase": "^5.6.0"
Run Code Online (Sandbox Code Playgroud)

播客文件

pod 'Firebase/Core', '~> 6.19.0'
pod 'Firebase/Functions', '~> 6.19.0'
pod 'Firebase/Messaging', '~> 6.19.0'
pod 'Firebase/Auth', '~> 6.19.0'
Run Code Online (Sandbox Code Playgroud)

为了测试我的推送通知,我通过 POSTMAN 发送它,使用 firebase API 和当前有效负载:

{
"to" : "my_FCM_token",
"priority" : "high",
"notification" : {
    "body" : "Body TEST",
    "title": "TEST Notification",
    "vibrate": 1,
    "sound": 1
},
"data" : {
    "key" : "value"
}
}
Run Code Online (Sandbox Code Playgroud)

请注意,它总是让我成功

AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // FIREBASE …
Run Code Online (Sandbox Code Playgroud)

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

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

错误:firebase.admob() InterstitialAd.show() 请求的 InterstitialAd 未加载且无法显示

我正在使用 react-native-firebase / admob 在 react native 中使用 Adbmod,当我尝试在第一次点击时使用插页式广告时,它会打开广告,但从那时起它返回此错误:

Error: firebase.admob () InterstitialAd.show () The requested InterstitialAd has not loaded and could not be shown.
Run Code Online (Sandbox Code Playgroud)

代码与文档相同,可在此处找到:

https://rnfirebase.io/admob/displaying-ads#banner-ads

javascript admob react-native react-native-firebase firebase-admob

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