I'm creating a binding library to bind native Objective-C framework.
I have the following delegate which I need to add it's declaration to ApiDefinition file and then I need to implement it using my Xamarin.iOS app:
- (void)Initialize:(id <MMSDKDelegate> _Nullable)pDelegate;
MMSDKDelegate:
@protocol MMSDKDelegate <IMMDelegate>
- (void)Started;
@end
IMMDelegate:
@protocol IMMDelegate
- (void)Inserted;
- (void)Removed;
- (void)ReaderConnected;
- (void)ReaderRemoved;
@end
I need the required definition in ApiDefinition file and I need a sample code to call this method from my Xamarin.iOS app.
Update
The Framework I'm dealing with is communicating with card reader device attached with iPhone to read ID card info, it has methods to be called on reader inserted / removed & card inserted / removed..
I have implemented the answer by @cole-xia, but the issue is the methods inside IMMDelegate
are never called when I insert card reader or ID. When I call ReadCardData()
, it should call Started()
which will display information saved by Inserted()
, but the current result is that Started()
method is called after calling ReadCardData()
, but Inserted()
and ReaderConnected()
are never called in any stage.
In the demo app of Framework, it is used as the following (and works properly):
// Demo app -> ViewController.m
@interface ViewController () <MMSDKDelegate>
@end
@implementation ViewController {
MMSDK *sdkInstance;
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
sdkInstance = [MMSDK SharedInstance];
[sdkInstance Initialize:self];
}
- (void)Started
{
// Update UI by: reading in progress ..
}
- (void)Inserted
{
// Update UI by: card inserted
// And read card data
[self readData:self];
}
- (void)Removed
{
// Update UI by: card removed
}
- (void)ReaderConnected
{
// Update UI by: card reader connected
}
- (void)ReaderRemoved
{
// Update UI by: card reader removed
}
- (IBAction)readData:(id)sender
{
var *data = [sdkInstance ReadCardData:YES pWithSignatureImage:YES pWithAddressData:YES];
if (data.hasError) {
// No data fetched
return;
}
if (data) {
// return card data
}
}
All suggestions are welcome and appreciated.
In summary, I just need to do same functionality of demo app in Xamarin.iOS app.