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

manage compatibility for android 11 and later #84

Open
kenfouo opened this issue Nov 25, 2024 · 1 comment
Open

manage compatibility for android 11 and later #84

kenfouo opened this issue Nov 25, 2024 · 1 comment

Comments

@kenfouo
Copy link

kenfouo commented Nov 25, 2024

Impossible de réaliser une impression avec un appareil Android 11 et versions ultérieures.

@kenfouo
Copy link
Author

kenfouo commented Nov 25, 2024

this fork offers a solution: https://github.com/kenfouo/Cordova-Plugin-Bluetooth-Printer.git

For Android 12, also use this script to request nearby device permissions:

 try {   
    var permissions = cordova.plugins.permissions;
    var bluetoothPermissions = [
        permissions.BLUETOOTH,
        permissions.BLUETOOTH_ADMIN,
        permissions.BLUETOOTH_SCAN,
        permissions.BLUETOOTH_CONNECT,
        permissions.ACCESS_FINE_LOCATION // Nécessaire pour le scan Bluetooth
    ];
    
    // Vérifier les permissions
    permissions.hasPermission(bluetoothPermissions, function(status) {
        if (!status.hasPermission) {
            // Demander les permissions
            permissions.requestPermissions(bluetoothPermissions, function(status) {
                if (status.hasPermission) {
                    console.log('Permissions accordées pour accéder aux appareils à proximité.');
                } else {
                    alert('Permissions refusées pour accéder aux appareils à proximité.');
                }
            }, function(error) {
                alert('Erreur lors de la demande de permissions: ' + JSON.stringify(error));
            });
        } else {
            console.log('Permissions déjà accordées pour accéder aux appareils à proximité.');              
        }                                                                        
    }, function(error) {
        alert('Erreur lors de la vérification des permissions: ' + JSON.stringify(error));
    });

} catch (error) {                                                        
    alert('error '+error);                                                         
}  

this code uses the plugin:
https://github.com/NeoLSN/cordova-plugin-android-permissions

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

1 participant