Uncaught ReferenceError: Ionic is not defined for Ionic Push

I'm trying to add Ionic.io Push to my application but its throwing Ionic is not defined

ReferenceError: Ionic is not defined
var push = new Ionic.Push({

Everything is working fine except this undefined error, I've run this command to update lib but nothing happen, bundle version is * Ionic, v1.1.0

ionic lib update

My app.js

angular.module('TestApp', ['ionic','ionic.service.core',
                            'ionic.service.push',
                            'lavoApp.controllers',
                            'lavoApp.services','ngCordova'])
.run(function($ionicPlatform,$rootScope,$location,$timeout,$anchorScroll,$state,$ionicHistory,$cordovaPush) {

    $ionicPlatform.ready(function() {

        var push = new Ionic.Push({
          "debug": true
        });

        push.register(function(token) {
          console.log("Device token:",token.token);
        });

Answers


Just add below line after

<script src="lib/ionic/ionic.bundle.js"></script>

in your index.html file.

<script src="lib/ionic-platform-web-client/dist/ionic.io.bundle.js"></script>

This error occurs before you run ionic io init. It's also necessary to run ionic config set dev_push true right after that if you're running the app in a browser (otherwise you'll get "PushNotification is not defined"). The whole push notification setup procedure is described here.


In following the setup steps, Ionic CLI autowrote to my index.html:

<script src="lib/ionic-platform-web-client/dist/ionic.io.bundle.min.js"></script>

but I had to manually retrieve the source file (ionic.io.bundle.min.js) from:

https://raw.githubusercontent.com/driftyco/ionic-platform-web-client/master/dist/ionic.io.bundle.min.js

and put it in the expected directory:

lib/ionic-platform-web-client/dist/

I also had to disable and then re-enable limited pushes from the CLI:

ionic config set dev_push true

Nothing else worked for me. Good luck!


You have to verify your ionic-cli version. It has to be the latest, or at least 1.7.10. check enter link description here


Ionic.io(); was supposed to be overruled in the latest version. However, adding Ionic.io(); before var push =Ionic.Push() solved the problem for me. i.e, after i had added the ionic-platform-web-client and push-plugin.


This is a general dependency problem! This means somehow your Ionic dependency from bower is not installed correctly. Try to run "bower install" to install all the dependencies again.


Need Your Help

limit number of jquery drag and drop id's

jquery ajax drag-and-drop

I have the code below that makes a list of div's drag and droppable, on drop it returns a list of the id's in there new order.

SSRS: Report loading external images, image not found, can I hide the image control

image reporting-services hide

My SSRS report loads logo images for each customer from a customer number specific folder on the report server.