谷歌社交登录无法使用 codetrix-studio Capacitor-google-auth 在离子电容器中工作

div*_*raj 6 javascript ionic-framework capacitor

在 Capacitor.config.json 中

"GoogleAuth": {
  "scopes": ["profile","email"],
  "serverClientId": "KEY.apps.googleusercontent.com"
}
Run Code Online (Sandbox Code Playgroud)

在index.html中

<meta name="google-signin-client_id" content="KEY.apps.googleusercontent.com">
Run Code Online (Sandbox Code Playgroud)

在android文件夹中的string.xml文件

<string name="server_client_id">KEY.apps.googleusercontent.com</string>
Run Code Online (Sandbox Code Playgroud)

并在我们的页面 .ts 文件中获取 google 用户详细信息的详细信息

const user = await GoogleAuth.signIn();
Run Code Online (Sandbox Code Playgroud)

我在 android 中出现错误,出了问题。

任何人都知道如何解决这种情况

小智 3

您必须在android/app/src/main/java/com/appName/app/MainActivity.java中添加这些代码行

package com.growyd.app;

import android.os.Bundle;

import com.getcapacitor.BridgeActivity;
import com.codetrixstudio.capacitor.GoogleAuth.GoogleAuth;
import com.getcapacitor.Plugin;

import java.util.ArrayList;

public class MainActivity extends BridgeActivity {
  @Override
  public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);

    //Initialize bridge
    this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
      // Additional plugins you've installed go here
      add(GoogleAuth.class);
    }});
  }
}
Run Code Online (Sandbox Code Playgroud)

此链接中是配置库的步骤。

我的参考: https: //devdactic.com/capacitor-google-sign-in/