Search code examples
ionic-frameworkionic2ionic3ionic-native

Ionic 3 Native - LinkedIn login error


I have used ionic native linkedin plugin in Ionic 3 app.

My code:

var scopes = ['r_basicprofile', 'r_emailaddress', 'rw_company_admin', 'w_share'];
this.linkedin.login(scopes, true).then((res) => {
    console.log(res) ;
}, (err) => {
    console.log(err) ;
});

And i have error:

Argument of type 'string[]' is not assignable to parameter of type 'LinkedInLoginScopes[]'. Type 'string' is not assignable to type 'LinkedInLoginScopes'.

Help me please.


Solution

  • You need to define the type of scopes.

    Type of scopes argument in plugin wrapper-

    export type LinkedInLoginScopes = 'r_basicprofile' | 'r_emailaddress' | 'rw_company_admin' | 'w_share';

    login(scopes: LinkedInLoginScopes[], promptToInstall: boolean): Promise { return; }

    let scopes:any = ['r_basicprofile', 'r_emailaddress', 'rw_company_admin', 'w_share'];
    

    or

     let scopes:Array<string> = ['r_basicprofile', 'r_emailaddress', 'rw_company_admin', 'w_share'];
    
    
        this.linkedin.login(scopes, true).then((res) => {
            console.log(res) ;
        }, (err) => {
            console.log(err) ;
        });