title: Typescript TypeError: Cannot read property 'set' of undefined
body: <p>I'm trying to set up a very basic example of push notifications on android. I use nativescript + typescript (even if the code is a bit messy, as i don't understand how to correctly rewrite "var Observable = require("data/observable");" and "viewModel" in typescript. The code is based on this example <a href="https://bradmartin.net/2015/12/28/use-google-cloud-messaging-for-push-notifications-with-nativescript/" rel="nofollow noreferrer">https://bradmartin.net/2015/12/28/use-google-cloud-messaging-for-push-notifications-with-nativescript/</a></p>
  
  <pre><code>import { Component } from "@angular/core";
  import * as pushPlugin from "nativescript-push-notifications";
  var Observable = require("data/observable");
  
  
  @Component({
  selector: "my-app",
  template: `
      &lt;ActionBar title="My App" icon="" class="action-bar"&gt;
      &lt;/ActionBar&gt;     
  &lt;StackLayout&gt;
  &lt;Label text="Tap the button to trigger the register function." textWrap="true" class=""&gt;&lt;/Label&gt;
  &lt;Button text="REGISTER" (tap)="registerTap()" &gt;&lt;/Button&gt;    
  &lt;label text="Your device id/token:" textWrap="true" &gt;&lt;/label&gt;
  &lt;TextView text="{{ registrationId }}" class="title" textWrap="true"&gt;&lt;/TextView&gt;
  &lt;Label text="{{ message }}" class="message" textWrap="true" &gt;&lt;/Label&gt;
  &lt;/StackLayout&gt;  `
  })
  
  export class AppComponent {
  // Your TypeScript logic goes here
  
  viewModel = new Observable.Observable({
  registrationId: ""
  });
  
  pageLoaded(args) {
  var page = args.object;
  page.bindingContext = this.viewModel;
  }
  
  
  registerTap (args) {
  
  var settings = {
      // Android settings 
      senderID: '0434blablabla', // Android: Required setting with the sender/project number 
      notificationCallbackAndroid: function(message) { // Android: Callback to invoke when a new push is received. 
          console.log(JSON.stringify(message));
          alert(JSON.stringify(message));            
      },
  
      // iOS settings 
      badge: true, // Enable setting badge through Push Notification 
      sound: true, // Enable playing a sound 
      alert: true, // Enable creating a alert 
  
      // Callback to invoke, when a push is received on iOS 
      notificationCallbackIOS: function(message) {
          alert(JSON.stringify(message));
      }
  };
  
  
  
  
  pushPlugin.register(settings,
      // Success callback 
      function(token) {
        alert("test");
            // if we're on android device we have the onMessageReceived function to subscribe 
          // for push notifications 
          if(pushPlugin.onMessageReceived) {
              pushPlugin.onMessageReceived(settings.notificationCallbackAndroid);
          }
  
          alert('Device registered successfully : ' + token);
          this.viewModel.set("regId", token);
      },
      // Error Callback 
      function(error){
        alert("errore");
          console.log(error);
          alert(error);
      }
  );
  }
  
  
  
  }
  </code></pre>
  
  <p>when i click on the register button, i get the following error:</p>
  
  <p>TypeError: "Cannot read property 'set' of undefined"
  I'm new to Typescript and notifications handling, can you give me a hint?</p>
  
  <p>thanks in advance</p>