Error - ':' expected


#1

Hai…I got this error…i have no idea how to clear this error

login(){  
  this.googleplus.login({       
    'webClientId' : 'my_client_id',    
     'offline' : true       
 }).then(res => {  
          firebase.auth().signInWithCredential(firebase.auth.GoogleAuthProvider.credential(res.idToken())) 
           .then(suc=>{              
                this.navCtrl.push(UserPage,{             
                          alert = this.alert.create({         
                                   title: 'Login-Message',       
                                   subTitle : 'LoggedIn Successfull',    
                                   buttons :  ['Okay']        
                                  });     
                                 alert.present(),       
                });     
       }).catch(ns =>{      
          alert("Not Successfull..Try again")   
         })      
    })     
  }

#2

Why exactly are you wanting to push the whole Google Plus login to the UserPage page? Second option in navCtrl.push is an object of paramters to forward, and you’re essentially doing

{ someFunction() }

which isn’t valid syntax for an object… What are you trying to do?

Edit: Also, this seems to be Ionic 2+, please update the category :slight_smile:


#3

sorry…i just want to do when google authentication button is clicked it has to alert the message in their userpage…that’s all what i need…now i updated my code…but still there is an error.


#4

What did you update your code to? If you’re still getting that error, my guess would be you didn’t follow what @mich356c said and you’re still attempting to create and present an alert in the navCtrl parameters.

To be clear, this is the offending code:

this.navCtrl.push(UserPage, {             
  alert = this.alert.create({         
    title: 'Login-Message',       
    subTitle : 'LoggedIn Successfull',    
    buttons :  ['Okay']        
  });     
  alert.present(),       
});

You’ll want to do something like this:

let alert = this.alert.create({
  title: 'Login-Message',
  subTitle : 'LoggedIn Successfull',
  buttons :  [{
    text: 'Okay',
    handler: () => {
      alert.dismiss().then(_ => {
        this.navCtrl.push(UserPage);
      });

      return false;
    }
  }]
});

alert.present();

#5

Uncaught(in promise):cordova_not_available what its mean…? i am getting this run time error…I am new to ionic.


#6

One of two things.

First possibility is that you’re trying to use a cordova plugin in the browser, which normally won’t work as most cordova plugins require native functionality.

The second possibility I believe is that you’re trying to use a cordova plugin before cordova is ready. In this case you need to wrap your call with platform.ready, e.g.

platform.ready().then(_ => {
   CordovaPlugin.doStuff();
});

#7

i have tried this code but it shows window.plugins is undefined in homepage. i created index.d.ts in the window folder and did
interface window{ plugins:any; }

but still i got this error…i @SigmundFroyd t will be helpfull if you give example as your method…What need to be change in my code

 this.platform.ready().then(_ =>{    
   (window as any).plugins.googleplus.login({     
     'webClientId' : 'my_client_id',
          'offline' : true      
  }).then(res => {
            firebase.auth().signInWithCredential(firebase.auth.GoogleAuthProvider.credential(res.idToken()))
            .then(suc=>{           
               this.displyaname = res.displyaname;
                this.email = res.email;    
                this.userdId  = res.userdId;
               this.isLoggedIn = true;
            }).catch(ns =>{           
                   alert("Not Successfull..Try again")     
                }) 
             })  
      });



#8

Why aren’t you using ionic-native googleplus?


#9

i am using that one …


#10

This does not look like you are using ionic-native to me.


#11

error corrected bro…now facing new errors…:slight_smile: