FirebaseArrayIndexError interface

複合類型,其中包含 FirebaseError 物件和索引,可用於取得發生錯誤的項目。

簽名:

export interface FirebaseArrayIndexError 

屬性

屬性 類型 說明
錯誤 FirebaseError 錯誤物件。
索引 數字 在呼叫的 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);
 
});