recognizegroup / capacitor-plugin-msauth

Capacitor-wrapper for MSAL libraries. Works on iOS, Android and web.
Other
17 stars 17 forks source link

Android - register plugin in main activity #1

Closed erlendaksnes-ws closed 2 years ago

erlendaksnes-ws commented 2 years ago

The setup says that the last step for android is: "Register the plugin in the main activity". Do you have an example of how you register it?

bartwesselink commented 2 years ago

Hi! Thank you for using the plugin. The plugin can be registered as follows, by calling add inside the init function of your MainActivity.java file:

import android.os.Bundle;

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

import java.util.ArrayList;

import nl.recognize.msauthplugin.MsAuthPlugin;

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>>() {{
            add(MsAuthPlugin.class);
        }});
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        outState.clear();
    }
}
DonaldoSoWell commented 1 year ago

Hi @bartwesselink thanks for your work, I'm currently implementing this plugin. I think it would be good idea to add this exemple code in the setup guide for other users