2

strong textI am implementing iZettle payment SDK in Xamarin. I have created binding libraries and converted all header files to ApiDefintions. I am stuck at conforming iZettleSDKAuthorizationProvider protocol in Xamarin.

Here is my APIDefinition.cs file code;

[BaseType(typeof(NSObject))]
[Model, Protocol]
interface iZettleSDKAuthorizationProvider
{
    // @required -(void)authorizeAccountWithCompletion:(void (^ _Nonnull)(iZettleSDKOAuthToken * _Nullable, NSError * _Nullable))completion;
    [Abstract]
    [Export("authorizeAccountWithCompletion:")]
    void AuthorizeAccountWithCompletion(Action<iZettleSDKOAuthToken, NSError> completion);

    // @required -(void)verifyAccountWithUuid:(NSUUID * _Nonnull)uuid completion:(void (^ _Nonnull)(iZettleSDKOAuthToken * _Nullable, NSError * _Nullable))completion;
    [Abstract]
    [Export("verifyAccountWithUuid:completion:")]
    void VerifyAccountWithUuid(NSUuid uuid, Action<iZettleSDKOAuthToken, NSError> completion);
}

// @interface iZettleSDKAuthorization : NSObject <iZettleSDKAuthorizationProvider>
[BaseType(typeof(NSObject), Name = "_TtC10iZettleSDK23iZettleSDKAuthorization")]
[DisableDefaultCtor]
interface iZettleSDKAuthorization : IiZettleSDKAuthorizationProvider
{
    // -(instancetype _Nullable)initWithClientID:(NSString * _Nonnull)clientID callbackURL:(NSURL * _Nonnull)callbackURL error:(NSError * _Nullable * _Nullable)error enforcedUserAccount:(NSString * _Nullable (^ _Nonnull)(void))enforcedUserAccount __attribute__((objc_designated_initializer));
    [Export("initWithClientID:callbackURL:error:enforcedUserAccount:")]
    [DesignatedInitializer]
    IntPtr Constructor(string clientID, NSUrl callbackURL, [NullAllowed] out NSError error, Func<NSString> enforcedUserAccount);
}

In short, I want Xamarin ios equivalent of the following code;

 id<iZettleSDKAuthorizationProvider> authorizationProvider = [[iZettleSDKAuthorization alloc]
                           initWithClientID:clientId
                           callbackURL:[NSURL URLWithString:callbackURL]
                           error:&error
                           enforcedUserAccount:^NSString * _Nullable{
    return [AccountManager shared].enforcedUserAccount;
}];

as shown here. So anyone can help me then it would be great.

Nikhil Sathawara
  • 161
  • 1
  • 2
  • 8
  • Why dont you use this xamarin bindings library https://github.com/centerax/izettle-ios-binding ? Also cant you right click on the error, and implement interface(aka protocol) automatically, what does it show you? – Saamer Aug 23 '20 at 17:55
  • @Saamer I want to integrate the latest iZettle SDK 3.0 in Xamarin and it's not available yet as a binding library. – Nikhil Sathawara Aug 24 '20 at 03:22

0 Answers0