ng2-cognito-sync
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

ng2-cognito-sync

Installation

  1. Create new identity pool

    Create new identity pool

  2. Registration Facebook for Developers and create facebook app.

    Facebook for Developers

  3. Install ng2-cognito-sync

    npm install ng2-cognito-sync --save
  4. Import Ng2CognitoSyncModule

    import { Ng2CognitoSyncModule } from 'ng2-cognito-sync';
     
    @NgModule({
    declarations: [
      AppComponent
    ],
    imports: [
      BrowserModule,
      FormsModule,
      HttpModule,
      Ng2CognitoSyncModule.forRoot({
        region: 'ap-northeast-1',
        identityCredentials: {
          IdentityPoolId: 'ap-northeast-1:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
        },
        facebookInitParams: {
          appId: '000000000000000'
        }
      })
    ],
  5. Usage

    <button (click)="login()">Login</button>
    import { Ng2CognitoSync } from 'ng2-cognito-sync';
    constructor(private cognitoSyncNg2CognitoSync) { }
     
    login() {
      this.cognitoSync.facebook.login('name,gender,birthday,locale',
        {scope: 'public_profile,user_birthday', return_scopes: true}).subscribe(res => {
        if (res.profile) {
          this.cognitoSync.facebook.openDataset('user').subscribe(dataset => {
            dataset.put('profile', JSON.stringify(res.profile), (errPut, record) => {
              dataset.synchronize();
            });
          });
        }
      }, error => {
        console.error(error);
      });
    }

Readme

Keywords

none

Package Sidebar

Install

npm i ng2-cognito-sync

Weekly Downloads

0

Version

0.0.1

License

MIT

Last publish

Collaborators

  • tupleach