有在幹資料的人都會推的開源:youtube-dl
優點是去爬網頁的資料,不需使用 api key也可以使用,
也有支援oauth的功魴。
const emitter = new EventEmitter()
emitter.setMaxListeners(100)
// or 0 to turn off the limit
emitter.setMaxListeners(0)
require('events').EventEmitter.prototype._maxListeners = 100;
// turn off limits by default (BE CAREFUL)
require('events').EventEmitter.prototype._maxListeners = 0;
require('events').EventEmitter.defaultMaxListeners = 0
- Do I have to unsubscribe the old token and subscribe the new token to topics?
subscribeToTopic() in onTokenRefreshed().
- Do I have to remove the old token and add the new token to device groups?
NotRegistred error on one of the tokens if you send to Device Group. :)
- Is it possible to get information about device groups/topics for a token?
details parameter to true:[optional] booleandetails: set this query parameter totrueto get available IID token details, including connection information and FCM or GCM topic subscription information (if any) for the device associated with this token. When not specified, defaults tofalse.
- Can I add a token to a device group more than once?
- Can I subscribe a token to a topic more than once?
- Will multiple subscriptions/additions of the same token result in receiving duplicate messages?






npm install firebase-admin --save
var admin = require('firebase-admin');
var serviceAccount = require('path/to/serviceAccountKey.json');
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: 'https://.firebaseio.com'
});
// The topic name can be optionally prefixed with "/topics/".
var topic = 'highScores';
// See documentation on defining a message payload.
var message = {
data: {
score: '850',
time: '2:45'
},
topic: topic};
// Send a message to devices subscribed to the provided topic.
admin.messaging().send(message)
.then((response) => {
// Response is a message ID string.
console.log('Successfully sent message:', response);
})
.catch((error) => {
console.log('Error sending message:', error);
});
admin.messaging().send(message, dryRun)
// Define a condition which will send to devices which are subscribed
// to either the Google stock or the tech industry topics.
var condition = "'stock-GOOG' in topics || 'industry-tech' in topics";
// See documentation on defining a message payload.
var message = {
notification: {
title: '$GOOG up 1.43% on the day',
body: '$GOOG gained 11.80 points to close at 835.67, up 1.43% on the day.'
},
condition: condition};
// Send a message to devices subscribed to the combination of topics
// specified by the provided condition.
admin.messaging().send(message)
.then((response) => {
// Response is a message ID string.
console.log('Successfully sent message:', response);
})
.catch((error) => {
console.log('Error sending message:', error);
});
| 参数 | 说明 |
|---|---|
data | 键值对映射,其中所有键和值都是字符串。 |
notification | 一个包含 title 和 body 字段的对象。 |
android | 一个由 Android 消息专用字段组成的对象。要了解详情,请参阅 Android 专用字段。 |
apns | 一个由 Apple 推送通知服务 (APNS) 专用字段组成的对象。要了解详情,请参阅 APNS 专用字段。 |
webpush | 一个由 WebPush 协议专用字段组成的对象。要了解详情,请参阅 WebPush 专用字段。 |
token | 一个用于标识消息的收件人设备的注册令牌。 |
topic | 要将消息发送至的主题名称。该主题名称不能包含 /topics/ 前缀。 |
condition | 发送消息时所依据的条件,例如 "foo" in topics && "bar" in topics |
var message = {
notification: {
title: '$GOOG up 1.43% on the day',
body: '$GOOG gained 11.80 points to close at 835.67, up 1.43% on the day.',
},
android: {
ttl: 3600 * 1000,
notification: {
icon: 'stock_ticker_update',
color: '#f45342',
},
},
apns: {
payload: {
aps: {
badge: 42,
},
},
},
topic: 'industry-tech'
};