cordova-plugin-android-permissions icon indicating copy to clipboard operation
cordova-plugin-android-permissions copied to clipboard

POST_NOTIFICATION not working

Open gepi97 opened this issue 2 years ago • 15 comments

When i request the new POST_NOTIFICATION permission on android platform, nothing be shown

Can someone help me ?

this is my code:

this.androidPermissions.checkPermission(this.androidPermissions.PERMISSION.POST_NOTIFICATIONS).then( result => { console.log('Has permission?', result.hasPermission) if (!result.hasPermission) this.androidPermissions.requestPermission(this.androidPermissions.PERMISSION.POST_NOTIFICATIONS); });

gepi97 avatar Dec 28 '22 16:12 gepi97

I had the same problem. OS: Android 13 Compile with SDK 32 or 33

When I made the "requestPermission" for POST_NOTIFICATIONS, I receive an error :

{
    error: "requestPermission"
    message: "Unknown error."
}

I try to request READ_CONTACTS and I receive success with { hasPermission: false } and nothing shown

mickjol avatar Jan 10 '23 20:01 mickjol

same. not working nothing show....

kotran88 avatar Jan 17 '23 10:01 kotran88

Hi, I have the same problem has anyone found a solution for this issue?

lxbbright39 avatar Feb 02 '23 11:02 lxbbright39

I have the same problem. The Allow permission modal is NOT shown for POST_NOTIFICATIONS

If I change permission to CAMERA then it works - the Allow permission modal IS shown. BUT not the first time. The app must be restarted for it to start working. Weird

    Android Target SDK: android-33
    Android Compile SDK: 33

is there an alternate plugin?

petercutting avatar Feb 10 '23 12:02 petercutting

Add the required permission here: image

jcruz1289 avatar Feb 21 '23 17:02 jcruz1289

Hithere, Did you add

<preference name="android-targetSdkVersion" value="33" />

in the config.xml?

Greetings, Simeon

SimeonLukas avatar Mar 06 '23 04:03 SimeonLukas

i have the same problem:

image

brandaopj avatar Apr 03 '23 20:04 brandaopj

I have same problem

<preference name="android-targetSdkVersion" value="33" />
 permissions
                .hasPermission(
                    permissions.POST_NOTIFICATION,
                    (status: any) => {
                        if (!status.hasPermission) {
                            permissions
                                .requestPermission(
                                    permissions.POST_NOTIFICATION,
                                    (data: any) => {
                                        console.log('PERMISIONS', data);
                                        result.resolve(true);
                                    },
                                    () => {
                                        result.reject(false);
                                    }
                                )
                        }
                    }
                );

matodrobec avatar Apr 20 '23 11:04 matodrobec

Hithere, Did you add

<preference name="android-targetSdkVersion" value="33" />

in the config.xml?

Greetings, Simeon

save me! Thanks

wtto00 avatar May 12 '23 03:05 wtto00

Hithere, Did you add

<preference name="android-targetSdkVersion" value="33" />

in the config.xml?

Greetings, Simeon

where is those config.xml file location ?

renofizaldy avatar May 23 '23 10:05 renofizaldy

Hithere, Did you add <preference name="android-targetSdkVersion" value="33" /> in the config.xml? Greetings, Simeon

where is those config.xml file location ?

For projects created with the Cordova CLI (described in The Command-Line Interface), this file can be found in the top-level directory:

app/config.xml

Link to Cordova Documentation

Hope this helps.

Greetings

SimeonLukas avatar May 24 '23 08:05 SimeonLukas

Hi,

permissions.POST_NOTIFICATION is still not working. I am using cordova android 11 and the persmission window have not shown.

matodrobec avatar Jun 06 '23 17:06 matodrobec

Use this plugin cordova.plugins.diagnostic.

wtto00 avatar Jun 06 '23 17:06 wtto00

Hi @wtto00

thx for advice and I tested it. I found usefull these two methods isRemoteNotificationsEnabled and switchToNotificationSettings

   let diagnostic = (cordova.plugins as any)?.diagnostic;

    diagnostic.isRemoteNotificationsEnabled((enabled) => {
      console.log("Remote notifications are " + (enabled ? "enabled" : "disabled"));
    }, (error) => {
      console.error("The following error occurred: " + error);
    });

    diagnostic.switchToNotificationSettings();

matodrobec avatar Sep 14 '23 13:09 matodrobec

This is what worked for me with the plugin .

    var permissions = cordova.plugins.permissions;
    permissions 
    .hasPermission(
        permissions.POST_NOTIFICATIONS,
        (status) => {
            if (!status.hasPermission) {
                permissions
                    .requestPermission(
                        permissions.POST_NOTIFICATIONS,
                        (data) => {
                            alert('PERMISIONS: ' + JSON.stringify(data));
                        },
                        (err) => {
                            alert('PERMISIONS: ' + JSON.stringify(err));
                        }
                    )
            }
        }
    );

add this to the manifest:

<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/> <uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />

kenfouo avatar Oct 11 '23 14:10 kenfouo