diff --git a/Makefile b/Makefile index 6f81f6c2f6..03717ccd84 100644 --- a/Makefile +++ b/Makefile @@ -77,7 +77,7 @@ $(STATUS_GO_DRO_ARCH): if [ $$? -ne 0 ]; then \ echo "Failed to download from DigitalOcean Bucket, checking GitHub..."; \ curl --fail --silent --location \ - "$(GITHUB_URL)/download/$(STATUS_GO_VER)/status-go-android.aar" \ + "$(GITHUB_URL)/$(STATUS_GO_VER)/status-go-android.aar" \ --output "$(STATUS_GO_DRO_ARCH)"; \ if [ $$? -ne 0 ]; then \ echo "Failed to download from GitHub!"; \ diff --git a/STATUS_GO_VERSION b/STATUS_GO_VERSION index 9c411507e4..eeb6eac346 100644 --- a/STATUS_GO_VERSION +++ b/STATUS_GO_VERSION @@ -1 +1 @@ -0.21.0g-beta.2 +0.20.0-beta.0 diff --git a/mobile_files/package.json.orig b/mobile_files/package.json.orig index 62aeec7bc3..056248846e 100644 --- a/mobile_files/package.json.orig +++ b/mobile_files/package.json.orig @@ -59,7 +59,7 @@ "react-native-svg": "6.5.2", "react-native-tcp": "git+https://github.com/status-im/react-native-tcp.git#v3.3.0-1-status", "react-native-udp": "git+https://github.com/status-im/react-native-udp.git#2.3.1-1", - "react-native-webview-bridge": "git+https://github.com/status-im/react-native-webview-bridge.git#0.33.16-4", + "react-native-webview-bridge": "git+https://github.com/status-im/react-native-webview-bridge.git#0.33.16-3-status", "react-navigation": "^2.12.1", "realm": "2.21.0", "rn-snoopy": "git+https://github.com/status-im/rn-snoopy.git#v2.0.2-status", diff --git a/mobile_files/yarn.lock b/mobile_files/yarn.lock index 30c3407a6a..c93dd3e645 100644 --- a/mobile_files/yarn.lock +++ b/mobile_files/yarn.lock @@ -6059,9 +6059,9 @@ react-native-tab-view@^1.0.0: ip-regex "^1.0.3" util "^0.10.3" -"react-native-webview-bridge@git+https://github.com/status-im/react-native-webview-bridge.git#0.33.16-4": +"react-native-webview-bridge@git+https://github.com/status-im/react-native-webview-bridge.git#0.33.16-3-status": version "0.33.16" - resolved "git+https://github.com/status-im/react-native-webview-bridge.git#db39ab2719dd0e0d33324643820619f3e75960b4" + resolved "git+https://github.com/status-im/react-native-webview-bridge.git#2e1735a1d512ad7505e55b055e36b80bfe780ba6" dependencies: invariant "2.2.0" keymirror "0.1.1" diff --git a/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusModule.java b/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusModule.java index 7312bffdb2..e482c143c0 100644 --- a/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusModule.java +++ b/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusModule.java @@ -24,9 +24,7 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.WritableMap; import com.facebook.react.modules.core.DeviceEventManagerModule; - -import statusgo.SignalHandler; -import statusgo.Statusgo; +import com.github.status_im.status_go.Statusgo; import org.json.JSONException; import org.json.JSONObject; @@ -50,7 +48,7 @@ import java.util.zip.ZipOutputStream; import javax.annotation.Nullable; -class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventListener, SignalHandler { +class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventListener, StatusNodeEventHandler { private static final String TAG = "StatusModule"; private static final String logsZipFileName = "Status-debug-logs.zip"; @@ -76,7 +74,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL @Override public void onHostResume() { // Activity `onResume` module = this; - Statusgo.setMobileSignalHandler(this); + StatusService.INSTANCE.setSignalEventListener(this); } @Override @@ -99,8 +97,9 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL } - public void handleSignal(String jsonEvent) { - Log.d(TAG, "Signal event: " + jsonEvent); + @Override + public void handleEvent(String jsonEvent) { + Log.d(TAG, "[handleEvent] event: " + jsonEvent); WritableMap params = Arguments.createMap(); params.putString("jsonEvent", jsonEvent); this.getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("gethEvent", params); @@ -243,7 +242,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL prettyPrintConfig(updatedJsonConfigString); - String res = Statusgo.startNode(updatedJsonConfigString); + String res = Statusgo.StartNode(updatedJsonConfigString); if (res.startsWith("{\"error\":\"\"")) { Log.d(TAG, "StartNode result: " + res); Log.d(TAG, "Geth node started"); @@ -362,7 +361,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL @Override public void run() { Log.d(TAG, "stopNode"); - String res = Statusgo.stopNode(); + String res = Statusgo.StopNode(); } }; @@ -380,7 +379,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL Runnable r = new Runnable() { @Override public void run() { - String result = Statusgo.login(address, password); + String result = Statusgo.Login(address, password); callback.invoke(result); } @@ -405,7 +404,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL Runnable r = new Runnable() { @Override public void run() { - String result = Statusgo.verifyAccountPassword(newKeystoreDir, address, password); + String result = Statusgo.VerifyAccountPassword(newKeystoreDir, address, password); callback.invoke(result); } @@ -425,7 +424,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL Runnable r = new Runnable() { @Override public void run() { - String result = Statusgo.loginWithKeycard(whisperPrivateKey, encryptionPublicKey); + String result = Statusgo.LoginWithKeycard(whisperPrivateKey, encryptionPublicKey); callback.invoke(result); } @@ -445,7 +444,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL Runnable r = new Runnable() { @Override public void run() { - String res = Statusgo.createAccount(password); + String res = Statusgo.CreateAccount(password); callback.invoke(res); } @@ -465,7 +464,8 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL Runnable r = new Runnable() { @Override public void run() { - String res = Statusgo.sendDataNotification(dataPayloadJSON, tokensJSON); + String res = Statusgo.SendDataNotification(dataPayloadJSON, tokensJSON); + callback.invoke(res); } }; @@ -634,7 +634,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL Runnable r = new Runnable() { @Override public void run() { - String res = Statusgo.addPeer(enode); + String res = Statusgo.AddPeer(enode); callback.invoke(res); } @@ -654,7 +654,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL Runnable r = new Runnable() { @Override public void run() { - String res = Statusgo.recoverAccount(password, passphrase); + String res = Statusgo.RecoverAccount(password, passphrase); callback.invoke(res); } @@ -678,7 +678,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL Runnable r = new Runnable() { @Override public void run() { - String res = Statusgo.sendTransaction(txArgsJSON, password); + String res = Statusgo.SendTransaction(txArgsJSON, password); callback.invoke(res); } }; @@ -697,7 +697,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL Runnable r = new Runnable() { @Override public void run() { - String res = Statusgo.signMessage(rpcParams); + String res = Statusgo.SignMessage(rpcParams); callback.invoke(res); } }; @@ -795,7 +795,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL Runnable r = new Runnable() { @Override public void run() { - String res = Statusgo.callRPC(payload); + String res = Statusgo.CallRPC(payload); callback.invoke(res); } }; @@ -808,7 +808,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL Runnable r = new Runnable() { @Override public void run() { - String res = Statusgo.callPrivateRPC(payload); + String res = Statusgo.CallPrivateRPC(payload); callback.invoke(res); } }; @@ -824,13 +824,13 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL @ReactMethod public void connectionChange(final String type, final boolean isExpensive) { Log.d(TAG, "ConnectionChange: " + type + ", is expensive " + isExpensive); - Statusgo.connectionChange(type, isExpensive ? 1 : 0); + Statusgo.ConnectionChange(type, isExpensive ? 1 : 0); } @ReactMethod public void appStateChange(final String type) { Log.d(TAG, "AppStateChange: " + type); - Statusgo.appStateChange(type); + Statusgo.AppStateChange(type); } private static String uniqueID = null; @@ -867,7 +867,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL Runnable r = new Runnable() { @Override public void run() { - String result = Statusgo.extractGroupMembershipSignatures(signaturePairs); + String result = Statusgo.ExtractGroupMembershipSignatures(signaturePairs); callback.invoke(result); } @@ -887,7 +887,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL Runnable r = new Runnable() { @Override public void run() { - String result = Statusgo.signGroupMembership(content); + String result = Statusgo.SignGroupMembership(content); callback.invoke(result); } @@ -907,7 +907,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL Runnable r = new Runnable() { @Override public void run() { - String result = Statusgo.enableInstallation(installationId); + String result = Statusgo.EnableInstallation(installationId); callback.invoke(result); } @@ -927,7 +927,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL Runnable r = new Runnable() { @Override public void run() { - String result = Statusgo.disableInstallation(installationId); + String result = Statusgo.DisableInstallation(installationId); callback.invoke(result); } @@ -947,7 +947,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL Runnable r = new Runnable() { @Override public void run() { - String res = Statusgo.updateMailservers(enodes); + String res = Statusgo.UpdateMailservers(enodes); callback.invoke(res); } diff --git a/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusNodeEventHandler.java b/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusNodeEventHandler.java new file mode 100644 index 0000000000..1e29d63b1a --- /dev/null +++ b/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusNodeEventHandler.java @@ -0,0 +1,5 @@ +package im.status.ethereum.module; + +public interface StatusNodeEventHandler { + void handleEvent(String eventJson); +} diff --git a/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusPackage.java b/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusPackage.java index b47df7c76c..e5e3ef77d2 100644 --- a/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusPackage.java +++ b/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusPackage.java @@ -5,12 +5,12 @@ import com.facebook.react.bridge.JavaScriptModule; import com.facebook.react.bridge.NativeModule; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.uimanager.ViewManager; +import com.github.status_im.status_go.Statusgo; +import java.util.ArrayList; import java.util.Collections; import java.util.List; - import im.status.ethereum.function.Function; -import statusgo.Statusgo; public class StatusPackage implements ReactPackage { @@ -22,8 +22,12 @@ public class StatusPackage implements ReactPackage { @Override public List createNativeModules(ReactApplicationContext reactContext) { - NativeModule statusModule = new StatusModule(reactContext, this.rootedDevice); - return Collections.singletonList(statusModule); + List modules = new ArrayList<>(); + System.loadLibrary("statusgoraw"); + System.loadLibrary("statusgo"); + modules.add(new StatusModule(reactContext, this.rootedDevice)); + + return modules; } @Override @@ -35,7 +39,7 @@ public class StatusPackage implements ReactPackage { return new Function() { @Override public String apply(String payload) { - return Statusgo.callRPC(payload); + return Statusgo.CallRPC(payload); } }; } diff --git a/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusService.java b/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusService.java new file mode 100644 index 0000000000..ce5a59787a --- /dev/null +++ b/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusService.java @@ -0,0 +1,63 @@ +package im.status.ethereum.module; + +import android.app.Service; +import android.content.Intent; +import android.os.*; +import android.support.annotation.Nullable; +import android.util.Log; +import java.util.concurrent.CountDownLatch; + +import java.lang.ref.WeakReference; + + +/** + * StatusService has nothing to do with Android services anymore. + * The name "StatusService" is kept to keep backward compatibility with status-go. + * Hopefully, it will be replaced when GoMobile + */ +public class StatusService { + static final StatusService INSTANCE = new StatusService(); + + private static final String TAG = "StatusService"; + + /** + * signalEvent is called by Statusgo JNI module to pass events from the node. + * @param jsonEvent + */ + public static void signalEvent(String jsonEvent) { + Log.d(TAG, "[signalEvent] event: " + jsonEvent); + StatusNodeEventHandler listener = StatusService.INSTANCE.getSignalEventListener(); + + if (listener == null) { + Log.w(TAG, "[signalEvent] no listener is set (module is missing?) ignoring event: " + jsonEvent); + return; + } + + Log.d(TAG, "[signalEvent] passing event to the listener: " + jsonEvent); + listener.handleEvent(jsonEvent); + } + + private StatusNodeEventHandler signalEventListener; + + void setSignalEventListener(StatusNodeEventHandler listener) { + Log.d(TAG, "[setSignalEventListener], setting listener to: " + this.safeClassName(listener)); + this.signalEventListener = listener; + } + + private String safeClassName(Object object) { + if (object == null) { + return "null"; + } + + if (object.getClass() == null) { + return ""; + } + + return object.getClass().getCanonicalName(); + } + + private StatusNodeEventHandler getSignalEventListener() { + return this.signalEventListener; + } + +} diff --git a/modules/react-native-status/ios/RCTStatus/RCTStatus.h b/modules/react-native-status/ios/RCTStatus/RCTStatus.h index f09d7fe841..9ce5e5b22a 100644 --- a/modules/react-native-status/ios/RCTStatus/RCTStatus.h +++ b/modules/react-native-status/ios/RCTStatus/RCTStatus.h @@ -1,8 +1,10 @@ #import #import -#import "Statusgo/Statusgo.h" #import "RCTLog.h" -@interface Status : NSObject -- (void)handleSignal:(NSString *)signal; +@interface Status : NSObject ++ (void)signalEvent:(const char *)signal; ++ (void)jailEvent:(NSString *)chatId + data:(NSString *)data; ++ (BOOL)JSCEnabled; @end diff --git a/modules/react-native-status/ios/RCTStatus/RCTStatus.m b/modules/react-native-status/ios/RCTStatus/RCTStatus.m index d773aafa09..f6bd8ab603 100644 --- a/modules/react-native-status/ios/RCTStatus/RCTStatus.m +++ b/modules/react-native-status/ios/RCTStatus/RCTStatus.m @@ -2,7 +2,7 @@ #import "ReactNativeConfig.h" #import "React/RCTBridge.h" #import "React/RCTEventDispatcher.h" -#import "Statusgo/Statusgo.h" +#import @interface NSDictionary (BVJSONString) -(NSString*) bv_jsonStringWithPrettyPrint:(BOOL) prettyPrint; @@ -45,18 +45,9 @@ } @end +static bool isStatusInitialized; static RCTBridge *bridge; - -@implementation Status - -- (instancetype)init { - self = [super init]; - if (!self) { - return nil; - } - // Subscribing to the signals from Status-Go - StatusgoSetMobileSignalHandler(self); - return self; +@implementation Status{ } -(RCTBridge *)bridge @@ -69,25 +60,6 @@ static RCTBridge *bridge; bridge = newBridge; } -- (void)handleSignal:(NSString *)signal -{ - if(!signal){ -#if DEBUG - NSLog(@"SignalEvent nil"); -#endif - return; - } - -#if DEBUG - NSLog(@"[handleSignal] Received an event from Status-Go: %@", signal); -#endif - [bridge.eventDispatcher sendAppEventWithName:@"gethEvent" - body:@{@"jsonEvent": signal}]; - - return; -} - - RCT_EXPORT_MODULE(); //////////////////////////////////////////////////////////////////// @@ -97,7 +69,6 @@ RCT_EXPORT_METHOD(startNode:(NSString *)configString) { #if DEBUG NSLog(@"StartNode() method called"); #endif - NSFileManager *fileManager = [NSFileManager defaultManager]; NSError *error = nil; NSURL *rootUrl =[[fileManager @@ -163,8 +134,8 @@ RCT_EXPORT_METHOD(startNode:(NSString *)configString) { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void) { - NSString *res = StatusgoStartNode(resultingConfig); - NSLog(@"StartNode result %@", res); + char *res = StartNode((char *) [resultingConfig UTF8String]); + NSLog(@"StartNode result %@", [NSString stringWithUTF8String: res]); }); } @@ -194,8 +165,8 @@ RCT_EXPORT_METHOD(stopNode) { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void) { - NSString *res = StatusgoStopNode(); - NSLog(@"StopNode result %@", res); + char *res = StopNode(); + NSLog(@"StopNode result %@", [NSString stringWithUTF8String: res]); }); } @@ -207,8 +178,8 @@ RCT_EXPORT_METHOD(createAccount:(NSString *)password #if DEBUG NSLog(@"CreateAccount() method called"); #endif - NSString *result = StatusgoCreateAccount(password); - callback(@[result]); + char * result = CreateAccount((char *) [password UTF8String]); + callback(@[[NSString stringWithUTF8String: result]]); } //////////////////////////////////////////////////////////////////// @@ -217,8 +188,8 @@ RCT_EXPORT_METHOD(createAccount:(NSString *)password RCT_EXPORT_METHOD(sendDataNotification:(NSString *)dataPayloadJSON tokensJSON:(NSString *)tokensJSON callback:(RCTResponseSenderBlock)callback) { - NSString* result = StatusgoSendDataNotification(dataPayloadJSON, tokensJSON); - callback(@[result]); + char * result = SendDataNotification((char *) [dataPayloadJSON UTF8String], (char *) [tokensJSON UTF8String]); + callback(@[[NSString stringWithUTF8String: result]]); #if DEBUG NSLog(@"SendDataNotification() method called"); #endif @@ -237,8 +208,8 @@ RCT_EXPORT_METHOD(sendLogs:(NSString *)dbJson) { //////////////////////////////////////////////////////////////////// addPeer RCT_EXPORT_METHOD(addPeer:(NSString *)enode callback:(RCTResponseSenderBlock)callback) { - NSString *result = StatusgoAddPeer(enode); - callback(@[result]); + char * result = AddPeer((char *) [enode UTF8String]); + callback(@[[NSString stringWithUTF8String: result]]); #if DEBUG NSLog(@"AddPeer() method called"); #endif @@ -247,8 +218,8 @@ RCT_EXPORT_METHOD(addPeer:(NSString *)enode //////////////////////////////////////////////////////////////////// updateMailservers RCT_EXPORT_METHOD(updateMailservers:(NSString *)enodes callback:(RCTResponseSenderBlock)callback) { - NSString* result = StatusgoUpdateMailservers(enodes); - callback(@[result]); + char * result = UpdateMailservers((char *) [enodes UTF8String]); + callback(@[[NSString stringWithUTF8String: result]]); #if DEBUG NSLog(@"UpdateMailservers() method called"); #endif @@ -261,8 +232,8 @@ RCT_EXPORT_METHOD(recoverAccount:(NSString *)passphrase #if DEBUG NSLog(@"RecoverAccount() method called"); #endif - NSString *result = StatusgoRecoverAccount(password, passphrase); - callback(@[result]); + char * result = RecoverAccount((char *) [password UTF8String], (char *) [passphrase UTF8String]); + callback(@[[NSString stringWithUTF8String: result]]); } //////////////////////////////////////////////////////////////////// login @@ -272,8 +243,8 @@ RCT_EXPORT_METHOD(login:(NSString *)address #if DEBUG NSLog(@"Login() method called"); #endif - NSString *result = StatusgoLogin(address, password); - callback(@[result]); + char * result = Login((char *) [address UTF8String], (char *) [password UTF8String]); + callback(@[[NSString stringWithUTF8String: result]]); } //////////////////////////////////////////////////////////////////// login @@ -289,8 +260,10 @@ RCT_EXPORT_METHOD(verify:(NSString *)address lastObject]; NSURL *absKeystoreUrl = [rootUrl URLByAppendingPathComponent:@"keystore"]; - NSString *result = StatusgoVerifyAccountPassword(absKeystoreUrl.path, address, password); - callback(@[result]); + char * result = VerifyAccountPassword((char *) [absKeystoreUrl.path UTF8String], + (char *) [address UTF8String], + (char *) [password UTF8String]); + callback(@[[NSString stringWithUTF8String: result]]); } //////////////////////////////////////////////////////////////////// @@ -302,8 +275,8 @@ RCT_EXPORT_METHOD(sendTransaction:(NSString *)txArgsJSON #if DEBUG NSLog(@"SendTransaction() method called"); #endif - NSString *result = StatusgoSendTransaction(txArgsJSON, password); - callback(@[result]); + char * result = SendTransaction((char *) [txArgsJSON UTF8String], (char *) [password UTF8String]); + callback(@[[NSString stringWithUTF8String: result]]); } //////////////////////////////////////////////////////////////////// @@ -314,8 +287,8 @@ RCT_EXPORT_METHOD(signMessage:(NSString *)message #if DEBUG NSLog(@"SignMessage() method called"); #endif - NSString *result = StatusgoSignMessage(message); - callback(@[result]); + char * result = SignMessage((char *) [message UTF8String]); + callback(@[[NSString stringWithUTF8String: result]]); } //////////////////////////////////////////////////////////////////// @@ -326,8 +299,8 @@ RCT_EXPORT_METHOD(signGroupMembership:(NSString *)content #if DEBUG NSLog(@"SignGroupMembership() method called"); #endif - NSString *result = StatusgoSignGroupMembership(content); - callback(@[result]); + char * result = SignGroupMembership((char *) [content UTF8String]); + callback(@[[NSString stringWithUTF8String: result]]); } //////////////////////////////////////////////////////////////////// @@ -338,8 +311,8 @@ RCT_EXPORT_METHOD(extractGroupMembershipSignatures:(NSString *)content #if DEBUG NSLog(@"ExtractGroupMembershipSignatures() method called"); #endif - NSString *result = StatusgoExtractGroupMembershipSignatures(content); - callback(@[result]); + char * result = ExtractGroupMembershipSignatures((char *) [content UTF8String]); + callback(@[[NSString stringWithUTF8String: result]]); } //////////////////////////////////////////////////////////////////// @@ -350,8 +323,8 @@ RCT_EXPORT_METHOD(enableInstallation:(NSString *)content #if DEBUG NSLog(@"EnableInstallation() method called"); #endif - NSString *result = StatusgoEnableInstallation(content); - callback(@[result]); + char * result = EnableInstallation((char *) [content UTF8String]); + callback(@[[NSString stringWithUTF8String: result]]); } //////////////////////////////////////////////////////////////////// @@ -362,8 +335,8 @@ RCT_EXPORT_METHOD(disableInstallation:(NSString *)content #if DEBUG NSLog(@"DisableInstallation() method called"); #endif - NSString *result = StatusgoDisableInstallation(content); - callback(@[result]); + char * result = DisableInstallation((char *) [content UTF8String]); + callback(@[[NSString stringWithUTF8String: result]]); } //////////////////////////////////////////////////////////////////// @@ -410,9 +383,9 @@ RCT_EXPORT_METHOD(clearStorageAPIs) { RCT_EXPORT_METHOD(callRPC:(NSString *)payload callback:(RCTResponseSenderBlock)callback) { dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - NSString *result = StatusgoCallRPC(payload); - dispatch_async(dispatch_get_main_queue(), ^{ - callback(@[result]); + char * result = CallRPC((char *) [payload UTF8String]); + dispatch_async( dispatch_get_main_queue(), ^{ + callback(@[[NSString stringWithUTF8String: result]]); }); }); } @@ -420,9 +393,9 @@ RCT_EXPORT_METHOD(callRPC:(NSString *)payload RCT_EXPORT_METHOD(callPrivateRPC:(NSString *)payload callback:(RCTResponseSenderBlock)callback) { dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - NSString *result = StatusgoCallPrivateRPC(payload); - dispatch_async(dispatch_get_main_queue(), ^{ - callback(@[result]); + char * result = CallPrivateRPC((char *) [payload UTF8String]); + dispatch_async( dispatch_get_main_queue(), ^{ + callback(@[[NSString stringWithUTF8String: result]]); }); }); } @@ -437,14 +410,14 @@ RCT_EXPORT_METHOD(connectionChange:(NSString *)type #if DEBUG NSLog(@"ConnectionChange() method called"); #endif - StatusgoConnectionChange(type, isExpensive ? 1 : 0); + ConnectionChange((char *) [type UTF8String], isExpensive? 1 : 0); } RCT_EXPORT_METHOD(appStateChange:(NSString *)type) { #if DEBUG NSLog(@"AppStateChange() method called"); #endif - StatusgoAppStateChange(type); + AppStateChange((char *) [type UTF8String]); } RCT_EXPORT_METHOD(getDeviceUUID:(RCTResponseSenderBlock)callback) { @@ -456,6 +429,26 @@ RCT_EXPORT_METHOD(getDeviceUUID:(RCTResponseSenderBlock)callback) { callback(@[Identifier]); } ++ (void)signalEvent:(const char *) signal +{ + if(!signal){ +#if DEBUG + NSLog(@"SignalEvent nil"); +#endif + return; + } + + NSString *sig = [NSString stringWithUTF8String:signal]; +#if DEBUG + NSLog(@"SignalEvent"); + NSLog(sig); +#endif + [bridge.eventDispatcher sendAppEventWithName:@"gethEvent" + body:@{@"jsonEvent": sig}]; + + return; +} + - (bool) is24Hour { NSString *format = [NSDateFormatter dateFormatFromTemplate:@"j" options:0 locale:[NSLocale currentLocale]];