TeamMaestro / capacitor-single-sign-on

10 stars 13 forks source link

[Android] : Cannot read property 'authenticate' of undefined #12

Open GroupeBEL opened 4 years ago

GroupeBEL commented 4 years ago

Hello,

When I run my ionic application in android and I tried to sign in, I got this problem:

Cannot read property 'authenticate' of undefined

I tried to test it with android 10 and android 8.

iOS is showing the authentication.

pradella commented 4 years ago

Same here. Seems like the plugin is not recognized when Android. iOS works fine.

pradella commented 4 years ago

@webteambel found the solution:

When in Android, plugins must be exported: https://capacitor.ionicframework.com/docs/plugins/android/#export-to-capacitor

Following the link above, import the class: import com.teamhive.capacitor.plugin.SingleSignOn;

...and add the plugin: add(SingleSignOn.class);

Zensynthium commented 2 years ago

What files what you add those lines of code in?

pradella commented 2 years ago

MainActivity.java

Sharing mine below:

package com.myapp;

import android.os.Bundle;

import com.getcapacitor.BridgeActivity;
import com.getcapacitor.Plugin;

import java.util.ArrayList;

// Other imports...
import com.teamhive.capacitor.plugin.SingleSignOn;

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

    // Initializes the Bridge
    this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
      // Additional plugins you've installed go here
      // Ex: add(TotallyAwesomePlugin.class);
      add(SingleSignOn.class);
    }});
  }
}