Strange unexpected token on cordova

I have this code

Template.au.onRendered(function () {
var allContacts = {
    if(Meteor.isCordova){
      function onSuccess(contacts){
        console.log(contacts);
        contacts = _.sortBy(contacts, function(o) { return o.name.givenName; })
        Session.set("contactos",contacts);
      };
      function onError(contactError){
        Session.set("contactos","");
      };
      var options = new ContactFindOptions();
      options.multiple = true;
      var fields       = ["displayName", "name"];
      var contactos = navigator.contacts.find(fields, onSuccess, onError, options);
    }else{
      Session.set("contactos", allContacts);
    }
    }
    )};
    
    Template.au.helpers({
    contactos: function () {
    return Session.get("contactos");
    }
    });

That i am using to list all contacts in my phone.However,i keep getting unexpected token error on this line if(Meteor.isCordova){

I have checked the braces and all they all match and the problem squarely emanates from that line. Why am i getting the error?.