Subramani
Subramani

Reputation: 477

Read and Redirect webpage by NFC tag response in objective c

Im struggled with redirect to webpage after read NFC scan by objective C.

Here is my code

- (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);
        }
    }        
}

Upvotes: 1

Views: 742

Answers (1)

Subramani
Subramani

Reputation: 477

I got solution by using VYNFC kit,

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];

       }

Upvotes: 1

Related Questions