- Home /
Question by
stuartmcroberts · Jan 03, 2019 at 05:35 AM ·
iphoneipad
Calling Objective C function
Trying to call a custom Objective C function form C#.
The function is defined as:
#import <Foundation/Foundation.h>
//#import "BraintreeCore.h"
#import <BraintreeCore.h>
#import <BraintreeDropIn.h>
@interface BrainTreeHandler : UIViewController
#ifdef _cplusplus
extern "C"{
-(void)ShowDropIn:(const char *)clientTokenOrTokenizationKey;
}
#endif
@end
@implementation BrainTreeHandler
#ifdef __cplusplus
extern "C"
{
-(void)ShowDropIn:(const char *)clientTokenOrTokenizationKey{
BTDropInRequest *request = [[BTDropInRequest alloc] init];
BTDropInController *dropIn = [[BTDropInController alloc] initWithAuthorization:clientTokenOrTokenizationKey request:request handler:^(BTDropInController * _Nonnull controller, BTDropInResult * _Nullable result, NSError * _Nullable error) {
if (error != nil) {
NSLog(@"ERROR");
} else if (result.cancelled) {
NSLog(@"CANCELLED");
} else {
// Use the BTDropInResult properties to update your UI
// result.paymentOptionType
// result.paymentMethod
// result.paymentIcon
// result.paymentDescription
}
}];
[self presentViewController:dropIn animated:YES completion:nil];
}
#endif
@end
And the C# code to call it looks like this:
[DllImport("__Internal")]
private static extern void ShowDropIn(string s);
void ShowBrainTree(){
//clientToke is a string
ShowDropIn(clientToken);
}
Whenever i try to build in Xcode it says that _ShowDropIn is undefined?
Comment