question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot register my capacitor plugin in any of the capacitor app

See original GitHub issue

I have generated the plugin for AES256 encryption. i have installed it using npm install "foldername" in local.But when i register that plugin in capacitor app

i have received

Argument of type 'AES256Web' is not assignable to parameter of type 'WebPlugin'. Types have separate declarations of a private property 'addWindowListener'

But i have created this plugin by extending Webplugin class

Here my web.ts file in plugin

import { WebPlugin } from '@capacitor/core'; import { AES256Plugin } from './definitions';

export class AES256Web extends WebPlugin implements AES256Plugin { constructor() { super({ name: 'AES256', platforms: ['web', 'Android', 'iOS'] }); }

async encrypt(options: { secureKey: string, action: string, secureIv: string, value: string }): Promise<any> { return options; } }

const AES256 = new AES256Web(); import { registerWebPlugin } from '@capacitor/core'; registerWebPlugin(AES256);

export { AES256 };

my app.component.ts file in capacitor app

import { Component, OnInit } from '@angular/core'; import {registerWebPlugin} from "@capacitor/core"; import { AES256 } from 'cordova-plugin-aes256-encryption'; import { Platform } from '@ionic/angular'; import { SplashScreen } from '@ionic-native/splash-screen/ngx'; import { StatusBar } from '@ionic-native/status-bar/ngx'; import {OAuth2Client} from '@byteowls/capacitor-oauth2'; @Component({ selector: 'app-root', templateUrl: 'app.component.html', styleUrls: ['app.component.scss'] }) export class AppComponent implements OnInit { constructor( private platform: Platform, private splashScreen: SplashScreen, private statusBar: StatusBar ) { this.initializeApp(); } initializeApp() { this.platform.ready().then(() => { this.statusBar.styleDefault(); this.splashScreen.hide(); }); } ngOnInit() { registerWebPlugin(AES256); } }

I have received this error in app.component.ts file

ngOnInit() { registerWebPlugin(AES256); }

package.json file in capacitor app

{ “name”: “Fund-Request”, “version”: “0.0.1”, “author”: “Ionic Framework”, “homepage”: “https://ionicframework.com/”, “scripts”: { “ng”: “ng”, “start”: “ng serve”, “build”: “ng build”, “test”: “ng test”, “lint”: “ng lint”, “e2e”: “ng e2e” }, “private”: true, “dependencies”: { “@angular/common”: “~8.1.2”, “@angular/compiler”: “~8.1.2”, “@angular/core”: “~8.1.2”, “@angular/forms”: “~8.1.2”, “@angular/platform-browser”: “~8.1.2”, “@angular/platform-browser-dynamic”: “~8.1.2”, “@angular/router”: “~8.1.2”, “@byteowls/capacitor-oauth2”: “1.0.0”, “@capacitor/android”: “^1.1.1”, “@capacitor/cli”: “1.1.1”, “@capacitor/core”: “1.1.1”, “@capacitor/ios”: “^1.1.1”, “@ionic-native/core”: “^5.0.0”, “@ionic-native/splash-screen”: “^5.0.0”, “@ionic-native/status-bar”: “^5.0.0”, “@ionic/angular”: “^4.7.1”, “@ionic/pro”: “2.0.4”, “capacitor-media”: “0.0.5”, “cordova-plugin-aes256-encryption”: “file:…/…/AES256/Capacitor-plugin/cordova-plugin-aes256-encryption”, “core-js”: “^2.5.4”, “rxjs”: “~6.5.1”, “tslib”: “^1.9.0”, “zone.js”: “~0.9.1”, “typescriopt”:“^3.5.4” }, “description”: “An Ionic project” }

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
danielsoglcommented, Sep 16, 2019

I resolved the issues by removing the web.ts file and ignored the tsc error inside the definitions.ts file.

// add this line to ignore tsc errors to fix the issue
// @ts-ignore
declare module '@capacitor/core' {
  interface PluginRegistry {
    FaceId: FaceIdPlugin;
  }
}

export interface FaceIdPlugin {
  isAvailable(): Promise<{ value: boolean }>;
  auth(options?: { reason?: string }): Promise<void>;
}

Check out my example repo: https://github.com/danielsogl/capacitor-face-id

0reactions
ionitron-bot[bot]commented, Nov 13, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

I am trying to register capacitor v3 plugins to Android but ...
Same problem here trying to register community plug-ins but cannot resolve the symbols in MainActivity.java What I can tell is that the package ......
Read more >
Troubleshooting Android Issues | Capacitor Documentation
On Android, this can happen if Capacitor doesn't find the plugins or can't inject its code into the WebView. First of all, make...
Read more >
Registering capacitor plugins in java with FragmentActivity
I'm working on a capacitor/electron project. I have written a plugin of my own and also I am using a few community plugins....
Read more >
How to Use Capacitor Plugins: Core & Others - Ionic.io
iOS Native Usage​. In order to use a Capacitor Core Plugin, you need to install the plugin as a dependency in your Podfile...
Read more >
@capacitor/push-notifications - npm
This plugin will use the following project variables (defined in your app's variables.gradle file):. $firebaseMessagingVersion version of com.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found