小编Bob*_*der的帖子

Firebase功能:不清楚"连接错误"

我使用HTTP Firebase Cloud功能每次运行都会出现此错误:

Function execution took ****ms, finished with status: 'connection error'

它发生的不一致,但我不能完全解决问题所在.我不相信错误在我的应用程序中,因为它没有显示错误打印输出.在运行此云功能时,我自己与firebase的连接并没有消失.

任何想法为什么Firebase随着"连接错误"随机失败云功能执行?

firebase google-cloud-functions

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

升级到Google Play Services 9.0.0后,App会在DynamiteModulesC中挂起

通过以下更改将开发中的应用程序升级到9.0.0并重新生成google-services.json:

classpath 'com.google.gms:google-services:3.0.0'
compile 'com.google.android.gms:play-services:9.0.0'
Run Code Online (Sandbox Code Playgroud)

升级后,当应用程序初始化时,将显示预期的logcat消息序列.大约7秒后,再次输出相同的消息序列,并添加标题background_crash.例如:

17:39:30.162 5453-5453/com.xxx.nub:background_crash I/MultiDex: install done
Run Code Online (Sandbox Code Playgroud)

该应用程序正常运行,直到它变得隐藏,例如通过在另一个应用程序中启动活动.5秒后,系统检测到应用程序已挂起:

05-20 17:40:10.315 5138-5138/com.xxx.nub I/MainActivity: STOP MainActivity
05-20 17:40:10.375 5138-5138/com.xxx.nub I/NubApplication: onTrimMemory(): TRIM_MEMORY_UI_HIDDEN
05-20 17:40:10.375 5138-5138/com.xxx.nub D/FirebaseApp: Notifying background state change listeners.
05-20 17:45:10.465 5138-5143/com.xxx.nub I/dalvikvm: threadid=3: reacting to signal 3
05-20 17:45:10.565 5138-5143/com.xxx.nub I/dalvikvm: Wrote stack traces to '/data/anr/traces.txt'
Run Code Online (Sandbox Code Playgroud)

堆栈跟踪显示应用程序已挂起 com.google.android.gms.DynamiteModulesC

----- pid 5138 at 2016-05-20 17:45:10 -----
Cmd line: com.xxx.nub

JNI: CheckJNI is off; workarounds are off; pins=0; globals=295

DALVIK THREADS:
(mutexes: tll=0 …
Run Code Online (Sandbox Code Playgroud)

android google-play-services

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

Firebase:检查onWrite事件的"写入或删除"

我有以下函数来监听数据库触发器的onWrite事件,如下所示:

exports.sendNotifications = functions.database.ref('/events/{eventId}/registered')
        .onWrite(event => {

            ...
         });
Run Code Online (Sandbox Code Playgroud)

无论是删除还是添加节点,都会调用上述函数.如何检查onWrite事件是否为该特定节点的"删除"事件或"添加"事件,以便仅在"添加"事件时才调用此函数.

javascript firebase google-cloud-functions

10
推荐指数
4
解决办法
3422
查看次数

如何清除GoogleApiClient默认帐户和凭据

我连接GoogleApiClient以用于Google云端硬盘.我像这样构建客户端:

        GoogleApiClient.Builder(this)
                .addApi(Drive.API)
                .addScope(Drive.SCOPE_FILE)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .build();
Run Code Online (Sandbox Code Playgroud)

我的经验是,一次为此客户端发出连接请求时,会显示AccountPicker对话框并显示Google云端硬盘的同意屏幕.如果用户选择一个帐户,同意并且连接成功完成,则AccountManager或某些相关功能会将所选帐户保存为默认帐户,并将驱动器范围的凭据(OAuth令牌?)保存.在后续连接请求中,为了方便用户,使用保存的值,并且用户没有看到用于帐户选择或同意的UI.

对于开发测试,我希望能够清除默认帐户和保存的凭据,以便我可以执行连接失败解决处理.我还没有办法做到这一点.我尝试了这个没有成功:

String driveScope = "https://www.googleapis.com/auth/drive.file";
String tokenType = "oauth2:" + driveScope;

AccountManager.get(this).invalidateAuthToken(
    GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE, tokenType);
Run Code Online (Sandbox Code Playgroud)

android google-play-services google-drive-android-api

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

为什么两个FirebaseDatabase客户端脱机方法?

FirebaseDatabase提供了两种使客户端脱机的方法:

DatabaseReference.goOffline()

手动断开Firebase数据库客户端与服务器的连接并禁用自动重新连接.注意:调用此方法将影响所有Firebase数据库连接.

FirebaseDatabase.goOffline()

关闭我们与Firebase数据库后端的连接,直到调用goOnline().

调用FirebaseDatabase.getInstance().goOffline()产生预期结果:

  1. ValueEventListener 用于断开连接的".info/connected"触发
  2. OnDisconnect 行动执行
  3. ValueEventListener用于远程更改的s不会触发,用于本地更改的用途
  4. CompletionListener不要开火

打电话DatabaseReference.goOffline()似乎没有效果.上面列出的行为都不会发生.它坏了吗?如果没有,它与另一个有goOffline()什么不同?

android firebase firebase-realtime-database

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

Firebase 动态链接 onSuccess 或 onFailure 被调用

我正在使用下面的代码

        FirebaseDynamicLinks.getInstance()
                            .getDynamicLink(getIntent())
                            .addOnSuccessListener(this, new OnSuccessListener<PendingDynamicLinkData>() {
                                @Override
                                public void onSuccess(PendingDynamicLinkData pendingDynamicLinkData) {
...
     }
                            })
                            .addOnFailureListener(this, new OnFailureListener() {
                                @Override
                                public void onFailure(@NonNull Exception e) {

                                }
                            });
Run Code Online (Sandbox Code Playgroud)

我在一些设备上,当我不启动时抛出了一个深层链接,onSuccess 被调用,pendingDynamicLinkData == null,这很好,但在某些设备上,onSuccess 和 onFailure 根本没有被调用。如何解决这个问题?

android firebase firebase-dynamic-links

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

Firebase Cloud Messaging Android接收静默推送通知

我正在尝试从GCM迁移到Firebase云消息传递,我注意到当应用程序未运行时,通知将出现在通知托盘中.对于GCM,情况并非如此,开发人员需要显示通知.我希望与FCM有类似的行为,当应用程序运行时,我想静默处理推送消息,而不是让用户点击通知并启动应用程序.我怎样才能做到这一点.

谢谢,P

android firebase firebase-cloud-messaging

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

ParcelFileDescriptor 泄漏发生在哪里?

我已经按照数据备份指南实现了BackupAgent。代码的行为符合预期,直到设置为检测泄漏的可关闭对象。执行备份并发生 GC 后,CloseGuard 报告泄漏并显示以下堆栈跟踪:StrictMode.VmPolicyParcelFileDescriptor

\n\n
06-28 21:47:39.683  25072-25081/com.qbix.nub E/StrictMode\xef\xb9\x95 A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.\n    java.lang.Throwable: Explicit termination method \'close\' not called\n            at dalvik.system.CloseGuard.open(CloseGuard.java:184)\n            at android.os.ParcelFileDescriptor.<init>(ParcelFileDescriptor.java:179)\n            at android.os.ParcelFileDescriptor$1.createFromParcel(ParcelFileDescriptor.java:905)\n            at android.os.ParcelFileDescriptor$1.createFromParcel(ParcelFileDescriptor.java:897)\n            at android.app.IBackupAgent$Stub.onTransact(IBackupAgent.java:64)\n            at android.os.Binder.execTransact(Binder.java:404)\n            at dalvik.system.NativeStart.run(Native Method)\n06-28 21:47:39.683  25072-25081/com.qbix.nub W/System.err\xef\xb9\x95 StrictMode VmPolicy violation with POLICY_DEATH; shutting down.\n06-28 21:47:39.683  25072-25081/com.qbix.nub I/Process\xef\xb9\x95 Sending signal. PID: 25072 SIG: 9\n
Run Code Online (Sandbox Code Playgroud)\n\n

为了确认我没有泄漏ParcelFileDescriptor我的BackupAgent …

android android-backup-service android-strictmode

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

Firebase Analytics甚至会显示在日志中,但不会显示在firebase控制台上

我正在尝试将Firebase RemoteConfig和Google Analytics与我的Android应用程序集成.远程配置部分正在运行但分析部分无法正常工作.这是我的build.gradle

   // Firebase configuration
   compile group:'com.google.firebase', name:'firebase-core', version: '9.4.0'
   compile group:'com.google.firebase', name:'firebase-config', version: '9.4.0'

   // Firebase analytics
   compile 'com.google.android.gms:play-services-analytics:9.4.0'
Run Code Online (Sandbox Code Playgroud)

这是我的活动代码.

 FirebaseAnalytics firebaseAnalytics = FirebaseAnalytics.getInstance(this);
      firebaseAnalytics.setUserId("5107611364");
      firebaseAnalytics.setUserProperty("custom_user_property", "custom_user_proerty_value");

      Bundle bundle = new Bundle();
      bundle.putString(FirebaseAnalytics.Param.ITEM_ID, "SomeID");
      bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, "SomeIDName");
      bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "IdType");
      firebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle);
Run Code Online (Sandbox Code Playgroud)

我正在尝试发布客户资产以及事件,但他们都没有工作.我启用了adb日志记录,我可以看到自定义事件和属性已发布.即使在24小时后,这些也不会出现在Firebase Analytics控制台上.我不知道出了什么问题.

android firebase firebase-analytics

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

在 firebase auth 上,用户登录时是否有云触发器?

我们希望在用户每次登录时发送电子邮件、短信或推送通知。

有没有办法通过 firebase auth 来做到这一点?

firebase-cloud-function 的触发器是理想的选择,但似乎并不存在。

谢谢!

firebase firebase-authentication google-cloud-functions

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

Firestore 事务被多次触发导致数据错误

所以我有一个云功能,每次交易被喜欢/不喜欢时都会触发。此函数增加/减少likesCount。我已经使用 firestore 事务来实现相同的目的。我认为问题是事务块内的代码被多次执行,根据文档,这可能是正确的。

但我的点赞数在某些时候更新不正确。

 return firestore.runTransaction(function (transaction) {
        return transaction.get(transRef).then(function (transDoc) {
            let currentLikesCount = transDoc.get("likesCount");
            if (event.data && !event.data.previous) {
                newLikesCount = currentLikesCount == 0 || isNaN(currentLikesCount) ? 1 : transDoc.get("likesCount") + 1;
            } else {
                newLikesCount = currentLikesCount == 0 || isNaN(currentLikesCount) ? 0 : transDoc.get("likesCount") - 1;
            }
            transaction.update(transRef, { likesCount: newLikesCount });
        });
    });
Run Code Online (Sandbox Code Playgroud)

任何人都有类似的经历

transactions firebase google-cloud-functions google-cloud-firestore

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

Exists() 不适用于第二个变量 Cloud Firestore 规则

在我的项目中,我想通过检查用户的 uid 是否是该文档的子集合(包含该文档的所有成员)的一部分来控制对文档的访问。当我想用exists() 方法检查这个时,它在它应该授予的时候没有授予权限。

 match /events/{season}/events/{code} {
    function isVV (season, code) {
      return exists(/databases/$(database)/documents/events/$(season)/events/$(code)/vv/$(request.auth.uid));
    }

    allow read: if isVV(season, code);
Run Code Online (Sandbox Code Playgroud)

当我用我当前正在测试的值替换 $(code) 时,规则通过,一切都按预期工作。当我使用变量时,它不会。

任何可以帮助我的 Cloud Firestore 规则专家?也许有更好的方法来做到这一点?

firebase firebase-security google-cloud-firestore

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