在目标C阅读NFC扫描后,我很难重定向到网页。
这是我的代码
- (void) readerSession:(nonnull NFCNDEFReaderSession *)session didDetectNDEFs:(nonnull NSArray<NFCNDEFMessage *> *)messages {
for (NFCNDEFMessage *message in messages) {
for (NFCNDEFPayload *payload in message.records) {
NSLog(@"Payload data:%@",payload.payload);
}
}
}
答案 0 :(得分:1)
我使用VYNFC套件获得了解决方案,
https://github.com/vinceyuan/VYNFCKit
if ([parsedPayload isKindOfClass:[VYNFCNDEFURIPayload class]]) {
text = @"[URI payload]\n";
text = [NSString stringWithFormat:@"%@%@", text, ((VYNFCNDEFURIPayload *)parsedPayload).URIString];
urlString = ((VYNFCNDEFURIPayload *)parsedPayload).URIString;
NSURL *url = [NSURL URLWithString:urlString];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[_webview loadRequest:requestObj];
}