nativescript-aws-cognito
AWS Cognito 服务限版
npm i --save nativescript-aws-cognito

nativescript-aws-cognito

本插件为使用 AWS Cognito 服务的限版。如果您想购买完整版或其他 AWS 服务插件,请通过此网址联系我们。www.cerensoftware.co.uk

您可以查看示例项目:https://github.com/aliyksel/loginproject(分支:cognito)

(可选) 先决条件 / 要求

如果在 iOS 中遇到 keychain 错误,您必须将 nativescript-custom-entitlements 插件安装到您的项目中。您需要将以下行添加到 app.entitlements 文件中。

<dict>
<key>keychain-access-groups</key>
<array>
<string>$(AppIdentifierPrefix)org.nativescript.loginproject</string>
</array>
</dict>

安装

tns plugin add nativescript-aws-cognito

使用方法

import {AwsCognito, CognitoCommonDelegate} from "nativescript-aws-cognito";

为 Cognito 用户池创建用户池。

  AwsCognito.createUserPool(region, cliendId, secretId, poolId, delegate);
region : region of your pool. for example AWSRegionUSWest1.
delegate : instance of your class is implement from CognitoIdentityInteractiveAuthenticationDelegate.
delegate has startPasswordAuthentication method. this method is called when begin of  Authentication flow.
You must open login page.

you can create a new user.
   AwsCognito.registerUser(userName:, password:, attrubutes:Array<{key:string, value:string}>, delegate);   
    attrubutes : they are user attributes which are you select when define the pool.
    delegate : instance of your class is implement from CognitoCommonDelegate.
    delegate has 2 methods.
       onSuccess : it is called when action seccesfull
       onError :  it is called when action has an error.

After user created, cognito sen a digital code for confirmation to user email. you have to send digitalcode to cognito.
```js
    AwsCognito.confirmSignUp(userName,verifyCode, delegate);
```

delegate : instance of your class is implement from CognitoCommonDelegate.
    delegate has 2 methods.
       onSuccess : it is called when action seccesfull
       onError :  it is called when action has an error.


you can user details. if user signin you get details. if user not signin your class is called which is implement from CognitoIdentityInteractiveAuthenticationDelegate.

```js
    AwsCognito.getUserDetail(delegate:CognitoCommonDelegate);
```
you opened login page and you got username and password from user. you call login method.

```js
    AwsCognito.login(userName:String, password:String, delegate:CognitoCommonDelegate);
```
```js
    AwsCognito.signOut();
```

API

This plugin uses ObjectiveC AWS SDk and Java AWS Sdk.

许可

Apache 许可证第 2 版,2004 年 1 月 2004