"Ошибка при успешном вызове callbackId: CCCometChat1199030706: TypeError: Невозможно прочитать свойство" fcm "из неопределенного"
Я использую тот же код для push-уведомлений в кометном чате. при открытии окна чата кометы, получая "Ошибка в CallbackId: CCCometChat1199030706: TypeError: Невозможно прочитать свойство" fcm "из неопределенного"
Мой код здесь:
declare var CCCometChat: any;
licenseKey = "COMETCHAT-UWUEP-JSKVT-UPXXN-H2Y7Z";
apiKey = "52131x665661ed305388bf2fce242889ee3774";
openCometChat() {
var isFullScreen = true;
CCCometChat.launchCometChat(isFullScreen, data => {
console.log("launch come chat data", data);
CCCometChat.getPlatform(currentplatform => {
console.log("getPlatform", currentplatform);
if (currentplatform.platform == "Android") {
console.log("platform data", data);
data = JSON.parse(data);
console.log("json parse data", data);
if (data.hasOwnProperty('userInfoCallback')) {
console.log("data.userInfoCallback", data.userInfoCallback);
console.log("data.userInfoCallback.push_channel", data.userInfoCallback.push_channel);
// this.checkFCM(data.userInfoCallback.push_channel);
this.fcm.subscribeToTopic(data.userInfoCallback.push_channel);
this.fcm.onNotification().subscribe(data => {
console.log("onNotification data", data);
this.notifyData = JSON.parse(data.data);
console.log('this.notifyData -> ' +JSON.stringify(this.notifyData));
this.message = this.notifyData.message.message;
console.log('this.message -> ' +JSON.stringify(this.message));
if(data.wasTapped){
console.log("Received in background");
console.log('background this.message -> ' +JSON.stringify(this.message));
} else {
console.log("Received in foreground");
let confirmAlert = this.alertCtrl.create({
title: 'New Notification',
message: this.message,
buttons: [{
text: 'Ignore',
role: 'cancel'
}, {
text: 'View',
handler: () => {
//TODO: Your logic here
console.log("ok clicked");
}
}]
});
confirmAlert.present();
}
// if (data.wasTapped) {
// console.log("Received in background" + JSON.stringify(data));
// } else {
// console.log("Received in foreground" + JSON.stringify(data));
// };
});
} else if (data.hasOwnProperty('chatroomInfoCallback')) {
console.log("data.chatroomInfoCallback", data.chatroomInfoCallback);
console.log("data.chatroomInfoCallback.push_channel", data.chatroomInfoCallback.push_channel);
if (data.chatroomInfoCallback.hasOwnProperty('action') && data.chatroomInfoCallback.action != "" && data.chatroomInfoCallback.action == "join") {
// this.checkFCM(data.chatroomInfoCallback.push_channel);
this.fcm.subscribeToTopic(data.chatroomInfoCallback.push_channel);
this.fcm.onNotification().subscribe(data => {
console.log("onNotification data", data);
if (data.wasTapped) {
console.log("Received in background" + JSON.stringify(data));
} else {
console.log("Received in foreground" + JSON.stringify(data));
};
});
}
}
} else {
data = JSON.stringify(data);
data = JSON.parse(data);
if (data.hasOwnProperty('userInfoCallback')) {
this.fcm.subscribeToTopic(data.userInfoCallback.push_channel);
this.fcm.onNotification().subscribe(data => {
if (data.wasTapped) {
console.log("Received in background" + JSON.stringify(data));
} else {
console.log("Received in foreground" + JSON.stringify(data));
};
});
} else if (data.hasOwnProperty('chatroomInfoCallback')) {
if (data.chatroomInfoCallback.hasOwnProperty('action') && data.chatroomInfoCallback.action != "" && data.chatroomInfoCallback.action == "join") {
this.fcm.subscribeToTopic(data.chatroomInfoCallback.push_channel);
this.fcm.onNotification().subscribe(data => {
if (data.wasTapped) {
console.log("Received in background" + JSON.stringify(data));
} else {
console.log("Received in foreground" + JSON.stringify(data));
};
});
}
}
}
});
}, data => {
});
}
Как я могу решить выше неопределенную ошибку 'fcm'? Пожалуйста, дайте здесь ответ как можно скорее, это будет очень ценно.
1 ответ
Пожалуйста, загрузите плагин FCM по ссылке: https://temp.cometchat.com/cordova-plugin-fcm.zip
После этого замените эту папку на папку плагина FCM внутри директории вашего проекта. Не стесняйтесь обращаться в случае дальнейшей помощи.
PS: Этот аккаунт принадлежит команде CometChat.