Understanding how to use ionic-native with Creator


#1

Hello. I am still new to Ionic Creator, but I have created most of my app through the drag and drop. I am wondering where can I find proper documentations with using ionic-native (specifically camera) with Creator? The syntax between using ionic and ionic native in the controller vs creator and ionic native looks really different. Can someone please point me in the right direction?

Thanks!


#2

Please check out this post: How to user ngCordova with Ionic creator.


#3

Hey there! Thanks for linking me this post. I’ve actually looked at that exact post and became extremely confused.

For example:

function ($scope, $stateParams, $cordovaGeolocation) {
    $scope.MyLocation = {
        Lat:Infinity,
        Long:Infinity
    };
    $scope.GetLocation = function() {
        var posOptions = {timeout: 10000, enableHighAccuracy: false};
        $cordovaGeolocation
            .getCurrentPosition(posOptions)
            .then(function (position) {
                $scope.MyLocation.Lat  = position.coords.latitude;
                $scope.MyLocation.Long = position.coords.longitude;
            }, function(err) {
          // error
        });
    };
}

This is the Ionic creators usage, but looking through the gelocation documentation and sample usage.

I am not sure how I am supposed to know to use “position.coords.latitude”. How do I correlate the documentation and how it’s executed in the Creator app?


#4

Ionic Native is just a wrapper around various 3rd party plugins to simplify the use of the plugins in Ionic. So there are really 2 issues for you here:

  1. How to use Ionic Native in Ionic v1 - which is creator’s current version. For this, scroll to the bottom of this page: Examples and read the part in the sample code that says “// Angular 1 / Ionic 1…”

  2. How to use a specific plugin. For this, you have to read the Repo of the plugin which is listed in each plugin page in Ionic Native as well. e.g… for GeoLocation, it says “Repo: https://github.com/apache/cordova-plugin-geolocation”. If you read the Repo, you’ll see that “position.coords.latitude” is described there. Of coz, not all plugins have proper documentation and worse still, some have documentation error which will drive you in circles.


#5

That clears it up! Thanks for helping me out!