One of the views in my ember app has the following structure
export default Ember.View.extend({
didInsertElement: function() {
window.onload = function() {
chrome.gcm.onMessage.addListener(function(message) {
receiveGCM(message);
});
}
},
receiveGCM: function(message){
console.log(message);
//type check here
//Then call necessary data insertion module
//Or call the notification module
}
});
This is throwing an error Error in event handler for gcm.onMessage: ReferenceError: receiveGCM is not defined
Calling receiveGCM(message)
with the this
object doesn't solve the problem. Wrong this
object gets referred. I tried using bind(this)
. But that doesn't help.
How do I call receiveGCM()
from the chrome listener method?
Aucun commentaire:
Enregistrer un commentaire