Skip to content Skip to sidebar Skip to footer

Typeerror: Cannot Read Property 'notification' Of Undefined

Trying to implement local notification with the following error as a result: TypeError: Cannot read property 'notification' of undefined Code in question is, function(){ $ioni

Solution 1:

You're facing this error because, $ionicPlatform is not available in the global scope of your application.

Seems like you're trying to run something on the very first instance the application loads. Well, why not do it the angular way ?/

    angular.module("starter", ['ionic']).
    run(function($rootScope, $location, $ionicPlatform, $state) {
        $ionicPlatform.ready(function() {
            $cordovaLocalNotification.add({
                id: '1',
                message: "Push!!"
            })
        }, false);  
    });

From the Docs :

Run blocks are the closest thing in Angular to the main method. A run block is the code which needs to run to kickstart the application. It is executed after all of the service have been configured and the injector has been created.

Post a Comment for "Typeerror: Cannot Read Property 'notification' Of Undefined"