Closed ThonyFD closed 4 years ago
It’s requestPermission, without s
@jcesarmobile Something it's really wrong with this package, this method does not exist without s,
My bad @jcesarmobile, I only update capacitor-ios to 2, after update all capacitor to 2.0.0, all works as expected, thank's for the feedback
@ThonyFD that is not your bad, the documentation isn't accurate and waste of hours. There are tons of plugins I used with capacitor and all has documentation accuracy issues between the versions..
The default installation comes with the stable version and the documentation doesn't cover current stable version. Still I couldn't figure out how to use PushNotifications.requestPermissions with my current installation. I am not going to update the capacitor as after weeks, I already have mature application and can't risk it with upgrading capacitor.
So, how can I use PushNotifications.requestPermissions ? How to fix PushNotifications.requestPermissions is not a function
error?
Docs are for 2.x, they are not versioned. 2.x is the stable version.
I created my app 2 months ago and capacitor was setup with v1.4
And just after two months, its lots of functions and plugin compatibilities are changed and can’t find documentation for that
Seriously, I am disgusted by these instabilities between versions. What then is the annotation @ Deprecated if the functions must disappear without warning.
The problem is still current with 2.2.0.
With requestPermissions working in web, but on IOS : requestPermissions is not a function
I think some of the confusion comes from this:
The PushNotificationsPlugin
contains requestPermission
for requesting push notifications permissions:
But then there's a requestPermissions
on the Plugin
interface it extends, which all plugins have:
I can't discern why the push notifications plugin adds a new method.
I also have the problem with the Camera plugin
Today, I recommand #Flutter and I think that It's the future with #Google in background. Still the same goal : One Code for the both.
I think it is a typing issue. Followed worked for me.
(PushNotifications as any).requestPermission().then(result => { PushNotifications.register(); });
I am still stuggling.
I can't able to find the answer
error is PushNotifications.requestPermissions is not a function
I think it is a typing issue. Followed worked for me.
(PushNotifications as any).requestPermission().then(result => { PushNotifications.register(); });
This worked, thanks.
Make sure to update all capacitor related packages to the latest version. @capacitor/ios @capacitor/cli @capacitor/core @capacitor/android -> Only if you are developing for Android as well.
just use
PushNotifications.register();
not
(PushNotifications as any).requestPermission().then(result => { PushNotifications.register(); });
worked for me
Use PushNotifications.requestPermission() with no s.
You need to do this for iOS pns to work.
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.
Bug Report
Using @capacitor/ios 2.0.0 and trying to ask for push notification permission, an error appear in XCode console
` ⚡️ [log] - Initializing HomePage ⚡️ [error] - ERROR TypeError: PushNotifications.requestPermissions is not a function. (In 'PushNotifications.requestPermissions()', 'PushNotifications.requestPermissions' is undefined) ⚡️ [error] - ERROR CONTEXT [object Object]
`
Capacitor Version
npx cap doctor
output:`Latest Dependencies:
@capacitor/cli: 2.0.0
@capacitor/core: 2.0.0
@capacitor/android: 2.0.0
@capacitor/ios: 2.0.0
Installed Dependencies:
@capacitor/cli 1.5.1
@capacitor/android 1.5.1
@capacitor/ios 2.0.0
@capacitor/core 1.5.1
[success] Android looking great! 👌 Found 18 Capacitor plugins for ios: call-number (1.0.1) com.telerik.plugins.nativepagetransitions (0.6.5) cordova-plugin-actionsheet (2.3.3) cordova-plugin-camera (4.0.3) cordova-plugin-device (2.0.2) cordova-plugin-dialogs (2.0.1) cordova-plugin-geolocation (4.0.1) cordova-plugin-inappbrowser (3.0.0) cordova-plugin-ionic-keyboard (2.1.3) cordova-plugin-ionic-webview (4.0.1) cordova-plugin-screen-orientation (3.0.1) cordova-plugin-splashscreen (5.0.2) cordova-plugin-statusbar (2.4.2) cordova-plugin-whitelist (1.3.3) cordova-plugin-x-socialsharing (5.4.4) es6-promise-plugin (4.2.2) mx.ferreyra.callnumber (0.0.2) uk.co.workingedge.phonegap.plugin.launchnavigator (5.0.4) [success] iOS looking great! `
Affected Platform(s)
Current Behavior
iOS is not asking for push notifications permissions
Expected Behavior
iOS should ask for push notifications permissions
Sample Code or Sample Application Repo
Reproduction Steps
Other Technical Details
pod --version: 1.9.1
Other Information
This's my first capacitor project