-[NFCTagReaderSession _connectTag:error:]:744 Error Domain =NFCError Code=2 «Отсутствует необходимое право»
UserInfo={NSLocalizedDescription=Отсутствует необходимое право
после подключения к карте.
Я трижды проверил сертификат подписи, чтобы включить опцию NFC на портале разработчиков Apple, и также удалил сертификат локально на своем компьютере, чтобы убедиться, что он использует последнюю версию.
Вот мой ViewController:
ViewController.h
Код: Выделить всё
#import
#import
@interface ViewController : UIViewController
@property (nonatomic, strong) NFCTagReaderSession *nfcSession;
@end
Код: Выделить всё
#import "ViewController.h"
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self startScanning];
}
- (void)startScanning {
self.nfcSession = [[NFCTagReaderSession alloc] initWithPollingOption:NFCPollingISO14443 delegate:self queue:nil];
self.nfcSession.alertMessage = @"Hold your iPhone near the NFC tag.";
[self.nfcSession beginSession];
}
- (void)tagReaderSession:(NFCTagReaderSession *)session didDetectTags:(NSArray *)tags {
id tag = [tags firstObject];
[session connectToTag:tag completionHandler:^(NSError * _Nullable error) {
if (error != nil) {
[session invalidateSessionWithErrorMessage:@"Connection failed"];
return;
}
id iso7816Tag = [tag asNFCISO7816Tag];
NSLog(@"Connected: %@", iso7816Tag);
// FOLLOWING APDU COMMAND CAN BE REMOVED, THE RESULT IS THE SAME
NSData *readCertCommandData = [NSData dataWithBytes:(unsigned char[]){0x00, 0xB0, 0x00, 0x00, 0x10} length:5];
NFCISO7816APDU *readCertCommand = [[NFCISO7816APDU alloc] initWithInstructionClass:0x00
instructionCode:0xB0
p1Parameter:0x00
p2Parameter:0x00
data:readCertCommandData
expectedResponseLength:256];
[iso7816Tag sendCommandAPDU:readCertCommand completionHandler:^(NSData *responseData, uint8_t sw1, uint8_t sw2, NSError * _Nullable error) {
if (error) {
NSLog(@"Error sending read certificate APDU: %@", error.localizedDescription);
[self.nfcSession invalidateSessionWithErrorMessage:@"Session invalidated"];
} else {
NSLog(@"Read Certificate Response Data: %@", responseData);
NSLog(@"Status Word: %02X %02X", sw1, sw2);
[self.nfcSession invalidateSession];
}
}];
}];
}
- (void)tagReaderSessionDidBecomeActive:(NFCTagReaderSession *)session {
NSLog(@"NFC session did become active");
}
- (void)tagReaderSession:(NFCTagReaderSession *)session didInvalidateWithError:(NSError *)error {
NSLog(@"NFC session did invalidate with error: %@", error.localizedDescription);
}
@end
Код: Выделить всё
com.apple.developer.nfc.readersession.formats
TAG
NDEF
Код: Выделить всё
NFCReaderUsageDescription
Need NFC to scan
com.apple.developer.nfc.readersession.iso7816.select-identifiers
A000000116071
Код: Выделить всё
NFC session did become active
-[NFCTagReaderSession _connectTag:error:]:744 Error Domain=NFCError Code=2 "Missing required entitlement"
UserInfo={NSLocalizedDescription=Missing required entitlement}
Connected:
Error sending read certificate APDU: Session invalidated
NFC session did invalidate with error: Session invalidated by user
Любая помощь приветствуется, я закончились идеи!
Подробнее здесь: https://stackoverflow.com/questions/785 ... 06-iso-dev
Мобильная версия