Giter Club home page Giter Club logo

Comments (12)

cklanac avatar cklanac commented on June 18, 2024 1

I'm also having issues with the upgrade. A rudimentary Auth.signup and Auth.login, which worked with 0.0.12, no longer works on 0.0.14. The signup and login methods we static in 0.0.12 but now seem to be instance methods.

Was:
static login(moduleId, options: LoginOptions = {}, data): Promise<User> {
Now:
login(moduleId: AuthModuleId, data?: Object, options: LoginOptions = {'remember': true}): Promise<IUser> {

I did a clean install ionic start ionicv2-platform-auth sidemenu --v2 --ts
Added cloud-angular npm install --save @ionic/cloud-angular
Initialized the app ionic io init
And wired it up...

The TS error is...
Property signup does not exists on 'type of Auth'

import { Component, ViewChild } from '@angular/core';
import { App, ionicBootstrap, Platform, Nav } from 'ionic-angular';
import { Auth, User, CloudSettings, provideCloud } from '@ionic/cloud-angular';
import { StatusBar } from 'ionic-native';
import { Page1 } from './pages/page1/page1';
import { Page2 } from './pages/page2/page2';

const cloudSettings: CloudSettings = {
  'core': {
    'app_id': "1f589081"
  }
};

@Component({
  templateUrl: 'build/app.html'
})
class MyApp {
  @ViewChild(Nav) nav: Nav;
  rootPage: any = Page1;
  pages: Array<{ title: string, component: any }>

  constructor(private platform: Platform) {
    this.initializeApp();

    // used for an example of ngFor and navigation
    this.pages = [
      { title: 'Page uno', component: Page1 },
      { title: 'Page dos', component: Page2 }
    ];
  }

  ngOnInit() {
    console.log('app ngOnInit');
    var details = {
      'email': '[email protected]',
      'password': 'secretpassword'
    };
    /**** The following approach worked in 0.0.12 *****/
    Auth.signup(details).then(() => {
      console.log("`user` is now registered");
    }, (err) => {
      console.log("something went wrong!")
    });
  }

  initializeApp() {
    this.platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      StatusBar.styleDefault();
    });
  }

  openPage(page) {
    // Reset the content nav to have just this page
    // we wouldn't want the back button to show in this scenario
    this.nav.setRoot(page.component);
  }
}

ionicBootstrap(MyApp, [provideCloud(cloudSettings)]);

from ionic-cloud-angular.

imhoffd avatar imhoffd commented on June 18, 2024

Try 0.0.14. I just forgot to bump the version of ionic-cloud.

from ionic-cloud-angular.

sagivf avatar sagivf commented on June 18, 2024

Thanks @dwieeb , but now I'm getting this -
image

Looks like the es5 dist folder is missing the auth module
image

I have no Idea how the Typesciprt stuff gets bundled in the node_modeuls so I can'y really debug what's going on....

from ionic-cloud-angular.

imhoffd avatar imhoffd commented on June 18, 2024

What version is specified in your package.json for @ionic/cloud-angular? I was getting the exact same errors until I changed it to * and reinstalled.

from ionic-cloud-angular.

sagivf avatar sagivf commented on June 18, 2024

It was 0.0.14, tried *, still doesn't work.
Can you explain something:

I see Auth is exported twice, once here,
https://github.com/driftyco/ionic-cloud-angular/blob/master/src/index.ts#L1 (export * from '@ionic/cloud';)
And once here - https://github.com/driftyco/ionic-cloud-angular/blob/master/src/index.ts#L5

The second time it is used to add an @Injectable .
Does typesciprt always use the second one?
Why is the @Injectable here is never inject it myself?

from ionic-cloud-angular.

sagivf avatar sagivf commented on June 18, 2024

I Ask this because - 540400b is pretty recent which makes me suspect it's the colporate.

from ionic-cloud-angular.

sagivf avatar sagivf commented on June 18, 2024

@dwieeb I think this needs re opening...

from ionic-cloud-angular.

imhoffd avatar imhoffd commented on June 18, 2024

@cklanac The Auth service no longer has those static methods. 0.0.14 was a big change. Try this:

import {Component} from '@angular/core';
import {Auth, User} from '@ionic/cloud-angular';

@Component( ... )
export class MyApp {
  constructor(public auth: Auth, public user: User) {
    ...
  }

  ngOnInit() {
    console.log('app ngOnInit');
    var details = {
      'email': '[email protected]',
      'password': 'secretpassword'
    };

    this.auth.signup(details).then(() => {
      // success
    }, (err) => {
      console.log("something went wrong!")
    });
  }
}

The login method data and options parameters were swapped, because options should come after required parameters.

Try something like:

this.auth.login('basic', {'email': '[email protected]', 'password': 'secretpassword'});

from ionic-cloud-angular.

imhoffd avatar imhoffd commented on June 18, 2024

@sagivf The typescript errors are correct. It's saying you can't call login/logout/etc on Auth class because they're no longer static methods. 0.0.14 had some changes from 0.0.12. See above. They're quick changes. Just inject the service into your constructor(s) and instead of Auth use this.auth.

Similarly, always use the this.user variable to reference the current user.

This library and the ionic-cloud client aren't full releases. We're still very much in beta and we're still trying to develop the best API for the client, which is why we've opened discussions such as #1, ionic-team/legacy-ionic-cloud#3, and ionic-team/legacy-ionic-cloud#13.

from ionic-cloud-angular.

sagivf avatar sagivf commented on June 18, 2024

I think I tried it and it failed but I will try again soon.
On Sun, 3 Jul 2016 at 9:31 PM Daniel Imhoff [email protected]
wrote:

@sagivf https://github.com/sagivf The typescript errors are correct.
0.0.14 had some changes from 0.0.12. See above. They're quick changes. Just
inject the service into your constructor(s) and instead of Auth use
this.auth.


You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
#6 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/ABxXuicXJAP233X7LBfZwRlcGeXafwFFks5qSAAHgaJpZM4JDnaT
.

from ionic-cloud-angular.

sagivf avatar sagivf commented on June 18, 2024

Hey @dwieeb, so you are correct changing it to instances work nicely 👍
There are a couple of related issues/comments:
ionic-team/legacy-ionic-cloud#10 (comment)
#7

from ionic-cloud-angular.

imhoffd avatar imhoffd commented on June 18, 2024

Nice, glad to hear! 👍

from ionic-cloud-angular.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.