diff --git a/geth/ios.go b/geth/ios.go new file mode 100644 index 000000000..c8bd4f5e6 --- /dev/null +++ b/geth/ios.go @@ -0,0 +1,12 @@ +// +build darwin,cgo + +package geth + +/* +#cgo CFLAGS: -x objective-c +#cgo LDFLAGS: -framework Foundation +#include +#include +extern bool StatusServiceSignalEvent( const char *jsonEvent ); +*/ +import "C" diff --git a/geth/signals.c b/geth/signals.c index cb9a7c7e9..c06ccb54c 100644 --- a/geth/signals.c +++ b/geth/signals.c @@ -5,10 +5,43 @@ #include #include +#include +#include +#include +#include +static id statusServiceClassRef = nil; +static SEL statusServiceSelector = nil; + +static bool initLibrary() { + if (statusServiceClassRef == nil) { + statusServiceClassRef = objc_getClass("Status"); + if (statusServiceClassRef == nil) return false; + } + + if (statusServiceSelector == nil) { + statusServiceSelector = sel_getUid("signalEvent:"); + if (statusServiceSelector == nil) return false; + } + + return true; +} + + +/*! + * @brief Calls static method signalEvent of class GethService. + * + * @param jsonEvent - UTF8 string + * + * @note Definition of signalEvent method. + * + (void)signalEvent:(const char *)json + */ bool StatusServiceSignalEvent(const char *jsonEvent) { - // code for sending JSON notification up to iOS app - return true; + if (!initLibrary()) return false; + + objc_msgSend(statusServiceClassRef, statusServiceSelector, jsonEvent); + + return true; } #elif defined(ANDROID_DEPLOYMENT)