Comments (5)
This has been working fine for us in a production app on real Android 13 devices. FWIW we're targeting 32 but have the same uses-permission set in config.xml. You perhaps might want to consider also sharing the code where you're calling the plugin to check or request this permission.
Our code is effectively using .checkPermission
(then .requestPermission
as appropriate) when the registration event fires for our push notification service. From memory, (so could be mistaken here,) the first time the app runs, you don't need permission so you likely won't get a dialog but the next time it fires you should.
from cordova-plugin-android-permissions.
Here is a bare bones example of what I'm doing.
const onRegistration = async (data) => {
console.log("onRegistration", data);
const perm = cordova.plugins.permissions;
const { hasPermission } = await new Promise((resolve, reject) => perm.checkPermission(perm.POST_NOTIFICATIONS, resolve, reject));
if (!hasPermission) {
const value = await new Promise((resolve, reject) => perm.requestPermissions([perm.POST_NOTIFICATIONS], resolve, reject));
console.log(value); // unknown error :(
}
}
const onDeviceReady = async () => {
document.getElementById('deviceready').classList.add('ready');
const push = PushNotification.init({
android: {}
});
push.on("registration", onRegistration);
push.on("notification", console.log);
}
document.addEventListener('deviceready', onDeviceReady, false);
This is using @havesource/cordova-plugin-push
as the notification plugin. Somehow I now get a dialog when starting the app the second time, but it closes itself after about a second. Any idea why that might be happening?
from cordova-plugin-android-permissions.
Probably not related but in case it helps... We're using the same plugin for our push notifications, but installing via cordova plugin add github:havesource/cordova-plugin-push
to make sure we get v4 instead of v3 via cordova plugin add @havesource/cordova-plugin-push
since v3 doesn't seem to properly support Android 12 or 13.
For the permissions plug in, might be worth checking you're using the latest v1.1.4, which was published a couple of weeks ago? That's the first version which supports the POST_NOTIFICATIONS permission. I imagine you are but always worth mentioning just in case.
Not sure what else to suggest looking at. Maybe experiment with targeting SDK 32, as I know that's working for us. We didn't go with 33 since it was too new. Didn't want to be bleeding edge. Does work for us on Android 13 devices such as a Pixel 6.
from cordova-plugin-android-permissions.
Another quick thought: We're using .requestPermission
(singular) - and didn't try a list with .requestPermissions
as you're doing here. As you're just looking to add a single permission, you could try changing that to .requestPermission
and see if that is a good workaround.
from cordova-plugin-android-permissions.
You're right, it's probably not related. Thanks for all the suggestions though. Closing this for now.
from cordova-plugin-android-permissions.
Related Issues (20)
- Fix bug HOT 1
- NFC permissions Not Working HOT 1
- Cordova Permissions not working Quasar HOT 1
- Any way to "Predict" if User will be prompted for Permission? HOT 3
- How can i check `MANAGE_EXTERNAL_STORAGE`(all file access) in android? HOT 7
- BLUETOOTH_CONNECT permission missing in permissions.js HOT 2
- Background Location permission issue HOT 5
- BLUETOOTH_CONNECT + BLUETOOTH_SCAN missing for Android +10 HOT 4
- plugins/cordova-plug…w/permissions.js:38 Uncaught SyntaxError: Unexpected token ':' HOT 1
- Support Android 13 (API 33) HOT 5
- BLUETOOTH_SCAN doesn't show confirm dialog to the user HOT 4
- uses-feature and camera request in Ionic 6 HOT 3
- POST_NOTIFICATION not working HOT 15
- Camera permission is not turned on?? HOT 1
- android build faild HOT 1
- Permissions not popping up HOT 10
- Storage permission not showing up HOT 2
- BSF Cordova Ecosystem Crowdfunding Plan HOT 2
- POST_NOTIFICATIONS don't work for Android 10 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cordova-plugin-android-permissions.