NativeScript plugin for LinkedIn Auth. Use OAuth2 to sign in with LinkedIn. Use this iOS lib and this Android lib.
Add the plugin
tns plugin add nativescript-linkedin-signin
Add this line into the AndroidManifest.xml
<activity android:name="com.teammobile.linkedinsignin.ui.LinkedinSignInActivity"/>
import { Component, OnInit } from "@angular/core";
import { LinkedinSignin } from "nativescript-linkedin-signin";
import * as Application from "tns-core-modules/application";
import * as utilsModule from "tns-core-modules/utils/utils";
import { isAndroid } from "tns-core-modules/platform/platform";
@Component({
selector: "Home",
templateUrl: "./home.component.html"
})
export class HomeComponent implements OnInit {
constructor() {
}
ngOnInit(): void {
// Init your component properties here.
if(isAndroid){
LinkedinSignin.init("<CLIENT_ID>", "<CLIENT_SECRET>", "<REDIRECT_URI>", new Array<string>(), utilsModule.ad.getApplicationContext());
} else {
LinkedinSignin.init("<CLIENT_ID>", "<CLIENT_SECRET>", "<REDIRECT_URI>", new Array<string>(), Application.ios.rootController);
}
}
coLinkedin(): void {
LinkedinSignin.login().then(item => {
console.dir(item);
alert(item.token.accessToken);
}).catch((error)=>{
alert("FAIL : "+error.error);
console.dir(error);
});
}
}
Apache License Version 2.0, January 2004