Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POST_NOTIFICATION not working #120

Open
gepi97 opened this issue Dec 28, 2022 · 15 comments
Open

POST_NOTIFICATION not working #120

gepi97 opened this issue Dec 28, 2022 · 15 comments

Comments

@gepi97
Copy link

gepi97 commented Dec 28, 2022

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); });

@mickjol
Copy link

mickjol commented Jan 10, 2023

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

@kotran88
Copy link

kotran88 commented Jan 17, 2023

same. not working
nothing show....

@lxbbright39
Copy link

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

@petercutting
Copy link

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?

@jcruz1289
Copy link

Add the required permission here:
image

@SimeonLukas
Copy link

Hithere,
Did you add

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

in the config.xml?

Greetings,
Simeon

@brandaopj
Copy link

i have the same problem:

image

@matodrobec
Copy link

matodrobec commented Apr 20, 2023

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);
                                    }
                                )
                        }
                    }
                );

@wtto00
Copy link

wtto00 commented May 12, 2023

Hithere, Did you add

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

in the config.xml?

Greetings, Simeon

save me! Thanks

@renofizaldy
Copy link

Hithere, Did you add

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

in the config.xml?

Greetings, Simeon

where is those config.xml file location ?

@SimeonLukas
Copy link

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

@matodrobec
Copy link

Hi,

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

@wtto00
Copy link

wtto00 commented Jun 6, 2023

Use this plugin cordova.plugins.diagnostic.

@matodrobec
Copy link

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();

@kenfouo
Copy link

kenfouo commented Oct 11, 2023

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" />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests