我正在尝试使用Node.js了解如何在Firebase存储中上传文件.我的第一次尝试是使用Firebase库:
"use strict";
var firebase = require('firebase');
var config = {
apiKey: "AIz...kBY",
authDomain: "em....firebaseapp.com",
databaseURL: "https://em....firebaseio.com",
storageBucket: "em....appspot.com",
messagingSenderId: "95...6"
};
firebase.initializeApp(config);
// Error: firebase.storage is undefined, so not a function
var storageRef = firebase.storage().ref();
var uploadTask = storageRef.child('images/octofez.png').put(file);
// Register three observers:
// 1. 'state_changed' observer, called any time the state changes
// 2. Error observer, called on failure
// 3. Completion observer, called on successful completion
uploadTask.on('state_changed', function(snapshot){
...
}, function(error) {
console.error("Something nasty happened", error);
}, …Run Code Online (Sandbox Code Playgroud) //身体就像这样
{
"to":
"/topics/NEWS"
,
"data":{
"extra_information": "This is some extra information"
},
Run Code Online (Sandbox Code Playgroud)
//我需要提供的通知
"notification":{
"title": "ChitChat Group",
"text": "You may have new messages",
"click_action":"ChatActivity"
}
}
Run Code Online (Sandbox Code Playgroud) 我想知道是否有一个全面的列表,提供各种Firebase FCM使用限制的详细信息.
我知道数据消息有效负载限制最大为4KB.然后最近我的应用程序遇到了一些问题,然后认为这是由于另一个限制 - "每个设备最多4个不同的折叠键".
我还记得谷歌在最近的一次谈话中提到他们已经删除了他们以前喜欢的主题数量等限制.
我正在尝试详细了解Google对FCM使用的各种限制.
我在我的日志猫中收到此错误
Error:Failed to resolve: com.twitter.sdk.android:twitter:2.3.0
Run Code Online (Sandbox Code Playgroud)
当我尝试添加此依赖项时:
compile 'com.firebaseui:firebase-ui:1.1.1'
Run Code Online (Sandbox Code Playgroud)
有人可以帮助我,我不知道我做错了什么.这是我从中获取依赖关系的链接:https://github.com/firebase/FirebaseUI-Android.在旁注中,我没有在我的应用程序中使用Twitter登录或与Twitter进行任何类型的交互,因此我不确定为什么在放置该依赖项后同步我的gradle时出现该错误.
我正在Android中实施FCM通知,但通知如何根据应用状态(背景与前景)而有所不同?

我使用带有Postman的FCM API发送通知,这是通知结构:
{ "notification": {
"title": "Notification title",
"body": "Notification message",
"sound": "default",
"color": "#53c4bc",
"click_action": "MY_BOOK",
"icon": "ic_launcher"
},
"data": {
"main_picture": "URL_OF_THE_IMAGE"
},
"to" : "USER_FCM_TOKEN"
}
Run Code Online (Sandbox Code Playgroud)
要渲染的图像取自data.main_picture.
我实现了自己的功能FirebaseMessagingService,使通知在前景状态下完美显示.通知代码是下一个:
NotificationCompat.BigPictureStyle notiStyle = new NotificationCompat.BigPictureStyle();
notiStyle.setSummaryText(messageBody);
notiStyle.bigPicture(picture);
Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = (NotificationCompat.Builder) new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setLargeIcon(bigIcon)
.setContentTitle(title)
.setContentText(messageBody)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent)
.setStyle(notiStyle); code here
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, notificationBuilder.build());
Run Code Online (Sandbox Code Playgroud)
但是,在后台,甚至没有执行该服务.在AndroidManifest.xml,Firebase服务声明如下:
<service
android:name=".MyFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<service …Run Code Online (Sandbox Code Playgroud) android background push-notification firebase-cloud-messaging
我正在尝试创建一个Heroku节点任务,从Firebase和console.log中读取数据.
我的节点脚本(位于/ bin目录中)是:
require('dotenv').config({ silent: true });
var firebase = require('firebase');
firebase.initializeApp({
serviceAccount: {
projectId: process.env.fb_projectId,
clientEmail: process.env.fb_clientEmail,
privateKey: process.env.fb_privateKey
},
databaseURL: process.env.fb_databaseURL
})
console.log(process.env.fb_privateKey);
firebase.database().ref('tasks').once('value', function(snapshot) {
console.log(snapshot.val());
process.exit();
})
Run Code Online (Sandbox Code Playgroud)
除了之外fb_privateKey,所有env变量都是正确的,因为它包含\n字符.
我的本地.env文件和Heroku环境变量都包含一个名为key的键fb_privateKey,一个值作为带有\n字符的字符串- 用".包围.
fb_privateKey="-----BEGIN PRIVATE KEY-----\nMY-PRIVATE-KEY\n-----END PRIVATE KEY-----\n"
Run Code Online (Sandbox Code Playgroud)
当我在本地运行脚本时,它会使用新行+从Firebase返回的任务向我记录私钥.但是,当我在Heroku上运行它时,(heroku run myScript)会记录带有\n字符的私钥(作为单行),并且无法从Firebase读取数据(可能是由于一个错误的私钥).有任何想法吗?
我想使用Firebase(身份验证,数据库和存储)构建Node.js Web应用程序.但我对应该使用哪个模块,firebase或firebase-admin(或两者)感到困惑.
node.js npm firebase firebase-realtime-database firebase-admin
我想在模拟器中测试我的应用程序的可访问性(特别是Talkback),但似乎模拟器中缺少该选项.以下是可访问性设置中模拟器的屏幕截图:
有两个选项"ClockBack"和"QueryBack"我不能我的手机上使用相同的Android版本发现.以下是我手机辅助功能设置的屏幕截图:
我搜索了解"ClockBack"并"QueryBack"了解它们是否是Talkback模拟器的替代品,但我找不到任何东西.
有谁知道"ClockBack"和的功能是"QueryBack"什么?还有更多关于如何Talkback在模拟器中启用?
我为我的Android应用程序创建了一个用于GCM推送通知的Android API密钥.从过去两天开始,GCM服务器在PHP中返回Unauthorized(401)响应.
Android API密钥是否有任何原因无效/过期?或者GCM是否弃用了Android API密钥?
我还没有得到关于为什么Android API密钥无效的正确解释?他们中的大多数人更喜欢使用服务器密钥而不是GCM的Android API密钥,但没有提到为什么不使用Android API密钥.
为什么不在GCM中使用Android API Key?Android API密钥有任何限制吗?或者,如果通知消息超过每日限制,GCM服务器是否阻止通知/ GCM服务器使Android API密钥无效?
android firebase google-cloud-messaging firebase-cloud-messaging
我可以在一个项目中从一个帐户创建多少个应用程序,以及我可以在Firebase for Cloud Messaging中创建多少个项目?
firebase ×8
android ×4
javascript ×2
node.js ×2
background ×1
dependencies ×1
firebaseui ×1
gcloud ×1
heroku ×1
npm ×1
postman ×1
talkback ×1
twitter ×1