npm i --save nativescript-instagram-auth
- 版本:1.0.0
- GitHub: https://github.com/daweedm/nativescript-instagram-auth
- NPM: https://npmjs.net.cn/package/nativescript-instagram-auth
- 下载量
- 昨日: 0
- 上周: 0
- 上月: 0
nativescript-instagram-auth
轻松集成 Instagram 登录功能到您的 NativeScript 应用(目前仅适用于使用 angular 开发的应用)
安装
tns plugin add nativescript-instagram-auth
配置
注册模块,并使用您的凭证进行配置
注意:重定向 URI 需要和您在 Instagram 开发者网站 > 管理客户端 > 安全中设置的相同
import {InstagramAuthModule} from "nativescript-instagram-auth/angular";
// ...
// Register this module to your angular app
InstagramAuthModule.forRoot({
clientId: 'YOUR_CLIENT_ID',
redirectUri: 'A_VALID_REDIRECT_URL'
})
启动登录界面(仅作为模态窗口)
private igLogin(): Promise<InstagramLoginResponse> {
const options: ModalDialogOptions = {
viewContainerRef: this.vcRef,
context: {},
fullscreen: true
};
return this.modalService.showModal(LoginComponent, options);
}
ngOnInit(): void {
this.igLogin().then(({error, token}) => {
if (error) {
// the user cancelled the login process or an error raised
} else {
console.log(`access token: ${token}`);
}
});
}
示例
完整示例可在 demo-angular
文件夹中找到
许可证
Apache 许可证第 2 版,2004 年 1 月