首页 > 解决方案 > 由于“服务获取错误”,应用程序消息无法正常工作

问题描述

我们刚刚在应用程序消息传递中实现,在 Play 商店的现有应用程序中。但是,应用内消息不起作用,没有显示任何弹出窗口,因此,我们尝试使用更新的 JSON,仍然没有改进,并且提到的日志显示了错误“服务获取错误”。

请帮忙。

实现:


    implementation 'com.google.firebase:firebase-messaging:20.1.0'
    implementation 'com.google.firebase:firebase-config:21.0.0'
    implementation 'com.google.firebase:firebase-inappmessaging-display:20.1.0'
    implementation 'com.google.firebase:firebase-analytics:19.0.1'

日志:

2021-09-27 12:04:06.759 14919-14919/com.hubhopper I/FIAM.Headless: went foreground
2021-09-27 12:04:06.770 14919-14919/com.hubhopper I/FIAM.Display: Binding to activity: DashBoardActivity
2021-09-27 12:04:06.771 14919-14919/com.hubhopper I/FIAM.Headless: Setting display event component
2021-09-27 12:04:06.920 14919-14971/com.hubhopper I/FIAM.Headless: Forcing fetch from service rather than cache. Test Device: false | App Fresh Install: true
2021-09-27 12:04:06.931 14919-14971/com.hubhopper I/FIAM.Headless: Recoverable exception while reading cache: /data/user/0/com.hubhopper/files/fiam_impressions_store_file (No such file or directory)
2021-09-27 12:04:07.211 14919-14919/com.hubhopper I/FIAM.Headless: Starting InAppMessaging runtime with Installation ID dA_tOxrhRJGCYmjyGXjM9A
2021-09-27 12:04:07.471 14919-15020/com.hubhopper W/FIAM.Headless: Service fetch error: Firebase Installations Service is unavailable. Please try again later.
2021-09-27 12:07:54.178 14919-14919/com.hubhopper I/FIAM.Display: Unbinding from activity: DashBoardActivity
2021-09-27 12:07:54.178 14919-14919/com.hubhopper I/FIAM.Headless: Removing display event component
2021-09-27 12:07:57.064 14919-14919/com.hubhopper I/FIAM.Headless: went foreground
2021-09-27 12:07:57.066 14919-14919/com.hubhopper I/FIAM.Display: Binding to activity: DashBoardActivity
2021-09-27 12:07:57.066 14919-14919/com.hubhopper I/FIAM.Headless: Setting display event component
2021-09-27 12:07:57.071 14919-14971/com.hubhopper I/FIAM.Headless: Forcing fetch from service rather than cache. Test Device: false | App Fresh Install: true
2021-09-27 12:07:57.074 14919-14971/com.hubhopper I/FIAM.Headless: Recoverable exception while reading cache: /data/user/0/com.hubhopper/files/fiam_impressions_store_file (No such file or directory)
2021-09-27 12:07:57.252 14919-16103/com.hubhopper W/FIAM.Headless: Service fetch error: Firebase Installations Service is unavailable. Please try again later.

它也不适用于 firebase-BOM。

标签: androidfirebasefirebase-in-app-messaging

解决方案


这是指南,我们在 Google Cloud 凭据上的 api 密钥从一开始就不适用于 firebase 安装。

https://github.com/firebase/firebase-android-sdk/blob/master/firebase-installations/API_KEY_RESTRICTIONS.md

现在,在https://console.cloud.google.com/apis/api/firebaseinstallations.googleapis.com/metrics 指标中,我们得到了 200,并且在应用程序消息中也可以正常工作。

因此,如果您遇到“Firebase 安装服务不可用”错误,请通过在 google 云上创建新凭据来更新 google_services.json 文件,或者在您用于 android 的当前密钥中限制 firebase 安装。

谢谢你。


推荐阅读