小编noo*_*gui的帖子

防止多个设备通过 Swift 使用同一个 Firebase 帐户

我正在使用 Swift 和 Firebase 构建一个 iOS 应用程序进行身份验证,需要避免来自不同设备的同一帐户的多个连接。我在这里阅读了一些其他帖子,但没有找到关于为什么这不起作用的明确答案。我首先尝试使用以下代码检查当前用户是否为零(由于异步调用,它始终显示为零)。

    if Auth.auth().currentUser == nil { 
    // ...
    }
Run Code Online (Sandbox Code Playgroud)

我还尝试在我的 viewDidLoad() 中使用 addStateDidChangeListener() 回调函数,虽然它在发生登录时触发,但它仍然不返回任何当前连接的会话或显示当前用户已登录时我使用不同设备上的相同凭据。

    Auth.auth().addStateDidChangeListener { (auth, user) in
    // ...
    }
Run Code Online (Sandbox Code Playgroud)

有没有更好的方法来检查我尝试登录 firebase 的帐户当前是否已登录(或未从上一个会话中退出)?

ios firebase swift firebase-authentication

6
推荐指数
0
解决办法
1832
查看次数

如何更改默认的firebase存储桶?

我有2个存储桶,一个来自谷歌云存储,一个是由firebase创建的,firebase创建的存储桶是默认存储桶,我想更改默认存储桶并删除firebase创建的存储桶.

google-cloud-storage firebase google-cloud-platform firebase-storage

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

处于瞌睡状态时,高优先级 FCM 通知无法唤醒 Chrome PWA

我现在正在 FCM 项目(在 Chrome [Android 8.0] 中运行的 PWA 客户端)中工作,一切看起来都很好,直到手机进入打盹状态并且推送通知无法唤醒我的 PWA。就我的应用而言,大延迟通知是不可接受的。

我正在根据此文档建立通知的优先级:https : //firebase.google.com/docs/cloud-messaging/concept-options#setting-the-priority-of-a-message

有没有办法绕过这种打瞌睡和 chrome 的行为或一些解决方法来告诉 chrome 监视高优先级通知?

android google-chrome google-cloud-messaging firebase-cloud-messaging

6
推荐指数
0
解决办法
534
查看次数

Firebase SDK signInWithPopup()无法使用Electron

我有一个电子应用程序启动轻量级express服务器,允许我http在生产中用于firebasegithub身份验证.

我使用signInWithRedirect()firebase auth方法可以正常工作.但是,我无法使用该signInWithPopup()方法.

electron启动一个新窗口,但内容为空.我的电子输入文件是否需要按照预期配置上述工作?

这在我在常规浏览器窗口中启动应用程序时工作正常,这导致我认为电子需要配置...

javascript firebase electron firebase-authentication

6
推荐指数
0
解决办法
410
查看次数

Vuejs & Firestore - 当 Firestore 中的数据发生变化时如何更新

我已经阅读了大量教程和文档,但是当 Firestore 中的数据发生变化时,似乎无法在页面上更新(注意:不是 Firebase)

这是我目前工作正常的内容,除非数据库中的数据发生变化,除非我刷新,否则它不会反映在页面本身上。下面的代码在脚本标签内:

 import { recipeRef } from '../../firebase';
 export default {
 data() {
  return {
    recipes: []
  }
},
firestore: {
  recipes: recipeRef
},
created() {
  db.collection('recipes').get().then((onSnapshot) => {
    this.loading = false
    onSnapshot.forEach((doc) => {
      let data = {
        'id': doc.id,
        'name': doc.data().name
      }
      this.recipes.push(data)
    })

  })
}
Run Code Online (Sandbox Code Playgroud)

我没有使用 Vuex。添加数据、编辑和阅读工作正常。只是不反映数据更改后的更改。也许我应该使用一个生命周期钩子?对于“ onSnapshot” - 我试过“ snap”,“ querySnapshot”等。没有运气。

提前致谢。

firebase vue.js google-cloud-firestore

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

如何删除应用程序处于后台时出现的单个 fcm 通知?

我正在开发一个应用程序,在那里我收到 FCM 通知,因为当应用程序打开时,onMessageRecieved()方法会触发,我根据标签和 ID 通知消息,并根据 ID 和标签删除通知。但是当应用程序在后台时onMesasageRecived()不会调用。当我从后台收到通知时,如何附加 id 和标签通知或如何根据某个 id 删除单个通知。

见 onMessageReceived

 @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
............
     notificationManager.notify("tag", notificationId, notification);
.......
}
Run Code Online (Sandbox Code Playgroud)

用于删除消息

  private void clearNotifications() {

        NotificationManager nMgr = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

        nMgr.cancel("tag",notificationId);
    }
Run Code Online (Sandbox Code Playgroud)

这是有效的,但是当应用程序关闭时,代码不起作用。我们可以从服务器端有效负载通知或附加标签和 ID

android push-notification firebase firebase-cloud-messaging

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

如何从Flutter中的UploadTaskSnapshot获取完整的downloadUrl?

我正确收到UploadTaskSnapshot,字段downloadUrl包含一个Uri解析上传文件下载链接的实例.

如何将存储和downloadUrl作为字符串?

firebase flutter firebase-storage

6
推荐指数
3
解决办法
4628
查看次数

如何使用FCM为富文本通知创建Payload

我正在我的一个应用程序中实现Rich Text Notification.我知道我需要以下列格式的有效载荷:

{
  "aps": {
      "alert": {
          "title": "", 
          "body": “”
      },
      "badge": 1,
      "sound": "default",
      "mutable-content": true,
      "content-available": true,
      "category": "defaultCategory"
  },
  "image_url": ""
}
Run Code Online (Sandbox Code Playgroud)

虽然当我尝试使用默认的APNS进程时,我成功完成了它,但是我在使用FCM实现它时遇到了一个问题,问题是我没有收到密钥:

mutable-content: 1
category: defaultCategory
Run Code Online (Sandbox Code Playgroud)

我探讨了它,并为iOS找到了一个url FCM丰富的推送通知负载 ,我也尝试了所提到的密钥.

"mutable_content": true,
"click_action": defaultCategory,
Run Code Online (Sandbox Code Playgroud)

但即使使用这些我也没有得到正确的结果.我在最终更改后收到的当前有效负载是:

{
    gcm.notification.category: defaultCategory, 
    image: /r/u/rustyredsmall.jpg, 
    type_id: XMH677878912-L-Blue, 
    type: Product, 
    aps: {
        alert =     {
           body = "new product notification message2018-05-24 00:00:00";
           title = "Product Notification";
        };
       badge = 1;
       sound = default;
    }, 
    0: {"mutable_content":true}, 
    gcm.message_id: 0:1527142412430945%98b85c5198b85c51
} …
Run Code Online (Sandbox Code Playgroud)

push-notification ios firebase swift firebase-cloud-messaging

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

打字稿接口符合 Firestore 查询

我如何使用 Firebase 和我自己的 Typescript 接口?

IE。我在这里有一个函数,我将需要完整的Payment对象(不仅仅是增量),所以我通过DocumentReference对象获得了它。

function doSomethingWithPayment(payment: Payment) {
   console.log(payment.amount); 
}


exports.resolveStripeCharge = functions.firestore.document('/payments/{paymentId}')
    .onWrite((change : Change <DocumentSnapshot>) => {

        change.after.ref.get().then((doc: DocumentSnapshot )=> {
            const payment : Payment =   doc.data(); // tslint warning here. 
            doSomethingWithPayment(payment); 

        })


[ts]
Type 'DocumentData' is not assignable to type 'Payment'.
  Property 'amount' is missing in type 'DocumentData'.
const payment: Payment
Run Code Online (Sandbox Code Playgroud)

我知道返回的对象不一定符合接口 - 但无论如何 - 我应该在这里做什么 - 如果我想强制输入?

我只是使用:

 const payment : Payment =   <Payment>doc.data();
Run Code Online (Sandbox Code Playgroud)

或者有更好的解决方案吗?

firebase typescript google-cloud-firestore

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

如何在Android和iOS上实现基于Firebase的对讲/一键通/对讲机功能?

我使用 Firebase 作为云数据库并为我的 Android 和 iOS 应用程序处理身份验证,它运行良好。最近也想在基于Firebase的APP中加入对讲/一键通/对讲机功能。我在互联网上搜索了一段时间,但仍然不确定从哪里开始:

(1) Android和iOS都可以实现基于Firebase的对讲/一键通/对讲机功能吗?如果是,是否有任何教程可以开始?

(2) 如果 Firebase 不是正确的方向,是否还有其他关于 Android 和 iOS APP 对讲功能的示例/教程?

android ios firebase firebase-realtime-database intercom

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