capacitor-community / privacy-screen

⚡️ Capacitor plugin that protects your app from displaying a screenshot in Recents screen/App Switcher.
MIT License
88 stars 23 forks source link

Capacitor 3 Support #9

Closed robingenz closed 3 years ago

robingenz commented 3 years ago

Updating Capacitor to 3.0.
Guide: https://capacitorjs.com/docs/v3/updating/plugins/3-0
New plugin template: https://github.com/ionic-team/create-capacitor-plugin/tree/main/assets/plugin-template

robingenz commented 3 years ago

The guide is a work-in-progress. Currently waiting for final release.

mheumann commented 3 years ago

Hey, everything seems to work great with Capacitor 3. There is just one thing missing in the documentation. You renamed the class to PrivacySrcreenPlugin so one now needs to change the import statement and also the registation:

import com.getcapacitor.plugin.privacyscreen.PrivacyScreenPlugin;

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

    registerPlugin(PrivacyScreenPlugin.class);
  }
}
robingenz commented 3 years ago

Hi, as far as I know Capacitor 3 has "Android Plugin Auto-loading" (see here). So you don't have to register the plugin manually anymore. This section in the README.md still refers to Capacitor 2, I will remove it soon.

mheumann commented 3 years ago

I didn't test without registering it, but I refer to this section in the upgrade guide: https://capacitorjs.com/docs/v3/updating/3-0#switch-to-automatic-android-plugin-loading

robingenz commented 3 years ago

Custom Plugins refers to plug-ins a user builds specifically for an app. Plugins included in package.json are registered automatically by the Capacitor CLI. I tested it again and it works.

mheumann commented 3 years ago

Ah ok thank you! And great work with the plugin!