这是我的清单
<service android:name=".fcm.PshycoFirebaseMessagingServices">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service android:name=".fcm.PshycoFirebaseInstanceIDService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
Run Code Online (Sandbox Code Playgroud)
当应用程序处于后台并且通知到达时,默认通知将会运行并且不会运行我的代码onMessageReceived.
这是我的onMessageReceived代码.如果我的应用程序在前台运行,而不是在后台应用程序时,则调用此方法.如何在应用程序处于后台时运行此代码?
// [START receive_message]
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
// TODO(developer): Handle FCM messages here.
// If the application is in the foreground handle both data and notification messages here.
// Also if you intend on generating your own notifications as a result of a received FCM
// message, here is where that should be initiated. See …Run Code Online (Sandbox Code Playgroud) 在火力web应用指南规定我应该把给定的apiKey在我的HTML初始化火力点:
// TODO: Replace with your project's customized code snippet
<script src="https://www.gstatic.com/firebasejs/3.0.2/firebase.js"></script>
<script>
// Initialize Firebase
var config = {
apiKey: '<your-api-key>',
authDomain: '<your-auth-domain>',
databaseURL: '<your-database-url>',
storageBucket: '<your-storage-bucket>'
};
firebase.initializeApp(config);
</script>
Run Code Online (Sandbox Code Playgroud)
通过这样做,apiKey暴露给每个访客.这把钥匙的目的是什么,它真的是公开的吗?
使用带有gradle插件版本的Android Studio 3.3 Canary 11 3.3.0-alpha11.尝试同步gradle时,它会引发以下错误
WARNING: API 'variant.getExternalNativeBuildTasks()' is obsolete and has been
replaced with 'variant.getExternalNativeBuildProviders()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-
avoidance
Affected Modules: app
Run Code Online (Sandbox Code Playgroud)
单击错误会将我引导至gradle文件中的此行
applicationVariants.all { variant ->
variant.outputs.all {
outputFileName = "${variant.name}-${variant.versionName}.apk"
}
}
Run Code Online (Sandbox Code Playgroud)
我到底需要改变什么?
项目 build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral() // jcenter() works as well because it pulls from …Run Code Online (Sandbox Code Playgroud) android firebase android-studio android-gradle-plugin fabric.io
我正在构建一个 Flutter 应用程序并且我已经集成了 Firebase,但是当我点击一个按钮来注册、登录或注销时,我不断收到这个错误。我见过其他人问过同样的问题,但似乎没有一个对我有用。我正在使用 Flutter 和Android Studio。我该如何解决这个问题?
这是我的代码的摘录
class HomeScreen extends StatefulWidget {
@override
_HomeScreenState createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.red,
body: Center(
child: Container(
child: RaisedButton(
onPressed: () {
FirebaseAuth.instance.signOut().then((value) {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) =>
LoginScreen()));
});
},
child: Text("Logout"),
)
)
)
);
}
}
Run Code Online (Sandbox Code Playgroud)
下面是抛出的异常
class HomeScreen extends StatefulWidget {
@override
_HomeScreenState createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> { …Run Code Online (Sandbox Code Playgroud) 将firebase项目从旧域升级到新的google firebase域时出现以下错误.
无法解决:com.google.firebase:firebase-core:9.0.0
我按照Firebase文档中提到的步骤,在" 将Firebase添加到Android项目"一节中,主题可用库.
我有什么选择来解决这个错误?
{
"movies": {
"movie1": {
"genre": "comedy",
"name": "As good as it gets",
"lead": "Jack Nicholson"
},
"movie2": {
"genre": "Horror",
"name": "The Shining",
"lead": "Jack Nicholson"
},
"movie3": {
"genre": "comedy",
"name": "The Mask",
"lead": "Jim Carrey"
}
}
}
Run Code Online (Sandbox Code Playgroud)
我是Firebase的新手.我如何可以检索从上面的数据结果,其中genre = 'comedy'与lead = 'Jack Nicholson'?
我有什么选择?
我正在使用Firebase,并在应用程序处于后台时测试从我的服务器向我的应用发送通知.通知成功发送,甚至出现在设备的通知中心,但是当通知出现或甚至我点击它时,我的FCMessagingService内的onMessageReceived方法永远不会被调用.
当我在我的应用程序位于前台时对此进行测试时,调用了onMessageReceived方法,一切正常.当应用程序在后台运行时会出现此问题.
这是预期的行为,还是有办法解决这个问题?
这是我的FBMessagingService:
import android.util.Log;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
public class FBMessagingService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Log.i("PVL", "MESSAGE RECEIVED!!");
if (remoteMessage.getNotification().getBody() != null) {
Log.i("PVL", "RECEIVED MESSAGE: " + remoteMessage.getNotification().getBody());
} else {
Log.i("PVL", "RECEIVED MESSAGE: " + remoteMessage.getData().get("message"));
}
}
}
Run Code Online (Sandbox Code Playgroud) 谷歌刚刚发布了Cloud Firestore,这是他们针对应用的新文档数据库.
我一直在阅读文档但我没有看到Firestore和Firebase DB之间存在很多差异.
重点是Firestore使用的文档和集合与Firebase相比,可以轻松使用查询,Firebase是一个带有JSON基础的传统noSQL数据库.
我想更多地了解他们的差异或用法,或者Firestore是否刚刚取代Firebase DB?
firebase google-cloud-platform firebase-realtime-database google-cloud-firestore
我开始使用新的Google服务进行通知Firebase Cloud Messaging.
感谢此代码https://github.com/firebase/quickstart-android/tree/master/messaging我能够将Firebase用户控制台的通知发送到我的Android设备.
是否有任何API或方式可以在不使用Firebase控制台的情况下发送通知?我的意思是,例如,PHP API或类似的东西,直接从我自己的服务器创建通知.