react-native-nfc-manager 3.13.4 → 3.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/ios/NfcManager.m CHANGED
@@ -534,141 +534,6 @@ RCT_EXPORT_METHOD(queryNDEFStatus:(nonnull RCTResponseSenderBlock)callback)
534
534
  }
535
535
  }
536
536
 
537
-
538
-
539
- RCT_EXPORT_METHOD(sendMifareCommand:(NSArray *)bytes callback: (nonnull RCTResponseSenderBlock)callback)
540
- {
541
- if (@available(iOS 13.0, *)) {
542
- if (tagSession != nil) {
543
- if (tagSession.connectedTag) {
544
- id<NFCMiFareTag> mifareTag = [tagSession.connectedTag asNFCMiFareTag];
545
- NSData *data = arrayToData(bytes);
546
- NSLog(@"input bytes: %@", getHexString(data));
547
- if (mifareTag) {
548
- [mifareTag sendMiFareCommand:data
549
- completionHandler:^(NSData *response, NSError *error) {
550
- if (error) {
551
- callback(@[getErrorMessage(error), [NSNull null]]);
552
- } else {
553
- callback(@[[NSNull null], dataToArray(response)]);
554
- }
555
- }];
556
- return;
557
- } else {
558
- callback(@[@"not a mifare tag", [NSNull null]]);
559
- }
560
- }
561
- callback(@[@"Not connected", [NSNull null]]);
562
- } else {
563
- callback(@[@"Not even registered", [NSNull null]]);
564
- }
565
- } else {
566
- callback(@[@"Not support in this device", [NSNull null]]);
567
- }
568
- }
569
-
570
- RCT_EXPORT_METHOD(sendFelicaCommand:(NSArray *)bytes callback: (nonnull RCTResponseSenderBlock)callback)
571
- {
572
- if (@available(iOS 13.0, *)) {
573
- if (tagSession != nil) {
574
- if (tagSession.connectedTag) {
575
- id<NFCFeliCaTag> felicaTag = [tagSession.connectedTag asNFCFeliCaTag];
576
- NSData *data = arrayToData(bytes);
577
- NSLog(@"input bytes: %@", getHexString(data));
578
- if (felicaTag) {
579
- [felicaTag sendFeliCaCommandPacket:data
580
- completionHandler:^(NSData *response, NSError *error) {
581
- if (error) {
582
- callback(@[getErrorMessage(error), [NSNull null]]);
583
- } else {
584
- callback(@[[NSNull null], dataToArray(response)]);
585
- }
586
- }];
587
- return;
588
- } else {
589
- callback(@[@"not a felica tag", [NSNull null]]);
590
- }
591
- }
592
- callback(@[@"Not connected", [NSNull null]]);
593
- } else {
594
- callback(@[@"Not even registered", [NSNull null]]);
595
- }
596
- } else {
597
- callback(@[@"Not support in this device", [NSNull null]]);
598
- }
599
- }
600
-
601
- RCT_EXPORT_METHOD(sendCommandAPDUBytes:(NSArray *)bytes callback: (nonnull RCTResponseSenderBlock)callback)
602
- {
603
- if (@available(iOS 13.0, *)) {
604
- if (tagSession != nil) {
605
- if (tagSession.connectedTag) {
606
- id<NFCISO7816Tag> iso7816Tag = [tagSession.connectedTag asNFCISO7816Tag];
607
- NSData *data = arrayToData(bytes);
608
- NFCISO7816APDU *apdu = [[NFCISO7816APDU alloc] initWithData:data];
609
- if (iso7816Tag) {
610
- [iso7816Tag sendCommandAPDU:apdu completionHandler:^(NSData* response, uint8_t sw1, uint8_t sw2, NSError* error) {
611
- if (error) {
612
- callback(@[getErrorMessage(error), [NSNull null]]);
613
- } else {
614
- callback(@[[NSNull null], dataToArray(response), [NSNumber numberWithInt:sw1], [NSNumber numberWithInt:sw2]]);
615
- }
616
- }];
617
- return;
618
- } else {
619
- callback(@[@"not an iso7816 tag", [NSNull null]]);
620
- }
621
- }
622
- callback(@[@"Not connected", [NSNull null]]);
623
- } else {
624
- callback(@[@"Not even registered", [NSNull null]]);
625
- }
626
- } else {
627
- callback(@[@"Not support in this device", [NSNull null]]);
628
- }
629
- }
630
-
631
- RCT_EXPORT_METHOD(sendCommandAPDU:(NSDictionary *)apduData callback: (nonnull RCTResponseSenderBlock)callback)
632
- {
633
- if (@available(iOS 13.0, *)) {
634
- if (tagSession != nil) {
635
- if (tagSession.connectedTag) {
636
- id<NFCISO7816Tag> iso7816Tag = [tagSession.connectedTag asNFCISO7816Tag];
637
- NSNumber *cla = [apduData objectForKey:@"cla"];
638
- NSNumber *ins = [apduData objectForKey:@"ins"];
639
- NSNumber *p1 = [apduData objectForKey:@"p1"];
640
- NSNumber *p2 = [apduData objectForKey:@"p2"];
641
- NSArray *dataArray = [apduData objectForKey:@"data"];
642
- NSData *data = arrayToData(dataArray);
643
- NSNumber *le = [apduData objectForKey:@"le"];
644
-
645
- /*
646
- NFCISO7816APDU *apdu = [[NFCISO7816APDU alloc] initWithInstructionClass:0 instructionCode:0x84 p1Parameter:0 p2Parameter:0 data:[[NSData alloc] init] expectedResponseLength:8]
647
- */
648
-
649
- NFCISO7816APDU *apdu = [[NFCISO7816APDU alloc] initWithInstructionClass:[cla unsignedCharValue] instructionCode:[ins unsignedCharValue] p1Parameter:[p1 unsignedCharValue] p2Parameter:[p2 unsignedCharValue] data:data expectedResponseLength:[le integerValue]];
650
- if (iso7816Tag) {
651
- [iso7816Tag sendCommandAPDU:apdu completionHandler:^(NSData* response, uint8_t sw1, uint8_t sw2, NSError* error) {
652
- if (error) {
653
- callback(@[getErrorMessage(error), [NSNull null]]);
654
- } else {
655
- callback(@[[NSNull null], dataToArray(response), [NSNumber numberWithInt:sw1], [NSNumber numberWithInt:sw2]]);
656
- }
657
- }];
658
- return;
659
- } else {
660
- callback(@[@"not an iso7816 tag", [NSNull null]]);
661
- }
662
- }
663
- callback(@[@"Not connected", [NSNull null]]);
664
- } else {
665
- callback(@[@"Not even registered", [NSNull null]]);
666
- }
667
- } else {
668
- callback(@[@"Not support in this device", [NSNull null]]);
669
- }
670
- }
671
-
672
537
  RCT_EXPORT_METHOD(setAlertMessage: (NSString *)alertMessage callback:(nonnull RCTResponseSenderBlock)callback)
673
538
  {
674
539
  if (@available(iOS 11.0, *)) {
@@ -704,557 +569,5 @@ RCT_EXPORT_METHOD(isTagSessionAvailable:(nonnull RCTResponseSenderBlock)callback
704
569
  }
705
570
  }
706
571
 
707
- // ---------------------------
708
- // iso15693
709
- // ---------------------------
710
- RCT_EXPORT_METHOD(iso15693_getSystemInfo:(nonnull NSNumber *)flags callback:(nonnull RCTResponseSenderBlock)callback)
711
- {
712
- if (@available(iOS 14.0, *)) {
713
- if (!tagSession || !tagSession.connectedTag) {
714
- callback(@[@"Not connected", [NSNull null]]);
715
- return;
716
- }
717
-
718
- id<NFCISO15693Tag> tag = [tagSession.connectedTag asNFCISO15693Tag];
719
- if (!tag) {
720
- callback(@[@"incorrect tag type", [NSNull null]]);
721
- return;
722
- }
723
-
724
- RequestFlag rFlag = [flags unsignedIntValue];
725
-
726
- [tag getSystemInfoWithRequestFlag:rFlag completionHandler:
727
- ^(NSInteger dsfid, NSInteger afi, NSInteger blockSize, NSInteger blockCount, NSInteger icReference, NSError *error) {
728
- if (error) {
729
- callback(@[getErrorMessage(error), [NSNull null]]);
730
- return;
731
- }
732
-
733
- callback(@[[NSNull null], @{
734
- @"dsfid": @(dsfid),
735
- @"afi": @(afi),
736
- @"blockSize": @(blockSize),
737
- @"blockCount": @(blockCount),
738
- @"icReference": @(icReference)
739
- }]);
740
- }];
741
- } else {
742
- callback(@[@"Not support in this device", [NSNull null]]);
743
- }
744
- }
745
-
746
- RCT_EXPORT_METHOD(iso15693_readSingleBlock:(NSDictionary *)options callback:(nonnull RCTResponseSenderBlock)callback)
747
- {
748
- if (@available(iOS 14.0, *)) {
749
- if (!tagSession || !tagSession.connectedTag) {
750
- callback(@[@"Not connected", [NSNull null]]);
751
- return;
752
- }
753
-
754
- id<NFCISO15693Tag> tag = [tagSession.connectedTag asNFCISO15693Tag];
755
- if (!tag) {
756
- callback(@[@"incorrect tag type", [NSNull null]]);
757
- return;
758
- }
759
-
760
- RequestFlag flags = [[options objectForKey:@"flags"] unsignedIntValue];
761
- uint8_t blockNumber = [[options objectForKey:@"blockNumber"] unsignedIntValue];
762
-
763
- [tag readSingleBlockWithRequestFlags:flags
764
- blockNumber:blockNumber
765
- completionHandler:^(NSData *resp, NSError *error) {
766
- if (error) {
767
- callback(@[getErrorMessage(error), [NSNull null]]);
768
- return;
769
- }
770
-
771
- callback(@[[NSNull null], dataToArray(resp)]);
772
- }];
773
- } else {
774
- callback(@[@"Not support in this device", [NSNull null]]);
775
- }
776
- }
777
-
778
- RCT_EXPORT_METHOD(iso15693_readMultipleBlocks:(NSDictionary *)options callback:(nonnull RCTResponseSenderBlock)callback)
779
- {
780
- if (@available(iOS 14.0, *)) {
781
- if (!tagSession || !tagSession.connectedTag) {
782
- callback(@[@"Not connected", [NSNull null]]);
783
- return;
784
- }
785
-
786
- id<NFCISO15693Tag> tag = [tagSession.connectedTag asNFCISO15693Tag];
787
- if (!tag) {
788
- callback(@[@"incorrect tag type", [NSNull null]]);
789
- return;
790
- }
791
-
792
- RequestFlag flags = [[options objectForKey:@"flags"] unsignedIntValue];
793
- NSRange blockRange = NSMakeRange(
794
- [[options objectForKey:@"blockNumber"] unsignedIntValue],
795
- [[options objectForKey:@"blockCount"] unsignedIntValue]
796
- );
797
-
798
- [tag readMultipleBlocksWithRequestFlags:flags
799
- blockRange:blockRange
800
- completionHandler:^(NSArray<NSData *> *dataBlocks, NSError *error) {
801
- if (error) {
802
- callback(@[getErrorMessage(error), [NSNull null]]);
803
- return;
804
- }
805
- NSMutableArray *blocks = [NSMutableArray arrayWithCapacity:[dataBlocks count]];
806
- [dataBlocks enumerateObjectsUsingBlock:^(NSData *blockData, NSUInteger idx, BOOL *stop) {
807
- [blocks addObject:dataToArray(blockData)];
808
- }];
809
- callback(@[[NSNull null], blocks]);
810
- }];
811
- } else {
812
- callback(@[@"Not support in this device", [NSNull null]]);
813
- }
814
- }
815
-
816
- RCT_EXPORT_METHOD(iso15693_writeSingleBlock:(NSDictionary *)options callback:(nonnull RCTResponseSenderBlock)callback)
817
- {
818
- if (@available(iOS 14.0, *)) {
819
- if (!tagSession || !tagSession.connectedTag) {
820
- callback(@[@"Not connected", [NSNull null]]);
821
- return;
822
- }
823
-
824
- id<NFCISO15693Tag> tag = [tagSession.connectedTag asNFCISO15693Tag];
825
- if (!tag) {
826
- callback(@[@"incorrect tag type", [NSNull null]]);
827
- return;
828
- }
829
-
830
- RequestFlag flags = [[options objectForKey:@"flags"] unsignedIntValue];
831
- uint8_t blockNumber = [[options objectForKey:@"blockNumber"] unsignedIntValue];
832
- NSData *dataBlock = arrayToData([options mutableArrayValueForKey:@"dataBlock"]);
833
-
834
- [tag writeSingleBlockWithRequestFlags:flags
835
- blockNumber:blockNumber
836
- dataBlock:dataBlock
837
- completionHandler:^(NSError *error) {
838
- if (error) {
839
- callback(@[getErrorMessage(error), [NSNull null]]);
840
- return;
841
- }
842
-
843
- callback(@[]);
844
- }];
845
- } else {
846
- callback(@[@"Not support in this device", [NSNull null]]);
847
- }
848
- }
849
-
850
- RCT_EXPORT_METHOD(iso15693_lockBlock:(NSDictionary *)options callback:(nonnull RCTResponseSenderBlock)callback)
851
- {
852
- if (@available(iOS 14.0, *)) {
853
- if (!tagSession || !tagSession.connectedTag) {
854
- callback(@[@"Not connected", [NSNull null]]);
855
- return;
856
- }
857
-
858
- id<NFCISO15693Tag> tag = [tagSession.connectedTag asNFCISO15693Tag];
859
- if (!tag) {
860
- callback(@[@"incorrect tag type", [NSNull null]]);
861
- return;
862
- }
863
-
864
- RequestFlag flags = [[options objectForKey:@"flags"] unsignedIntValue];
865
- uint8_t blockNumber = [[options objectForKey:@"blockNumber"] unsignedIntValue];
866
-
867
- [tag lockBlockWithRequestFlags:flags
868
- blockNumber:blockNumber
869
- completionHandler:^(NSError *error) {
870
- if (error) {
871
- callback(@[getErrorMessage(error), [NSNull null]]);
872
- return;
873
- }
874
-
875
- callback(@[]);
876
- }];
877
- } else {
878
- callback(@[@"Not support in this device", [NSNull null]]);
879
- }
880
- }
881
-
882
- RCT_EXPORT_METHOD(iso15693_writeAFI:(NSDictionary *)options callback:(nonnull RCTResponseSenderBlock)callback)
883
- {
884
- if (@available(iOS 14.0, *)) {
885
- if (!tagSession || !tagSession.connectedTag) {
886
- callback(@[@"Not connected", [NSNull null]]);
887
- return;
888
- }
889
-
890
- id<NFCISO15693Tag> tag = [tagSession.connectedTag asNFCISO15693Tag];
891
- if (!tag) {
892
- callback(@[@"incorrect tag type", [NSNull null]]);
893
- return;
894
- }
895
-
896
- RequestFlag flags = [[options objectForKey:@"flags"] unsignedIntValue];
897
- uint8_t afi = [[options objectForKey:@"afi"] unsignedIntValue];
898
-
899
- [tag writeAFIWithRequestFlag:flags
900
- afi:afi
901
- completionHandler:^(NSError *error) {
902
- if (error) {
903
- callback(@[getErrorMessage(error), [NSNull null]]);
904
- return;
905
- }
906
-
907
- callback(@[]);
908
- }];
909
- } else {
910
- callback(@[@"Not support in this device", [NSNull null]]);
911
- }
912
- }
913
-
914
- RCT_EXPORT_METHOD(iso15693_lockAFI:(NSDictionary *)options callback:(nonnull RCTResponseSenderBlock)callback)
915
- {
916
- if (@available(iOS 14.0, *)) {
917
- if (!tagSession || !tagSession.connectedTag) {
918
- callback(@[@"Not connected", [NSNull null]]);
919
- return;
920
- }
921
-
922
- id<NFCISO15693Tag> tag = [tagSession.connectedTag asNFCISO15693Tag];
923
- if (!tag) {
924
- callback(@[@"incorrect tag type", [NSNull null]]);
925
- return;
926
- }
927
-
928
- RequestFlag flags = [[options objectForKey:@"flags"] unsignedIntValue];
929
-
930
- [tag lockAFIWithRequestFlag:flags
931
- completionHandler:^(NSError *error) {
932
- if (error) {
933
- callback(@[getErrorMessage(error), [NSNull null]]);
934
- return;
935
- }
936
-
937
- callback(@[]);
938
- }];
939
- } else {
940
- callback(@[@"Not support in this device", [NSNull null]]);
941
- }
942
- }
943
-
944
- RCT_EXPORT_METHOD(iso15693_writeDSFID:(NSDictionary *)options callback:(nonnull RCTResponseSenderBlock)callback)
945
- {
946
- if (@available(iOS 14.0, *)) {
947
- if (!tagSession || !tagSession.connectedTag) {
948
- callback(@[@"Not connected", [NSNull null]]);
949
- return;
950
- }
951
-
952
- id<NFCISO15693Tag> tag = [tagSession.connectedTag asNFCISO15693Tag];
953
- if (!tag) {
954
- callback(@[@"incorrect tag type", [NSNull null]]);
955
- return;
956
- }
957
-
958
- RequestFlag flags = [[options objectForKey:@"flags"] unsignedIntValue];
959
- uint8_t dsfid = [[options objectForKey:@"dsfid"] unsignedIntValue];
960
-
961
- [tag writeDSFIDWithRequestFlag:flags
962
- dsfid:dsfid
963
- completionHandler:^(NSError *error) {
964
- if (error) {
965
- callback(@[getErrorMessage(error), [NSNull null]]);
966
- return;
967
- }
968
-
969
- callback(@[]);
970
- }];
971
- } else {
972
- callback(@[@"Not support in this device", [NSNull null]]);
973
- }
974
- }
975
-
976
- RCT_EXPORT_METHOD(iso15693_lockDSFID:(NSDictionary *)options callback:(nonnull RCTResponseSenderBlock)callback)
977
- {
978
- if (@available(iOS 14.0, *)) {
979
- if (!tagSession || !tagSession.connectedTag) {
980
- callback(@[@"Not connected", [NSNull null]]);
981
- return;
982
- }
983
-
984
- id<NFCISO15693Tag> tag = [tagSession.connectedTag asNFCISO15693Tag];
985
- if (!tag) {
986
- callback(@[@"incorrect tag type", [NSNull null]]);
987
- return;
988
- }
989
-
990
- RequestFlag flags = [[options objectForKey:@"flags"] unsignedIntValue];
991
-
992
- // notice thie method name, DSFID -> DFSID, seems to be a typo in Core NFC
993
- [tag lockDFSIDWithRequestFlag:flags
994
- completionHandler:^(NSError *error) {
995
- if (error) {
996
- callback(@[getErrorMessage(error), [NSNull null]]);
997
- return;
998
- }
999
-
1000
- callback(@[]);
1001
- }];
1002
- } else {
1003
- callback(@[@"Not support in this device", [NSNull null]]);
1004
- }
1005
- }
1006
-
1007
- RCT_EXPORT_METHOD(iso15693_resetToReady:(NSDictionary *)options callback:(nonnull RCTResponseSenderBlock)callback)
1008
- {
1009
- if (@available(iOS 14.0, *)) {
1010
- if (!tagSession || !tagSession.connectedTag) {
1011
- callback(@[@"Not connected", [NSNull null]]);
1012
- return;
1013
- }
1014
-
1015
- id<NFCISO15693Tag> tag = [tagSession.connectedTag asNFCISO15693Tag];
1016
- if (!tag) {
1017
- callback(@[@"incorrect tag type", [NSNull null]]);
1018
- return;
1019
- }
1020
-
1021
- RequestFlag flags = [[options objectForKey:@"flags"] unsignedIntValue];
1022
-
1023
- [tag resetToReadyWithRequestFlags:flags
1024
- completionHandler:^(NSError *error) {
1025
- if (error) {
1026
- callback(@[getErrorMessage(error), [NSNull null]]);
1027
- return;
1028
- }
1029
-
1030
- callback(@[]);
1031
- }];
1032
- } else {
1033
- callback(@[@"Not support in this device", [NSNull null]]);
1034
- }
1035
- }
1036
-
1037
- RCT_EXPORT_METHOD(iso15693_select:(NSDictionary *)options callback:(nonnull RCTResponseSenderBlock)callback)
1038
- {
1039
- if (@available(iOS 14.0, *)) {
1040
- if (!tagSession || !tagSession.connectedTag) {
1041
- callback(@[@"Not connected", [NSNull null]]);
1042
- return;
1043
- }
1044
-
1045
- id<NFCISO15693Tag> tag = [tagSession.connectedTag asNFCISO15693Tag];
1046
- if (!tag) {
1047
- callback(@[@"incorrect tag type", [NSNull null]]);
1048
- return;
1049
- }
1050
-
1051
- RequestFlag flags = [[options objectForKey:@"flags"] unsignedIntValue];
1052
-
1053
- [tag selectWithRequestFlags:flags
1054
- completionHandler:^(NSError *error) {
1055
- if (error) {
1056
- callback(@[getErrorMessage(error), [NSNull null]]);
1057
- return;
1058
- }
1059
-
1060
- callback(@[]);
1061
- }];
1062
- } else {
1063
- callback(@[@"Not support in this device", [NSNull null]]);
1064
- }
1065
- }
1066
-
1067
- RCT_EXPORT_METHOD(iso15693_stayQuiet:(nonnull RCTResponseSenderBlock)callback)
1068
- {
1069
- if (@available(iOS 14.0, *)) {
1070
- if (!tagSession || !tagSession.connectedTag) {
1071
- callback(@[@"Not connected", [NSNull null]]);
1072
- return;
1073
- }
1074
-
1075
- id<NFCISO15693Tag> tag = [tagSession.connectedTag asNFCISO15693Tag];
1076
- if (!tag) {
1077
- callback(@[@"incorrect tag type", [NSNull null]]);
1078
- return;
1079
- }
1080
-
1081
- [tag stayQuietWithCompletionHandler:^(NSError *error) {
1082
- if (error) {
1083
- callback(@[getErrorMessage(error), [NSNull null]]);
1084
- return;
1085
- }
1086
-
1087
- callback(@[]);
1088
- }];
1089
- } else {
1090
- callback(@[@"Not support in this device", [NSNull null]]);
1091
- }
1092
- }
1093
-
1094
- RCT_EXPORT_METHOD(iso15693_customCommand:(NSDictionary *)options callback:(nonnull RCTResponseSenderBlock)callback)
1095
- {
1096
- if (@available(iOS 14.0, *)) {
1097
- if (!tagSession || !tagSession.connectedTag) {
1098
- callback(@[@"Not connected", [NSNull null]]);
1099
- return;
1100
- }
1101
-
1102
- id<NFCISO15693Tag> tag = [tagSession.connectedTag asNFCISO15693Tag];
1103
- if (!tag) {
1104
- callback(@[@"incorrect tag type", [NSNull null]]);
1105
- return;
1106
- }
1107
-
1108
- RequestFlag flags = [[options objectForKey:@"flags"] unsignedIntValue];
1109
- NSInteger customCommandCode = [[options objectForKey:@"customCommandCode"] integerValue];
1110
- NSData *customRequestParameters = arrayToData([options mutableArrayValueForKey:@"customRequestParameters"]);
1111
-
1112
- [tag customCommandWithRequestFlag:flags
1113
- customCommandCode: customCommandCode
1114
- customRequestParameters: customRequestParameters
1115
- completionHandler:^(NSData *resp, NSError *error) {
1116
- if (error) {
1117
- callback(@[getErrorMessage(error), [NSNull null]]);
1118
- return;
1119
- }
1120
-
1121
- callback(@[[NSNull null], dataToArray(resp)]);
1122
- }];
1123
- } else {
1124
- callback(@[@"Not support in this device", [NSNull null]]);
1125
- }
1126
- }
1127
-
1128
- RCT_EXPORT_METHOD(iso15693_sendRequest:(NSDictionary *)options callback:(nonnull RCTResponseSenderBlock)callback)
1129
- {
1130
- if (@available(iOS 14.0, *)) {
1131
- if (!tagSession || !tagSession.connectedTag) {
1132
- callback(@[@"Not connected", [NSNull null]]);
1133
- return;
1134
- }
1135
-
1136
- id<NFCISO15693Tag> tag = [tagSession.connectedTag asNFCISO15693Tag];
1137
- if (!tag) {
1138
- callback(@[@"incorrect tag type", [NSNull null]]);
1139
- return;
1140
- }
1141
-
1142
- NSInteger flags = [[options objectForKey:@"flags"] integerValue];
1143
- NSInteger commandCode = [[options objectForKey:@"commandCode"] integerValue];
1144
- NSData *data = arrayToData([options mutableArrayValueForKey:@"data"]);
1145
-
1146
- [tag sendRequestWithFlag:flags
1147
- commandCode:commandCode
1148
- data:data
1149
- completionHandler:^(NFCISO15693ResponseFlag responseFlag, NSData *resp, NSError *error) {
1150
- if (error) {
1151
- callback(@[getErrorMessage(error), [NSNull null]]);
1152
- return;
1153
- }
1154
- callback(@[[NSNull null], [NSNumber numberWithLong:responseFlag], dataToArray(resp)]);
1155
- }];
1156
- } else {
1157
- callback(@[@"Not support in this device", [NSNull null]]);
1158
- }
1159
- }
1160
-
1161
- RCT_EXPORT_METHOD(iso15693_extendedReadSingleBlock:(NSDictionary *)options callback:(nonnull RCTResponseSenderBlock)callback)
1162
- {
1163
- if (@available(iOS 14.0, *)) {
1164
- if (!tagSession || !tagSession.connectedTag) {
1165
- callback(@[@"Not connected", [NSNull null]]);
1166
- return;
1167
- }
1168
-
1169
- id<NFCISO15693Tag> tag = [tagSession.connectedTag asNFCISO15693Tag];
1170
- if (!tag) {
1171
- callback(@[@"incorrect tag type", [NSNull null]]);
1172
- return;
1173
- }
1174
-
1175
- RequestFlag flags = [[options objectForKey:@"flags"] unsignedIntValue];
1176
- uint16_t blockNumber = [[options objectForKey:@"blockNumber"] unsignedIntValue];
1177
-
1178
- [tag extendedReadSingleBlockWithRequestFlags:flags
1179
- blockNumber:blockNumber
1180
- completionHandler:^(NSData *resp, NSError *error) {
1181
- if (error) {
1182
- callback(@[getErrorMessage(error), [NSNull null]]);
1183
- return;
1184
- }
1185
-
1186
- callback(@[[NSNull null], dataToArray(resp)]);
1187
- }];
1188
- } else {
1189
- callback(@[@"Not support in this device", [NSNull null]]);
1190
- }
1191
- }
1192
-
1193
- RCT_EXPORT_METHOD(iso15693_extendedWriteSingleBlock:(NSDictionary *)options callback:(nonnull RCTResponseSenderBlock)callback)
1194
- {
1195
- if (@available(iOS 14.0, *)) {
1196
- if (!tagSession || !tagSession.connectedTag) {
1197
- callback(@[@"Not connected", [NSNull null]]);
1198
- return;
1199
- }
1200
-
1201
- id<NFCISO15693Tag> tag = [tagSession.connectedTag asNFCISO15693Tag];
1202
- if (!tag) {
1203
- callback(@[@"incorrect tag type", [NSNull null]]);
1204
- return;
1205
- }
1206
-
1207
- RequestFlag flags = [[options objectForKey:@"flags"] unsignedIntValue];
1208
- uint16_t blockNumber = [[options objectForKey:@"blockNumber"] unsignedIntValue];
1209
- NSData *dataBlock = arrayToData([options mutableArrayValueForKey:@"dataBlock"]);
1210
-
1211
- [tag extendedWriteSingleBlockWithRequestFlags:flags
1212
- blockNumber:blockNumber
1213
- dataBlock: dataBlock
1214
- completionHandler:^(NSError *error) {
1215
- if (error) {
1216
- callback(@[getErrorMessage(error), [NSNull null]]);
1217
- return;
1218
- }
1219
-
1220
- callback(@[]);
1221
- }];
1222
- } else {
1223
- callback(@[@"Not support in this device", [NSNull null]]);
1224
- }
1225
- }
1226
-
1227
- RCT_EXPORT_METHOD(iso15693_extendedLockBlock:(NSDictionary *)options callback:(nonnull RCTResponseSenderBlock)callback)
1228
- {
1229
- if (@available(iOS 14.0, *)) {
1230
- if (!tagSession || !tagSession.connectedTag) {
1231
- callback(@[@"Not connected", [NSNull null]]);
1232
- return;
1233
- }
1234
-
1235
- id<NFCISO15693Tag> tag = [tagSession.connectedTag asNFCISO15693Tag];
1236
- if (!tag) {
1237
- callback(@[@"incorrect tag type", [NSNull null]]);
1238
- return;
1239
- }
1240
-
1241
- RequestFlag flags = [[options objectForKey:@"flags"] unsignedIntValue];
1242
- uint16_t blockNumber = [[options objectForKey:@"blockNumber"] unsignedIntValue];
1243
-
1244
- [tag extendedLockBlockWithRequestFlags:flags
1245
- blockNumber:blockNumber
1246
- completionHandler:^(NSError *error) {
1247
- if (error) {
1248
- callback(@[getErrorMessage(error), [NSNull null]]);
1249
- return;
1250
- }
1251
-
1252
- callback(@[]);
1253
- }];
1254
- } else {
1255
- callback(@[@"Not support in this device", [NSNull null]]);
1256
- }
1257
- }
1258
-
1259
572
  @end
1260
573