-
Notifications
You must be signed in to change notification settings - Fork 0
/
CoreNFC.framework.h
2317 lines (2000 loc) · 115 KB
/
CoreNFC.framework.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ========== CoreNFC.framework/Headers/NFCReaderSession.h
//
// NFCReaderSession.h
// CoreNFC
//
// Copyright © 2017 Apple. All rights reserved.
//
#ifndef NFCReaderSession_h
#define NFCReaderSession_h
#import <Foundation/Foundation.h>
#import <dispatch/dispatch.h>
NS_ASSUME_NONNULL_BEGIN
@class NFCReaderSession;
@protocol NFCTag;
#pragma mark - NFCReaderSession, protocol of a reader session
/*!
* @protocol NFCReaderSession
*
* @discussion General reader session functions
*/
API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(watchos, macos, tvos)
@protocol NFCReaderSession <NSObject>
/*!
* @property ready
*
* @return <i>YES</i> if the reader session is started and ready to use.
*
* @discussion The RF discovery polling begins immediately when a reader session is activated successfully.
* The @link readerSession:didDetectTags: @link/ will be called when a tag is detected.
*/
@property (nonatomic, getter=isReady, readonly) BOOL ready;
/*!
* @property alertMessage
*
* @discussion Descriptive text message that is displayed on the alert action sheet once tag scanning has started. The string can be update
* dynamically in any thread context as long as the session is valid. This should be set prior to calling @link beginSession @link/ to display
* the correct message. Use this string to provide additional context about the NFC reader mode operation.
*/
@property (nonatomic, copy) NSString *alertMessage;
/*!
* @method beginSession:
*
* @discussion Starts the session. The @link [NFCReaderSessionDelegate readerSessionDidBecomeActive:] @link/ will be called when the reader session
* is activated successfully. @link [NFCReaderSessionDelegate readerSession:didDetectTags:] @link/ will return tag objects that are
* conformed to the @link NFCTag @link/ protocol. @link [NFCReaderSessionDelegate readerSession:didInvalidateWithError:] will return
* errors related to the session start.
*/
- (void)beginSession;
/*!
* @method invalidateSession
*
* @discussion Closes the reader session. The session cannot be re-used.
*/
- (void)invalidateSession;
/*!
* @method invalidateSessionWithErrorMessage:
*
* @discussion Closes the reader session. The session cannot be re-used. The specified error message and an error symbol will be displayed momentarily
* on the action sheet before it is automatically dismissed.
*/
- (void)invalidateSessionWithErrorMessage:(NSString *)errorMessage API_AVAILABLE(ios(13.0)) API_UNAVAILABLE(watchos, macos, tvos);
@end
#pragma mark - NFCReaderSessionDelegate, Reader session callback delegate
/*!
* @protocol NFCReaderSession
*
* @discussion General reader session callbacks
*/
API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(watchos, macos, tvos)
@protocol NFCReaderSessionDelegate <NSObject>
@required
/*!
* @method readerSessionDidBecomeActive:
*
* @param session The session object in the active state.
*
* @discussion Gets called when the NFC reader session has become active. RF is enabled and reader is scanning for tags.
* The @link readerSession:didDetectTags: @link/ will be called when a tag is detected.
*/
- (void)readerSessionDidBecomeActive:(NFCReaderSession *)session;
/*!
* @method readerSession:didInvalidateWithError:
*
* @param session The session object that is invalidated.
* @param error The error indicates the invalidation reason.
*
* @discussion Gets called when a session becomes invalid. At this point the client is expected to discard
* the returned session object.
*/
- (void)readerSession:(NFCReaderSession *)session didInvalidateWithError:(NSError *)error;
@optional
/*!
* @method readerSession:didDetectTags:
*
* @param session The session object used for tag detection.
* @param tags Array of @link NFCTag @link/ objects.
*
* @discussion Gets called when the reader detects NFC tag(s) in the polling sequence.
*/
- (void)readerSession:(NFCReaderSession *)session didDetectTags:(NSArray<__kindof id<NFCTag>> *)tags;
@end
#pragma mark - NFCReaderSession, Reader session base class
/*!
* @class NFCReaderSession
*
* @discussion This represents a NFC reader session for processing tags; this base class cannot be instantiate. Only one NFCReaderSession
* can be active at any time in the system. Subsequent opened sessions will get queued up and processed by the system in FIFO order.
*/
API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(watchos, macos, tvos)
@interface NFCReaderSession : NSObject<NFCReaderSession>
@property (nonatomic, weak, readonly) id delegate;
/*!
* @property readingAvailable
*
* @discussion YES if device supports NFC tag reading.
*/
@property (class, nonatomic, readonly) BOOL readingAvailable;
/*!
* @property sessionQueue
*
* @discussion The NFCReaderSessionDelegate delegate callbacks and the completion block handlers for tag operation will be dispatched on this queue.
*/
@property (nonatomic, readonly) dispatch_queue_t sessionQueue;
- (instancetype)init NS_UNAVAILABLE;
@end
NS_ASSUME_NONNULL_END
#endif /* NFCReaderSession_h */
// ========== CoreNFC.framework/Headers/CoreNFC.h
//
// CoreNFC.h
// CoreNFC
//
// Copyright © 2017 Apple. All rights reserved.
//
#ifndef CoreNFC_H
#define CoreNFC_H
#import <CoreNFC/NFCError.h>
#import <CoreNFC/NFCReaderSession.h>
#import <CoreNFC/NFCTag.h>
#import <CoreNFC/NFCTagReaderSession.h>
#import <CoreNFC/NFCNDEFReaderSession.h>
#import <CoreNFC/NSUserActivity+CoreNFC.h>
#if __has_include(<CoreNFC/NFCISO15693Tag.h>)
#import <CoreNFC/NFCISO15693Tag.h>
#endif
#if __has_include(<CoreNFC/NFCISO15693ReaderSession.h>)
#import <CoreNFC/NFCISO15693ReaderSession.h>
#endif
#import <CoreNFC/NFCFeliCaTag.h>
#import <CoreNFC/NFCISO7816Tag.h>
#import <CoreNFC/NFCMiFareTag.h>
#import <CoreNFC/NFCNDEFTag.h>
#import <CoreNFC/NFCNDEFPayload.h>
#import <CoreNFC/NFCNDEFMessage.h>
#import <CoreNFC/NFCVASReaderSession.h>
#endif
// ========== CoreNFC.framework/Headers/NFCISO7816Tag.h
//
// NFCISO7816Tag.h
// CoreNFC
//
// Copyright © 2017 Apple. All rights reserved.
//
#ifndef NFCISO7816Tag_h
#define NFCISO7816Tag_h
#import <Foundation/Foundation.h>
#import <CoreNFC/NFCNDEFTag.h>
NS_ASSUME_NONNULL_BEGIN
/*!
* @class NFCISO7816APDU
*
* @discussion ISO7816 Application Data Unit (APDU).
*/
API_AVAILABLE(ios(13.0)) API_UNAVAILABLE(watchos, macos, tvos)
@interface NFCISO7816APDU : NSObject<NSCopying>
/*!
* @property instructionClass Class (CLA) byte.
*/
@property (nonatomic, readonly, assign) uint8_t instructionClass;
/*!
* @property instructionCode Instruction (INS) byte.
*/
@property (nonatomic, readonly, assign) uint8_t instructionCode;
/*!
* @property p1Parameter P1 parameter.
*/
@property (nonatomic, readonly, assign) uint8_t p1Parameter;
/*!
* @property p2Parameter P2 parameter.
*/
@property (nonatomic, readonly, assign) uint8_t p2Parameter;
/*!
* @property data Data field; nil if data field is absent
*/
@property (nonatomic, readonly, copy, nullable) NSData *data;
/*!
* @property expectedResponseLength Expected response length (Le). -1 means no response data field is expected.
*/
@property (readonly, assign, nonatomic) NSInteger expectedResponseLength;
- (instancetype)init NS_UNAVAILABLE;
/*!
* @method initWithInstructionClass:instructionCode:p1Parameter:p2Parameter:data:expectedResponseLength:
*
* @param instructionClass Instruction class (CLA) byte
* @param instructionCode Instruction code (INS) byte
* @param p1Parameter P1 parameter byte
* @param p2Parameter P2 parameter byte
* @param data Data to transmit. Value of Lc field is set according to the data size.
* @param expectedResponseLength Response data length (Le) in bytes. Valid range is from 1 to 65536 inclusively;
* -1 means no response data field is expected.
*
* @discussion Generates an ISO7816 APDU object. The Lc value is generated base on the size of the data object; possible value ranges from
* 1 to 65535 inclusively. Use @link -initWithData: @link/ in cases where a finer control on the APDU format is required.
*/
- (instancetype)initWithInstructionClass:(uint8_t)instructionClass
instructionCode:(uint8_t)instructionCode
p1Parameter:(uint8_t)p1Parameter
p2Parameter:(uint8_t)p2Parameter
data:(NSData *)data
expectedResponseLength:(NSInteger)expectedResponseLength;
/*!
* @method initWithData:
*
* @param data Data buffer containing the full APDU.
*
* @return nil if input data does not contain a valid APDU.
*/
- (_Nullable instancetype)initWithData:(NSData *)data;
@end
@protocol NFCTag, NFCNDEFTag;
/*!
* @protocol NFCISO7816Tag
*
* @discussion A @link NFCTagReaderSession @link/ reader session returns an instance conforming to this protocol
* when an ISO7816 compatible tag is detected. Unless it is specified all block completion handlers are dispatched on the
* session work queue that is associated with the tag. Your process requires to include the
* "com.apple.developer.nfc.readersession.formats" entitlement and the "com.apple.developer.nfc.readersession.iso7816.select-identifiers"
* key in the application's Info.plist to receive this tag object from the @link NFCTagReaderSessionDelegate @link/ delegate.
* @link NFCReaderErrorSecurityViolation @link/ will be returned from the @link NFCTagReaderSessionDelegate @link/ invalidation
* method if the required entitlement is missing or "com.apple.developer.nfc.readersession.iso7816.select-identifiers" does not contain
* at least one valid entry.
* When the reader discovered a compatible ISO14443 tag it automatically performs a SELECT command (by DF name) using the values provided in
* "com.apple.developer.nfc.readersession.iso7816.select-identifiers" in the specified array order. The tag is
* returned from the [NFCTagReaderSessionDelegate readerSession:didDetectTags:] call on the first successful SELECT command.
* The initialSelectedAID property returns the application identifier of the selected application. Tag will not be returned
* to the NFCTagReaderSessionDelegate if no application described in "com.apple.developer.nfc.readersession.iso7816.select-identifiers"
* is found. Tag must be in the connected state for NFCNDEFTag protocol properties and methods to work correctly.
*
*/
API_AVAILABLE(ios(13.0)) API_UNAVAILABLE(watchos, macos, tvos)
@protocol NFCISO7816Tag <NFCTag, NFCNDEFTag>
/*!
* @property initialSelectedAID The Hex string of the application identifier (DF name) selected by the reader when the tag is discovered.
* This will match one of the entries in the "com.apple.developer.nfc.readersession.iso7816.select-identifiers"
* in the Info.plist.
*/
@property (nonatomic, retain, readonly) NSString *initialSelectedAID API_AVAILABLE(ios(13.0)) API_UNAVAILABLE(watchos, macos, tvos);
/*!
* @discussion The hardware UID of the tag.
*/
@property (nonatomic, readonly, copy) NSData *identifier;
/*!
* @discussion The optional historical bytes extracted from the Type A Answer To Select response.
*/
@property (nonatomic, readonly, copy, nullable) NSData *historicalBytes;
/*!
* @discussion The optional Application Data bytes extracted from the Type B Answer To Request response.
*/
@property (nonatomic, readonly, copy, nullable) NSData *applicationData;
/*!
* @discussion Indicates if @link applicationData @link/ follows proprietary data coding. If false, the format of the application data is
* defined in the ISO14443-3 specification.
*/
@property (nonatomic, readonly) BOOL proprietaryApplicationDataCoding;
/*!
* @method sendCommandAPDU:completionHandler:
*
* @param apdu The command APDU object
* @param completionHandler Completion handler called when the operation is completed. error is nil if operation succeeds.
* A @link NFCErrorDomain @link/ error is returned when there is a communication issue with the tag. responseData may be
* empty. Command processing status bytes (SW1-SW2) are always valid.
*
* @discussion Send a command APDU to the tag and receives a response APDU. Note that a SELECT command with a P1 value of 0x04 (seelction by DF name)
* will be checked against the values listed in the "com.apple.developer.nfc.readersession.iso7816.select-identifiers" in the Info.plist.
* Selecting an application outside of the permissible list will result in a NFCReaderErrorSecurityViolation error.
*/
- (void)sendCommandAPDU:(NFCISO7816APDU *)apdu
completionHandler:(void(^)(NSData *responseData, uint8_t sw1, uint8_t sw2, NSError * _Nullable error))completionHandler API_AVAILABLE(ios(13.0)) API_UNAVAILABLE(watchos, macos, tvos);
@end
NS_ASSUME_NONNULL_END
#endif /* NFCISO7816Tag_h */
// ========== CoreNFC.framework/Headers/NFCNDEFReaderSession.h
//
// NFCNDEFReaderSession.h
// CoreNFC
//
// Copyright © 2017 Apple. All rights reserved.
//
#ifndef NFCNDEFReaderSession_h
#define NFCNDEFReaderSession_h
#import <Foundation/Foundation.h>
@class NFCReaderSession;
@class NFCNDEFReaderSession;
@class NFCNDEFMessage;
@protocol NFCNDEFTag;
NS_ASSUME_NONNULL_BEGIN
/*!
* @protocol NFCNDEFReaderSessionDelegate
*
* @discussion NDEF reader session callbacks. Presence of the -readerSession:didDetectTags: optional method will change the session behaviour
* into a read-write session where @link NFCNDEFTag @link/ objects are returned.
*
* @note A read-write session does not trigger the -readerSession:didDetectNDEFs: method.
* @note A read-write session does not get invalidate automatically after a successful tag detection. Invalidation occurs when
* the invalidation method is called explicitly or the 60 seconds session time limit is reached.
*/
API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(watchos, macos, tvos)
@protocol NFCNDEFReaderSessionDelegate <NSObject>
@required
/*!
* @method readerSession:didInvalidateWithError:
*
* @param session The session object that is invalidated.
* @param error The error indicates the invalidation reason.
*
* @discussion Gets called when a session becomes invalid. At this point the client is expected to discard
* the returned session object.
*/
- (void)readerSession:(NFCNDEFReaderSession *)session didInvalidateWithError:(NSError *)error API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(watchos, macos, tvos);
/*!
* @method readerSession:didDetectNDEFs:
*
* @param session The session object used for tag detection.
* @param messages Array of @link NFCNDEFMessage @link/ objects.
*
* @discussion Gets called when the reader detects NFC tag(s) with NDEF messages in the polling sequence. Polling
* is automatically restarted once the detected tag is removed from the reader's read range. This method
* is only get call if the optional -readerSession:didDetectTags: method is not
* implemented.
*/
- (void)readerSession:(NFCNDEFReaderSession *)session didDetectNDEFs:(NSArray<NFCNDEFMessage *> *)messages API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(watchos, macos, tvos);
@optional
/*!
* @method readerSession:didDetectTags:
*
* @param session The session object used for NDEF tag detection.
* @param tags Array of @link NFCNDEFTag @link/ objects.
*
* @discussion Gets called when the reader detects NDEF tag(s) in the RF field. Presence of this method overrides -readerSession:didDetectNDEFs: and enables
* read-write capability for the session.
*/
- (void)readerSession:(NFCNDEFReaderSession *)session didDetectTags:(NSArray<__kindof id<NFCNDEFTag>> *)tags API_AVAILABLE(ios(13.0)) API_UNAVAILABLE(watchos, macos, tvos);
/*!
* @method readerSessionDidBecomeActive:
*
* @param session The session object in the active state.
*
* @discussion Gets called when the NFC reader session has become active. RF is enabled and reader is scanning for tags.
*/
- (void)readerSessionDidBecomeActive:(NFCNDEFReaderSession *)session API_AVAILABLE(ios(13.0)) API_UNAVAILABLE(watchos, macos, tvos);
@end
#pragma mark - NDEF reader session
/*!
* @class NFCNDEFReaderSession
*
* @discussion NFC reader session for processing NFC Data Exchange Format (NDEF) tags. This session requires the "com.apple.developer.nfc.readersession.formats"
* entitlement in your process. In addition your application's Info.plist must contain a non-empty usage description string.
* @link NFCReaderErrorSecurityViolation @link/ will be returned from @link [NFCNDEFReaderSessionDelegate readerSession:didInvalidateWithError:] @link/
* if the required entitlement is missing when session is started.
*
* @note Only one NFCNDEFReaderSession can be active at any time in the system. Subsequent opened sessions will get queued up and processed by the system in FIFO order.
* @note If the delegate object implements the optional -readerSession:didDetectTags: method the NFCNDEFReaderSession will become a read-write session; see @link
* NFCNDEFReaderSessionDelegate @link/ for detail description.
* @note The error symbol will not be drawn on the action sheet if -invalidateSessionWithError: method is called on a session that is not a read-write session;
* -invalidateSession: method should be used in a read-only session.
*/
API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(watchos, macos, tvos)
@interface NFCNDEFReaderSession : NFCReaderSession
- (instancetype)init NS_UNAVAILABLE;
/*!
* @method initWithDelegate:queue:invalidateAfterFirstRead:
*
* @param delegate The session will hold a weak ARC reference to this @link NFCNDEFReaderSessionDelegate @link/ object.
* @param queue A dispatch queue where NFCNDEFReaderSessionDelegate delegate callbacks will be dispatched to. A <i>nil</i> value will
* cause the creation of a serial dispatch queue internally for the session. The session object will retain the provided dispatch queue.
* @param invalidateAfterFirstRead Session will automatically invalidate after the first NDEF tag is read successfully when this is set to YES, and
* -readerSession:didInvalidateWithError: will return NFCReaderSessionInvalidationErrorFirstNDEFTagRead in this case.
* Set to NO if the delegate object implements the -readerSession:didDetectTags: optional method.
*
* @return A new NFCNDEFReaderSession instance.
*
* @discussion A NDEF reader session will scan and detect NFC Forum tags that contain a valid NDEF message. NFC Forum Tag type 1 to 5 that
* is NDEF formatted are supported. A modal system UI will present once -beginSession is called to inform the start of the session; the UI sheet
* is automatically dismissed when the session is invalidated either by the user or by calling -invalidateSession. The alertMessage property shall be set
* prior to -beginSession to display a message on the action sheet UI for the tag scanning operation.
*
* The reader session has the following properties:
* + An opened session has a 60 seconds time limit restriction after -beginSession is called; -readerSession:didInvalidateWithError: will return
* NFCReaderSessionInvalidationErrorSessionTimeout error when the time limit is reached.
* + Only 1 active reader session is allowed in the system; -readerSession:didInvalidateWithError: will return NFCReaderSessionInvalidationErrorSystemIsBusy
* when a new reader session is initiated by -beginSession when there is an active reader session.
* + -readerSession:didInvalidateWithError: will return NFCReaderSessionInvalidationErrorUserCanceled when user clicks on the done button on the UI.
* + -readerSession:didInvalidateWithError: will return NFCReaderSessionInvalidationErrorSessionTerminatedUnexpectedly when the client application enters
* the background state.
* + -readerSession:didInvalidateWithError: will return NFCReaderErrorUnsupportedFeature when 1) reader mode feature is not available on the hardware,
* 2) client application does not have the required entitlement.
*
* The session's mode of operation is determined by the implementation of the delegate object. The -readerSession:didDetectTags: optional method will
* enable the read-write capability and suppress the -readerSession:didDetectNDEFs: callback for the session.
*/
- (instancetype)initWithDelegate:(id<NFCNDEFReaderSessionDelegate>)delegate
queue:(nullable dispatch_queue_t)queue
invalidateAfterFirstRead:(BOOL)invalidateAfterFirstRead NS_DESIGNATED_INITIALIZER API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(watchos, macos, tvos) NS_EXTENSION_UNAVAILABLE("Not available to extensions");
/*!
* @method restartPolling
*
* @discussion Restart the polling sequence in this session to discover new NDEF tags. New tags discovered from polling will return in the subsequent @link [NFCNDEFReaderSessionDelegate readerSession:didDetectTags:]
* @link/ call. Tags that are returned previously by @link [NFCNDEFReaderSessionDelegate -readerSession:didDetectTags:] @link/ will become invalid,
* and all references to these tags shall be removed to properly release the resources. Calling this method on an invalidated session
* will have no effect; a new reader session is required to restart the reader. Calling this method on an instance initiated with a delegate object that does not implement
* the optional -readerSession:didDetectTags: method has no effect as RF polling restart is done automatically.
*/
- (void)restartPolling API_AVAILABLE(ios(13.0)) API_UNAVAILABLE(watchos, macos, tvos);
/*!
* @method connectToTag:completionHandler:
*
* @param tag A NFCTag protocol compliant tag object that will be connect to.
*
* @param completionHandler Completion handler called when the operation is completed. error is nil if operation succeeds.
* A @link NFCErrorDomain @link/ error is returned when there is a communication issue with the tag.
*
* @discussion This method establishes a tag connection and activates the tag. Connecting to the same tag that is currently opened has no effect.
* Connecting to a different tag will automatically terminate the previous tag connection and put it into the halt state. Tag stays in the
* connected state until another tag is connected or the polling is restarted.
*/
- (void)connectToTag:(id<NFCNDEFTag>)tag completionHandler:(void(^)(NSError * _Nullable error))completionHandler API_AVAILABLE(ios(13.0)) API_UNAVAILABLE(watchos, macos, tvos);
@end
NS_ASSUME_NONNULL_END
#endif
// ========== CoreNFC.framework/Headers/NFCVASReaderSession.h
//
// NFCVASReaderSession.h
// CoreNFC
//
// Copyright © 2017 Apple. All rights reserved.
//
#ifndef NFCVASReaderSession_h
#define NFCVASReaderSession_h
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@class NFCReaderSession;
@class NFCVASReaderSession;
/*!
* @class NFCVASCommandConfiguration
*
* @discussion Configuration for one GET VAS DATA command.
*/
API_AVAILABLE(ios(13.0)) API_UNAVAILABLE(watchos, macos, tvos)
@interface NFCVASCommandConfiguration : NSObject<NSCopying>
/*!
* @enum VASMode
*
* @constant VASModeURLOnly URL VAS protocol only.
* @constant VASModeNormal Full VAS protocol.
*/
typedef NS_ENUM(NSInteger, VASMode) {
VASModeURLOnly = 0,
VASModeNormal = 1,
};
/*!
* @property mode
* @discussion VAS protocol mode.
*/
@property (nonatomic, assign) VASMode mode;
/*!
* @property passTypeIdentifier
* @discussion Wallet Pass Type Identifier of the Wallet Pass. The string value will be used to calculate the
* Merchant ID value for the GET VAS DATA command.
*/
@property (nonatomic, retain) NSString *passTypeIdentifier;
/*!
* @property url
* @discussion Merchant URL object. Maximum length of the URL is 64 characters, including the schema.
* Set to nil to disable the merchant URL.
*/
@property (nonatomic, retain, nullable) NSURL *url;
/*!
* @method initWithVASMode:passTypeIdentifier:url:
*
* @param mode VAS operation mode
* @param passTypeIdentifier Pass type identifier of the Wallet pass.
* @param url URL for VAR URL Only mode. Set to <i>nil</i> for VAS normal mode.
*/
- (instancetype)initWithVASMode:(VASMode)mode passTypeIdentifier:(NSString *)passTypeIdentifier url:(NSURL * _Nullable)url NS_DESIGNATED_INITIALIZER;
@end
/*!
* @class NFCVASResponse
*
* @discussion Response from one GET VAS DATA command.
*/
API_AVAILABLE(ios(13.0)) API_UNAVAILABLE(watchos, macos, tvos)
@interface NFCVASResponse : NSObject<NSCopying>
/*!
* @enum VASErrorCode
*
* @discussion Response APDU status word.
*/
typedef NS_ENUM(NSInteger, VASErrorCode) {
VASErrorCodeSuccess = 0x9000,
VASErrorCodeDataNotFound = 0x6A83,
VASErrorCodeDataNotActivated = 0x6287,
VASErrorCodeWrongParameters = 0x6B00,
VASErrorCodeWrongLCField = 0x6700,
VASErrorCodeUserIntervention = 0x6984,
VASErrorCodeIncorrectData = 0x6A80,
VASErrorCodeUnsupportedApplicationVersion = 0x6340,
};
/*!
* @property status
*
* @discussion Response APDU status.
*/
@property (nonatomic, assign, readonly) VASErrorCode status;
/*!
* @property vasData
*
* @discussion VAS data.
*/
@property (nonatomic, retain, readonly) NSData *vasData;
/*!
* @property mobileToken
*
* @discussion Mobile token value.
*/
@property (nonatomic, retain, readonly) NSData *mobileToken;
@end
/*!
* @protocol NFCVASReaderSessionDelegate
*
* @discussion Value Added Service (VAS) reader session callbacks.
*/
API_AVAILABLE(ios(13.0)) API_UNAVAILABLE(watchos, macos, tvos)
@protocol NFCVASReaderSessionDelegate <NSObject>
@optional
/*!
* @method readerSessionDidBecomeActive:
*
* @param session The session object in the active state.
*
* @discussion Gets called when the NFC reader session has become active. RF is enabled and reader is scanning for VAS tags.
* The @link readerSession:didReceiveVASResponses: @link/ will be called when a VAS transaction is completed.
*/
- (void)readerSessionDidBecomeActive:(NFCVASReaderSession *)session API_AVAILABLE(ios(13.0)) API_UNAVAILABLE(watchos, macos, tvos);
@required
/*!
* @method readerSession:didInvalidateWithError:
*
* @param session The session object that is invalidated.
* @param error The error indicates the invalidation reason.
*
* @discussion Gets called when a session becomes invalid. At this point the client is expected to discard
* the returned session object.
*/
- (void)readerSession:(NFCVASReaderSession *)session didInvalidateWithError:(NSError *)error API_AVAILABLE(ios(13.0)) API_UNAVAILABLE(watchos, macos, tvos);
/*!
* @method readerSession:didReceiveVASResponses:
*
* @param session The session object used for tag detection.
* @param responses Array of @link NFCVASResponse @link/ objects. The order of the response objects follows the
* sequence of GET VAS DATA sent by the reader session.
*
* @discussion Gets called when the reader completes the requested VAS transaction. Polling
* is automatically restarted once the detected tag is removed from the reader's read range.
*/
- (void)readerSession:(NFCVASReaderSession *)session didReceiveVASResponses:(NSArray<NFCVASResponse *> *)responses API_AVAILABLE(ios(13.0)) API_UNAVAILABLE(watchos, macos, tvos);
@end
/*!
* @class NFCVASReaderSession
*
* @discussion Reader session for processing Value Added Service (VAS) tags. This session requires the "com.apple.developer.nfc.readersession.formats"
* entitlement in your process. In addition your application's Info.plist must contain a non-empty usage description string.
* @link NFCReaderErrorSecurityViolation @link/ will be returned from @link [NFCVASReaderSessionDelegate readerSession:didInvalidateWithError:] @link/
* if the required entitlement is missing when session is started.
*
* NOTE:
* Only one NFCReaderSession can be active at any time in the system. Subsequent opened sessions will get queued up and processed by the system in FIFO order.
*/
API_AVAILABLE(ios(13.0)) API_UNAVAILABLE(watchos, macos, tvos)
@interface NFCVASReaderSession : NFCReaderSession
- (instancetype)init NS_UNAVAILABLE;
/*!
* @method initWithVASCommandConfigurations:delegate:queue:invalidateAfterFirstRead:
*
* @param commandConfigurations NSArray of NFCVASCommandConfiguration objects. Each NFCVASCommandConfiguration defines one GET VAS DATA command send to
* a compatible tag when discovered. The order of elements in the array defines the order of the command execution.
* @param delegate The session will hold a weak ARC reference to this @link NFCVASReaderSessionDelegate @link/ object.
* @param queue A dispatch queue where NFCVASReaderSessionDelegate delegate callbacks will be dispatched to. A <i>nil</i> value will
* cause the creation of a serial dispatch queue internally for the session. The session object will retain the provided dispatch queue.
*
* @return A new NFCVASReaderSession instance.
*
* @discussion A VAS reader session will automatically scan and detect tag that is compatible with the VAS protocol. The session will advertise as a
* VAS App Only terminal. A modal system UI will present once -beginSession is called to inform the start of the session; the UI sheet
* is automatically dismissed when the session is invalidated either by the user or by calling -invalidateSession. The alertMessage property shall be set
* prior to -beginSession to display a message on the action sheet UI for the tag scanning operation.
*
* The reader session has the following properties:
* + An opened session has a 60 seconds time limit restriction after -beginSession is called; -readerSession:didInvalidateWithError: will return
* NFCReaderSessionInvalidationErrorSessionTimeout error when the time limit is reached.
* + Only 1 active reader session is allowed in the system; -readerSession:didInvalidateWithError: will return NFCReaderSessionInvalidationErrorSystemIsBusy
* when a new reader session is initiated by -beginSession when there is an active reader session.
* + -readerSession:didInvalidateWithError: will return NFCReaderSessionInvalidationErrorUserCanceled when user clicks on the done button on the UI.
* + -readerSession:didInvalidateWithError: will return NFCReaderSessionInvalidationErrorSessionTerminatedUnexpectedly when the client application enters
* the background state.
* + -readerSession:didInvalidateWithError: will return NFCReaderErrorUnsupportedFeature when 1) reader mode feature is not available on the hardware,
* 2) client application does not have the required entitlement.
*/
- (instancetype)initWithVASCommandConfigurations:(NSArray<NFCVASCommandConfiguration *> *)commandConfigurations
delegate:(id<NFCVASReaderSessionDelegate>)delegate
queue:(nullable dispatch_queue_t)queue NS_DESIGNATED_INITIALIZER API_AVAILABLE(ios(13.0)) API_UNAVAILABLE(watchos, macos, tvos) NS_EXTENSION_UNAVAILABLE("Not available to extensions");
@end
NS_ASSUME_NONNULL_END
#endif /* NFCVASReaderSession_h */
// ========== CoreNFC.framework/Headers/NFCNDEFPayload.h
//
// NFCNDEFPayload.h
// CoreNFC
//
// Copyright © 2018 Apple. All rights reserved.
//
#ifndef NFCNDEFPayload_h
#define NFCNDEFPayload_h
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/*!
* @discussion Type Name Format value defined by NFC Data Exchange Format (NDEF) Technical Specification
* from NFC Forum.
*/
typedef NS_ENUM(uint8_t, NFCTypeNameFormat) {
NFCTypeNameFormatEmpty = 0x00,
NFCTypeNameFormatNFCWellKnown = 0x01,
NFCTypeNameFormatMedia = 0x02,
NFCTypeNameFormatAbsoluteURI = 0x03,
NFCTypeNameFormatNFCExternal = 0x04,
NFCTypeNameFormatUnknown = 0x05,
NFCTypeNameFormatUnchanged = 0x06
};
/*!
* @class NFCNDEFPayload
*
* @discussion A NDEF message payload consists of Type Name Format, Type, Payload Identifier, and Payload data.
* The NDEF payload cannot result into a record that is greater than 128KB in size.
*/
NS_EXTENSION_UNAVAILABLE("Not available to extensions") API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(watchos, macos, tvos)
@interface NFCNDEFPayload : NSObject<NSSecureCoding>
@property (nonatomic, assign) NFCTypeNameFormat typeNameFormat;
@property (nonatomic, copy) NSData *type;
@property (nonatomic, copy) NSData *identifier;
@property (nonatomic, copy) NSData *payload;
- (instancetype)init NS_UNAVAILABLE;
/*!
* @method initWithFormat:type:identifier:paylaod:
*
* @param format NFCTypeNameFormat value.
* @param type Identifier describing the type of the payload. Empty data indicates field is absent from the payload.
* @param identifier Identifier in the form of a URI reference. Empty data indicates field is absent from the payload.
* @param payload Payload data. Empty data indicates field is absent from the payload.
*
* This initializer uses the maximum payload chunk size defined by the NFC NDEF specification, i.e. 2^32-1 octets.
*/
- (instancetype)initWithFormat:(NFCTypeNameFormat)format type:(NSData *)type identifier:(NSData *)identifier payload:(NSData *)payload API_AVAILABLE(ios(13.0)) API_UNAVAILABLE(watchos, macos, tvos);
/*!
* @method initWithFormat:type:identifier:paylaod:
*
* @param format NFCTypeNameFormat value.
* @param type Identifier describing the type of the payload. Empty data indicates field is absent from the payload.
* @param identifier Identifier in the form of a URI reference. Empty data indicates field is absent from the payload.
* @param payload Payload data. Empty data indicates field is absent from the payload.
* @param chunkSize Maximum size of a payload chunk. 0 means no chunking on the payload, i.e. payload is fit in a single record.
*/
- (instancetype)initWithFormat:(NFCTypeNameFormat)format type:(NSData *)type identifier:(NSData *)identifier payload:(NSData *)payload chunkSize:(size_t)chunkSize API_AVAILABLE(ios(13.0)) API_UNAVAILABLE(watchos, macos, tvos);
@end
@interface NFCNDEFPayload (ConvenienceHelpers)
/*!
* @method wellKnownTypeURIRecordWithString:
*
* @param uri URI string. UTF-8 encoding representation will be used.
*
* @discussion Used for creating NDEF URI payloads which cannot be represented with NSURL object. These are URIs that contain characters
* such as 'ä' and 'ö' which cannot be represent by the 7 bits ASCII encoding.
*/
+ (_Nullable instancetype)wellKnownTypeURIPayloadWithString:(NSString *)uri API_AVAILABLE(ios(13.0)) API_UNAVAILABLE(watchos, macos, tvos);
/*!
* @method wellKnownTypeURIPayloadWithURL:
*
* @param url NSURL object.
*
* @discussion Preferred convenience function for creating NDEF URI payload with common URLs such as "https://www.apple.com" or "tel:+1-555-555-5555".
*/
+ (_Nullable instancetype)wellKnownTypeURIPayloadWithURL:(NSURL *)url API_AVAILABLE(ios(13.0)) API_UNAVAILABLE(watchos, macos, tvos);
/*!
* @method wellKnowTypeTextPayloadWithString:locale:
*
* @param text Text message.
* @param locale NSLocale object. IANA language code specified by the locale will be saved with the payload.
*/
+ (_Nullable instancetype)wellKnowTypeTextPayloadWithString:(NSString *)text locale:(NSLocale *)locale API_AVAILABLE(ios(13.0)) API_UNAVAILABLE(watchos, macos, tvos);
/*!
* @method wellKnownTypeURIPayload
*
* @return NSURL object base on a valid Well Known Type URI payload. nil if payload is not a URI.
*/
- (NSURL * _Nullable)wellKnownTypeURIPayload API_AVAILABLE(ios(13.0)) API_UNAVAILABLE(watchos, macos, tvos);
/*!
* @method wellKnownTypeTextPayloadWithLocale:
*
* @param locale Returns NSLocale object that is constructed from the IANA language code stored with the text payload.
* @return NSString object base on a valid Well Known Type Text payload. nil if payload is not a text.
*/
- (NSString * _Nullable)wellKnownTypeTextPayloadWithLocale:(NSLocale * _Nullable * _Nonnull)locale API_AVAILABLE(ios(13.0)) API_UNAVAILABLE(watchos, macos, tvos);
@end
NS_ASSUME_NONNULL_END
#endif /* NFCNDEFPayload_h */
// ========== CoreNFC.framework/Headers/NFCNDEFMessage.h
//
// NFCNDEFMessage.h
// CoreNFC
//
// Copyright © 2018 Apple. All rights reserved.
//
#ifndef NFCNDEFMessage_h
#define NFCNDEFMessage_h
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@class NFCNDEFPayload;
/*!
* @class NFCNDEFMessage
*
* @discussion A NDEF message consists of payload records. The maximum size of the NDEF message is limited to 128KB.
*/
NS_EXTENSION_UNAVAILABLE("Not available to extensions") API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(watchos, macos, tvos)
@interface NFCNDEFMessage : NSObject<NSSecureCoding>
/*!
* @property records
*
* @discussion Array of NFCNDEFPayload records contained in this message.
*/
@property (nonatomic, copy) NSArray<NFCNDEFPayload *> *records API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(watchos, macos, tvos);
/*!
* @property length
*
* @discussion Length of the resulting NDEF message in bytes as it would be stored on a NFC tag.
*/
@property (nonatomic, readonly) NSUInteger length API_AVAILABLE(ios(13.0)) API_UNAVAILABLE(watchos, macos, tvos);
- (instancetype)init NS_UNAVAILABLE;
/*!
* @method initWithNDEFRecords:
*
* @param records NSArray of NFCNDEFPayload object. An empty array will create an empty NDEF message.
*/
- (instancetype)initWithNDEFRecords:(NSArray<NFCNDEFPayload *> *)records API_AVAILABLE(ios(13.0)) API_UNAVAILABLE(watchos, macos, tvos);
/*!
* @method ndefMessageWithData:
*
* @param data NSData storing raw bytes of a complete NDEF message. The data content will be validated; all NDEF payloads must
* be valid according to the NFC Forum NDEF RTD specification and it shall only contain a single NDEF message.
*
*/
+ (_Nullable instancetype)ndefMessageWithData:(NSData *)data API_AVAILABLE(ios(13.0)) API_UNAVAILABLE(watchos, macos, tvos);
@end
NS_ASSUME_NONNULL_END
#endif /* NFCNDEFMessage_h */
// ========== CoreNFC.framework/Headers/NFCTag.h
//
// NFCTag.h
// CoreNFC
//
// Copyright © 2017 Apple. All rights reserved.
//
#ifndef NFCTag_h
#define NFCTag_h
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/*!
* @enum NFCTagType
*
* @constant NFCTagTypeISO15693 ISO15693 tag.
* @constant NFCTagTypeFeliCa FeliCa tag.
* @constant NFCTagTypeISO7816Compatible ISO14443-4 type A / B tag with ISO7816 communication.
* @constant NFCTagTypeMiFare MiFare technology tag (MIFARE Plus, UltraLight, DESFire) base on ISO14443.
*/
API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(watchos, macos, tvos)
typedef NS_ENUM(NSUInteger, NFCTagType) {
NFCTagTypeISO15693 = 1,
NFCTagTypeFeliCa API_AVAILABLE(ios(13.0)) API_UNAVAILABLE(watchos, macos, tvos) = 2,
NFCTagTypeISO7816Compatible API_AVAILABLE(ios(13.0)) API_UNAVAILABLE(watchos, macos, tvos) = 3,
NFCTagTypeMiFare API_AVAILABLE(ios(13.0)) API_UNAVAILABLE(watchos, macos, tvos) = 4,
};
@protocol NFCReaderSession;
@protocol NFCNDEFTag;
@protocol NFCISO15693Tag;
@protocol NFCISO7816Tag;
@protocol NFCMiFareTag;
@protocol NFCFeliCaTag;
/*!
* @protocol NFCTag
*
* @discussion A NFC / RFID tag object conforms to this protocol. The NFCReaderSession returns an instance of this type when a tag is detected.
*/
API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(watchos, macos, tvos)
@protocol NFCTag <NSObject, NSSecureCoding, NSCopying>
@required
/*!
* @property type
*
* @discussion See @link CNFCTagType @link/
*/
@property (nonatomic, readonly, assign) NFCTagType type;
/*!
* @property session
*
* @discussion Session that provides this tag.
*/
@property (nonatomic, weak, readonly) id<NFCReaderSession> session;
/*!
* @property available:
*
* @return <i>YES</i> if tag is available in the current reader session. A tag remove from the RF field will become
* unavailable. Tag in disconnected state will return NO.
*
* @discussion Check whether a detected tag is available.
*/
@property (nonatomic, getter=isAvailable, readonly) BOOL available;
/*!
* @method asNFCISO15693Tag
*
* @return Returns self if it conforms to the NFCISO15693Tag protocol; else returns nil.
*/
- (nullable id<NFCISO15693Tag>)asNFCISO15693Tag API_AVAILABLE(ios(13.0)) API_UNAVAILABLE(watchos, macos, tvos);
/*!
* @method asNFCISO7816Tag
*
* @return Returns self if it conforms to the NFCISO7816Tag protocol; else returns nil.
*/
- (nullable id<NFCISO7816Tag>)asNFCISO7816Tag API_AVAILABLE(ios(13.0)) API_UNAVAILABLE(watchos, macos, tvos);
/*!
* @property asNFCFeliCaTag
*
* @discussion Returns nil if tag does not conform to NFCFeliCaTag.
*/
- (nullable id<NFCFeliCaTag>)asNFCFeliCaTag API_AVAILABLE(ios(13.0)) API_UNAVAILABLE(watchos, macos, tvos);
/*!
* @property asNFCMiFareTag
*
* @discussion Returns nil if tag does not conform to NFCMiFareTag.