Angular - App cordova/phonegap+angular7, login google

 
Vista:
sin imagen de perfil
Val: 3
Ha aumentado 1 puesto en Angular (en relación al último mes)
Gráfica de Angular

App cordova/phonegap+angular7, login google

Publicado por chiki (2 intervenciones) el 20/03/2019 05:34:38
Hola, estoy haciendo un login con angular (7) para una app en cordova, pero no me ha funcionado nada, solo me funciona en angular con la web.
En el navegador, al dar clic en un botón que llama el método de iniciar sesión, abre otra ventana y permite iniciar sesión con una cuenta google, pero en la app de cordova, no abre ni siquiera la nueva ventana.

Intenté implementar angular-social-auth (https://www.npmjs.com/package/angular-social-auth), pero no lo supe realizar.
Agradezco su atención.

Este es mi archivo app.module.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
 
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
 
import { DynamiSocialLoginModule, AuthServiceConfig, GoogleLoginProvider, FacebookLoginProvider, LinkedinLoginProvider } from 'ng-dynami-social-login';
import { MenuComponent } from './components/menu/menu.component';
 
export function getAuthServiceConfigs() {
 
  let config = new AuthServiceConfig(
      [
        {
          id: FacebookLoginProvider.PROVIDER_ID,
          provider: new FacebookLoginProvider("XXXXXX")
        },
        {
          id: GoogleLoginProvider.PROVIDER_ID,
         provider: new GoogleLoginProvider("64534521-f0n9n8joovmn7qed5fdjsmlkp.apps.googleusercontent.com")
        }
        ,
        {
          id: LinkedinLoginProvider.PROVIDER_ID,
          provider: new LinkedinLoginProvider("XXXXXXXxXX")
        },
      ]
  );
  return config;
}
 
@NgModule({
  declarations: [
    AppComponent,
    MenuComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    DynamiSocialLoginModule
  ],
  providers: [{
    provide: AuthServiceConfig,
    useFactory: getAuthServiceConfigs
  }],
  bootstrap: [AppComponent],
})
export class AppModule { }

Y este es el archivo app.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { Component, OnInit } from '@angular/core';
import { AuthService, FacebookLoginProvider, GoogleLoginProvider, LinkedinLoginProvider, SocialUserModel } from 'ng-dynami-social-login';
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
 
  title = 'dev';
  user: SocialUserModel;
  constructor(private socialAuthService: AuthService) { }
 
  ngOnInit() {
    this.socialAuthService.authState.subscribe((user) => {
      this.user = user;
    });
  }
  public socialSignIn(socialPlatform : string) {
    let socialPlatformProvider;
    if(socialPlatform == "facebook"){
      socialPlatformProvider = FacebookLoginProvider.PROVIDER_ID;
    }else if(socialPlatform == "google"){
      socialPlatformProvider = GoogleLoginProvider.PROVIDER_ID;
    } else if (socialPlatform == "linkedin") {
      socialPlatformProvider = LinkedinLoginProvider.PROVIDER_ID;
    }
 
    this.socialAuthService.signIn(socialPlatformProvider).then(
      (userData) => {
 
        console.log(userData);
 
 
      }
    );
  }
  public socialSignOut(socialPlatform : string){
    let socialPlatformProvider;
    if(socialPlatform == "google"){
      socialPlatformProvider = GoogleLoginProvider.PROVIDER_ID;
    }
    this.socialAuthService.signOut();
  }
 
 
}

en el archivo html del componente solo llamo el metodo que quiero realizar
1
<input type="button" value="Signin in with Google" (click)="socialSignIn('google')">

Y a continuacion el archivo config.xml de cordova

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?xml version='1.0' encoding='utf-8'?>
<widget id="io.cordova.hellocordova" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>HelloCordova</name>
    <description>
        A sample Apache Cordova application that responds to the deviceready event.
    </description>
    <author email="dev@cordova.apache.org" href="http://cordova.io">
        Apache Cordova Team
    </author>
    <content src="index.html" />
    <plugin name="cordova-plugin-whitelist" spec="1" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <platform name="android">
        <allow-intent href="market:*" />
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
    </platform>
    <plugin name="cordova-plugin-googleplus" source="npm">
        <variable name="REVERSED_CLIENT_ID" value="com.googleusercontent.apps.64534521-f0n9n8joovmn7qed5fdjsmlkp" />
        <variable name="WEB_APPLICATION_CLIENT_ID" value="64534521-f0n9n8joovmn7qed5fdjsmlkp.apps.googleusercontent.com"/>
    </plugin>
    <engine name="android" spec="^7.1.4" />
</widget>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder