Reputation: 417
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!
Upvotes: 0
Views: 2531
Reputation: 149
I forgot to run npx cap update android
which solved my problem. Try also build and cap copy, or delete whole android and rebuild.
Upvotes: 0
Reputation: 302
I got the same issue and was freaking out. Push Notifications were working on the Emulator but not on a real device.
What helped was deleting the android folder. I made a fresh install cap add android
and I checked the diff using git.
In my case the following line of code in the app/build.gradle
had to be removed.
def enableProguardInReleaseBuilds = true
Upvotes: 0
Reputation: 417
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.
Upvotes: 1