Search code examples
ionic-frameworkcordova-plugins

ionic cordova plugins and ionic.Platform.ready


I'm not sure I have completely understood this part of the ionic doc.

Does it means that where ever in my code I'm using a cordova plugin (controller or service) I always have to wrap it with inside a ionic.platform.ready() block?

For example, in one of my controllers I need to stop a timer and cancel a notification:

$scope.stopTimer = function(index){
        $interval.cancel($scope.timers[index].interval);
        ionic.Platform.ready(function(){ 
            cordova.plugins.notification.local.cancel(index);
        }
    };

Is the ionic.Platform.ready necessary?


Solution

  • Yes if You want use native plugins you should use them after callback

    ionic.Platform.ready(callback)