Ionic Capacitor "PushNotifications" plugin is not implemented on android

Hi all,
I have a problem when a try to request permissions with @capacitor/push-notifications plugin. I followed every step described in the README and I’m using Ionic and Vue 3.

This is the package.json:

...
    "@capacitor/android": "^3.2.0",
    "@capacitor/core": "^3.2.0",
    "@capacitor/push-notifications": "^1.0.3",
    "@ionic/vue": "^5.4.0"
...

This is the method that requests the permissions:

requestFCMPermissions(context: AuthContext) {
      PushNotifications.requestPermissions().then(result => {
        if (result.receive === "granted") {
          PushNotifications.register();
          ...
        } else {
          ...
        }
      });
      ...
}

Of course this does not work when a try by Web, but, when I assembly an APK and profile that, it responses me an error in console log:

 "PushNotifications" plugin is not implemented on android

Anyone know why? Thanks!

Did you remove init in your MainActivity.java file? In Capacitor 3, it is preferred to auto load plugins (Switch to automatic Android plugin loading).

Here is a related issue as well - https://github.com/ionic-team/capacitor-plugins/issues/535.

Here is a full guide of implementing Push Notifications if you haven’t seen it yet - Capacitor - build cross platform apps with the web.

1 Like

Now my MainActivity.java is

package <..>
import android.os.Bundle;

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

import java.util.ArrayList;

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

  }
}

but the error is always the same. Anyway I already followed that guide. Maybe any other version of some package?

Here you have a few things that can cause “plugin not implemented” problem.

If it’s none of those, if you provide a sample app I can take a look.

The other posters have covered the underlying concern better than I can, but is there any chance the proximate cause of your issue is the same as this thread?

I resolved my issue editing the MainActivity.java file:

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
      //...
      add(com.capacitorjs.plugins.pushnotifications.PushNotificationsPlugin.class);
    }});
  }
}

but this is not specified in any tutorial, so it could be something for my configuration.

Thanks all :slight_smile:

I resolved this issue by adding one line to file named ‘variables.gradle’ under ‘android’ folder
Please reference to