text: /*
   * Licensed to the Apache Software Foundation (ASF) under one
   * or more contributor license agreements.  See the NOTICE file
   * distributed with this work for additional information
   * regarding copyright ownership.  The ASF licenses this file
   * to you under the Apache License, Version 2.0 (the
   * "License"); you may not use this file except in compliance
   * with the License.  You may obtain a copy of the License at
   *
   * http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing,
   * software distributed under the License is distributed on an
   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   * KIND, either express or implied.  See the License for the
   * specific language governing permissions and limitations
   * under the License.
   */
  
   function onPushwooshInitialized(pushNotification) {
  
      //if you need push token at a later time you can always get it from Pushwoosh plugin
      pushNotification.getPushToken(function(token) {
        console.info('push token: ' + token);
      }
      );
      
      //and HWID if you want to communicate with Pushwoosh API
      pushNotification.getPushwooshHWID(function(token) {
        console.info('Pushwoosh HWID: ' + token);
      }
      );
      
      //settings tags
      pushNotification.setTags({
        tagName: "tagValue",
        intTagName: 10
      },
      function(status) {
       console.info('setTags success: ' + JSON.stringify(status));
     },
     function(status) {
       console.warn('setTags failed');
     }
     );
      
      pushNotification.getTags(function(status) {
         console.info('getTags success: ' + JSON.stringify(status));
       },
       function(status) {
         console.warn('getTags failed');
       }
       );
      
      //start geo tracking.
      //pushNotification.startLocationTracking();
    }
  
    function initPushwoosh() {
      var pushNotification = cordova.require("pushwoosh-cordova-plugin.PushNotification");
      
      //set push notifications handler
      document.addEventListener('push-notification',
        function(event) {
          var message = event.notification.message;
          var userData = event.notification.userdata;
  
          document.getElementById("pushMessage").innerHTML = message + "<p>";
          document.getElementById("pushData").innerHTML = JSON.stringify(event.notification) + "<p>";
  
                                //dump custom data to the console if it exists
                                if (typeof(userData) != "undefined") {
                                  console.warn('user data: ' + JSON.stringify(userData));
                                }
                              }
                              );
      
      //initialize Pushwoosh with projectid: "GOOGLE_PROJECT_ID", appid : "PUSHWOOSH_APP_ID". This will trigger all pending push notifications on start.
      pushNotification.onDeviceReady({
       projectid: "135096184935",
       appid: "A2349-A73FD",
       serviceName: ""
     });
      
      //register for push notifications
      pushNotification.registerDevice(
        function(status) {
          document.getElementById("pushToken").innerHTML = status.pushToken + "<p>";
          onPushwooshInitialized(pushNotification);
        },
        function(status) {
          alert("failed to register: " + status);
          console.warn(JSON.stringify(['failed to register ', status]));
        }
        );
    }
  
  
    var app = {
      // Application Constructor
      initialize: function() {
        this.bindEvents();
      },
      // Bind Event Listeners
      //
      // Bind any events that are required on startup. Common events are:
      // 'load', 'deviceready', 'offline', and 'online'.
      bindEvents: function() {
        document.addEventListener('deviceready', this.onDeviceReady, false);
      },
      // deviceready Event Handler
      //
      // The scope of 'this' is the event. In order to call the 'receivedEvent'
      // function, we must explicity call 'app.receivedEvent(...);'
      onDeviceReady: function() {
        initPushwoosh();
        app.receivedEvent('deviceready');
      },
      // Update DOM on a Received Event
      receivedEvent: function(id) {
        var parentElement = document.getElementById(id);
        var listeningElement = parentElement.querySelector('.listening');
        var receivedElement = parentElement.querySelector('.received');
  
        listeningElement.setAttribute('style', 'display:none;');
        receivedElement.setAttribute('style', 'display:block;');
  
        console.log('Received Event: ' + id);
      }
    };
  
    app.initialize();
  