复合类型,其中包含FirebaseError
对象和可用于获取错误项目的索引。
签名:
export interface FirebaseArrayIndexError
特性
财产 | 类型 | 描述 |
---|---|---|
错误 | Firebase错误 | 错误对象。 |
指数 | 数字 | 原始数组中错误项目的索引作为所调用的 API 方法的一部分传递。 |
FirebaseArrayIndexError.error
错误对象。
签名:
error: FirebaseError;
FirebaseArrayIndexError.index
原始数组中错误项目的索引作为所调用的 API 方法的一部分传递。
签名:
index: number;
例子
var registrationTokens = [token1, token2, token3];
admin.messaging().subscribeToTopic(registrationTokens, 'topic-name')
.then(function(response) {
if (response.failureCount > 0) {
console.log("Following devices unsucessfully subscribed to topic:");
response.errors.forEach(function(error) {
var invalidToken = registrationTokens[error.index];
console.log(invalidToken, error.error);
});
} else {
console.log("All devices successfully subscribed to topic:", response);
}
})
.catch(function(error) {
console.log("Error subscribing to topic:", error);
});