iOS Question Send callback to external sdk in objc inline

Katja

Member
Licensed User
Hi everybody,

I need to send a callback to an external sdk in order to initialize it. I´m quite new to Objective-C and barely used it in B4i. Would be great if somebody could give me a hint on that.
I managed to do a similar thing in B4A by just passing an object of a local Callback Class to a sdk. But i´m really confused when it comes to Inline Objc in B4i.

The Doc of the sdk says:

After you added the repository to your Xcode project you can import the module via import AusweisApp2 in Swift classes or @import AusweisApp2; in Objective-C classes and call the functions of the AusweisApp2.h header:

typedef void (* AusweisApp2Callback)(const char* pMsg);
bool ausweisapp2_init(AusweisApp2Callback pCallback);
void ausweisapp2_shutdown(void);
bool ausweisapp2_is_running(void);
void ausweisapp2_send(const char* pCmd);

First, you need to define a callback function that will be called by the AusweisApp2 to request or provide additional information.




As I understand, typedef means, I need to declare a Variable in Objc Inline Code like that:

Objective-C:
AusweisApp2Callback *pCallback;

Further the callback needs to have a method for output, something like this?:

Objective-C:
-(void)someMethod:(const char*) pMsg {
 
    //Log pMsg or Raise B4i event here
}

Then somehow link pCallback with someMethod ----> maybe I got it totally wrong here?

In the end ausweisapp2_init will be called with the callback as parameter

I just cant get those pieces together and I assume, there are a lot of pieces missing. Of course I need to get a better understanding of Objc - I´m willing to do so, but I dont even know where to start. Maybe somebody can push me to the right direction or give me a hint what is needed to solve this. Many thanks!

Regards
 

Katja

Member
Licensed User
In case somebody faces the same problem: I finally solved it by using a c function:

Objective-C:
void func(const char* pMsg){

NSLog(@"this is my message: %s", pMsg);

}
 
-(void)start{

AusweisApp2Callback pCallback = &func;
ausweisapp2_init(pCallback);

}

Regards
 
Upvote 0
Top