For the nativescript push plugin (https://github.com/NativeScript/push-plugin) in the readme, there is a run through of how to get the hello world app to send push notifications. As I ran through the tutorial before trying to impliment in my own application, I got it to build, then to run, but when the app tries to send a push notification, it hits the error saying TypeError: self.set is not a function
. Now, I do not see why it is saying this as self.set seems integral with the test application but I was wondering if this function was deprecated or if there is another issue. Here is the code in main-view-model.js (only edited file for the tutorial)
var Observable = require("data/observable").Observable;
var pushPlugin = require("nativescript-push-notifications");
function getMessage(counter) {
if (counter <= 0) {
return "Hoorraaay! You unlocked the NativeScript clicker achievement!";
} else {
return counter + " taps left";
}
}
function createViewModel() {
var viewModel = new Observable();
viewModel.counter = 42;
viewModel.message = getMessage(viewModel.counter);
viewModel.onTap = function() {
this.counter--;
this.set("message", getMessage(this.counter));
}
var self = this;
pushPlugin.register({ senderID: '403351630118' }, function (data){
self.set("message", "" + JSON.stringify(data));
}, function() { });
pushPlugin.onMessageReceived(function callback(data) {
self.set("message", "" + JSON.stringify(data));
});
return viewModel;
}
exports.createViewModel = createViewModel;
Any ideas on the issue or should I just try to start from scratch and try again?