This is actually quite simple, having the SDK linked as a DyLib and the main object initialized in a "attribute((constructor))" section, the following is what needed:
IMP g_originalSetDelegate = nil;
IMP g_originalOpenUrl = nil;
BOOL swizzle_openUrl(id self, SEL _cmd, UIApplication* application, NSURL* url, NSString* sourceApplication, id annotation) {
// TBD: Do your magic
return ((BOOL(*)(id,SEL,UIApplication*,NSURL*,NSString*,id))g_originalOpenUrl)(self, _cmd, application, url, sourceApplication, annotation);
}
void swizzle_setDelegate(id self, SEL _cmd, id delegate) {
((void(*)(id,SEL,id))g_originalSetDelegate)(self, _cmd, delegate);// Call the original method
auto method = class_getInstanceMethod([delegate class], @selector(application:openURL:sourceApplication:annotation:));
g_originalOpenUrl = method_getImplementation(method);
method_setImplementation(method, (IMP)swizzle_openUrl);
}
-(id)init {
auto method = class_getInstanceMethod([UIApplication class], @selector(setDelegate:));
g_originalSetDelegate = method_getImplementation(method);
method_setImplementation(method, (IMP)swizzle_setDelegate);
...
}