MonoTouch binding notifications in third party library
I am working on creating bindings for IDTech CC swipers. I beat my head about this for a while. I am lingering on how to subscribe to events that a third party library raises. Specifically, I need to know when the card was inserted.
//Notification identifiers used with NSNotificationCenter
//physical attachment related
extern NSString * const uniMagAttachmentNotification;
extern NSString * const uniMagDetachmentNotification;
//connection related
extern NSString * const uniMagInsufficientPowerNotification;
extern NSString * const uniMagPoweringNotification;
extern NSString * const uniMagTimeoutNotification;
extern NSString * const uniMagDidConnectNotification;
extern NSString * const uniMagDidDisconnectNotification;
//swipe related
extern NSString * const uniMagSwipeNotification;
extern NSString * const uniMagTimeoutSwipeNotification;
extern NSString * const uniMagDataProcessingNotification;
extern NSString * const uniMagInvalidSwipeNotification;
extern NSString * const uniMagDidReceiveDataNotification;
//command related
extern NSString * const uniMagCmdSendingNotification;
extern NSString * const uniMagCommandTimeoutNotification;
extern NSString * const uniMagDidReceiveCmdNotification;
//misc
extern NSString * const uniMagSystemMessageNotification;
The documentation says this should work:
[Notification]
[Field ("uniMagAttachmentNotification")]
NSString uniMagAttachmentNotification { get; }
It doesn't compile.
obj/Debug/ios/magTechBinding/uniMag.g.cs(637,95): error CS0117: `MonoTouch.Constants' does not contain a definition for `magTechBindingLibrary'
obj/Debug/ios/magTechBinding/uniMag.g.cs(637,77): error CS1502: The best overloaded method match for `MonoTouch.ObjCRuntime.Dlfcn.dlopen(string, int)' has some invalid arguments
obj/Debug/ios/magTechBinding/uniMag.g.cs(637,77): error CS1503: Argument `#1' cannot convert `object' expression to type `string'
Any thoughts or help would be greatly appreciated!
+3
source to share
1 answer
Try:
[Field ("uniMagAttachmentNotification", "__Internal")]
The second parameter indicates in which library to search for the field. Without a generator, suppose you have a constant readiness for this.
Now, when you link the third party static (.a) library, it will become part of the final executable. Therefore it __Internal
should be used as the name of the library (meaning it is inside the main executable).
+5
source to share