I created an IOS Application to print Labels from a QL-820NMBc. Everything works exactly as intended code wise. However, the only way I can get the Label to finally Print out of the printer, is to Force Close the Mobile Application.
I am in no way a network GURU, but I feel that something is blocking the data from the Ipad to the printer to finalize the print. Just a guess.
Any help would be appreciated.
Me trying to print Me trying to print from custom app to iPad to brother QL820 printer
RCT_REMAP_METHOD(printImage, deviceInfo:(NSDictionary *)device printerUri: (NSString *)imageStr printImageOptions:(NSDictionary *)options resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
{
NSLog(@"Called the printImage function");
BRPtouchDeviceInfo *deviceInfo = [self deserializeDeviceInfo:device];
BRLMChannel *channel = [[BRLMChannel alloc] initWithWifiIPAddress:deviceInfo.strIPAddress];
BRLMPrinterDriverGenerateResult *driverGenerateResult = [BRLMPrinterDriverGenerator openChannel:channel];
if (driverGenerateResult.error.code != BRLMOpenChannelErrorCodeNoError ||
driverGenerateResult.driver == nil) {
NSLog(@"%@", @(driverGenerateResult.error.code));
return;
}
BRLMPrinterDriver *printerDriver = driverGenerateResult.driver;
BRLMPrinterModel model = [BRLMPrinterClassifier transferEnumFromString:deviceInfo.strModelName];
BRLMQLPrintSettings *qlSettings = [[BRLMQLPrintSettings alloc] initDefaultPrintSettingsWithPrinterModel:model];
qlSettings.autoCut = true;
if (options[@"autoCut"]) {
qlSettings.autoCut = [options[@"autoCut"] boolValue];
}
if (options[@"labelSize"]) {
qlSettings.labelSize = [options[@"labelSize"] intValue];
}
NSLog(@"Auto Cut: %@, Label Size: %@", options[@"autoCut"], options[@"labelSize"]);
NSURL *url = [NSURL URLWithString:imageStr];
BRLMPrintError *printError = [printerDriver printImageWithURL:url settings:qlSettings];
if (printError.code != BRLMPrintErrorCodeNoError) {
NSLog(@"Error - Print Image: %@", printError);
NSError* error = [NSError errorWithDomain:@"com.react-native-brother-printers.rn" code:1 userInfo:[NSDictionary dictionaryWithObject:printError.description forKey:NSLocalizedDescriptionKey]];
reject(PRINT_ERROR, @"There was an error trying to print the image", error);
resolve(Nil);
} else {
NSLog(@"Success - Print Image %@", [printerDriver getPrinterStatus].debugDescription);
resolve(Nil);
}
[printerDriver closeChannel]; //Suppose to close the channel and print, but label doesn't print until i close the app completely.
}