Open Yasa000 opened 1 year ago
react-native-thermal-printer@2.3.5
is working on Android 12.
react-native-thermal-printer@2.3.6
also works on Android 12.
But at first this is what I encountered using the latest version:
Error: UID 10476 / PID 3069 lacks permission android.permission.BLUETOOTH
And able to fix it through this mentioned thread. It's just probably device-specific I reckon.
can I use it by USB connection
This solution works for EXPO SDK 51
plugins: [ withCustomBluetoothPermission, ],
File contents :
const { withAndroidManifest } = require("@expo/config-plugins");
module.exports = function withCustomBluetoothPermission(config) { return withAndroidManifest(config, async (config) => { const manifest = config.modResults;
// Find existing permissions or add them if they don't exist
const permissions = [
{ name: "android.permission.BLUETOOTH", toolsRemoveMaxSdkVersion: true },
{ name: "android.permission.BLUETOOTH_ADMIN" },
{ name: "android.permission.ACCESS_FINE_LOCATION" },
{ name: "android.permission.BLUETOOTH_SCAN", minSdkVersion: 31 },
{ name: "android.permission.BLUETOOTH_CONNECT", minSdkVersion: 31 },
{ name: "android.permission.BLUETOOTH_ADVERTISE", minSdkVersion: 31 },
];
permissions.forEach((permission) => {
const existingPermission = manifest.manifest["uses-permission"].find(
(perm) => perm["$"]["android:name"] === permission.name
);
if (existingPermission) {
// Handle special cases like tools:remove="android:maxSdkVersion"
if (permission.toolsRemoveMaxSdkVersion) {
delete existingPermission["$"]["android:maxSdkVersion"];
existingPermission["$"]["tools:remove"] = "android:maxSdkVersion";
}
if (permission.minSdkVersion) {
existingPermission["$"]["tools:targetApi"] = permission.minSdkVersion;
}
} else {
// If the permission doesn't exist, add it
const newPermission = {
$: { "android:name": permission.name },
};
if (permission.toolsRemoveMaxSdkVersion) {
newPermission["$"]["tools:remove"] = "android:maxSdkVersion";
}
if (permission.minSdkVersion) {
newPermission["$"]["tools:targetApi"] = permission.minSdkVersion;
}
manifest.manifest["uses-permission"].push(newPermission);
}
});
return config;
}); };
react-native-thermal-printer@2.3.5
is working on Android 12.