Skip to content

Commit

Permalink
Added methods from the SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
vijaysharm committed Apr 11, 2017
1 parent 69da1c3 commit f322f41
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 1 deletion.
62 changes: 61 additions & 1 deletion android/src/main/java/com/testfairy/react/TestFairyModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ public void run() {
});
}

@ReactMethod
public void pushFeedbackController() {
runOnUi(new Runnable() {
@Override
public void run() {
Log.i("TestFairyModule", "Android does not support pushing a feedback controller");
}
});
}

@ReactMethod
public void resume() {
runOnUi(new Runnable() {
Expand All @@ -96,7 +106,17 @@ public void checkpoint(final String checkpoint) {
runOnUi(new Runnable() {
@Override
public void run() {
TestFairy.addCheckpoint(checkpoint);
TestFairy.addEvent(checkpoint);
}
});
}

@ReactMethod
public void hideWebViewElements(final String cssSelector) {
runOnUi(new Runnable() {
@Override
public void run() {
Log.i("TestFairyModule", "Android does not support hiding web view elements");
}
});
}
Expand Down Expand Up @@ -151,6 +171,46 @@ public void run() {
});
}

@ReactMethod
public void setScreenName(final String name) {
runOnUi(new Runnable() {
@Override
public void run() {
TestFairy.setScreenName(name);
}
});
}

@ReactMethod
public void stop() {
runOnUi(new Runnable() {
@Override
public void run() {
TestFairy.stop();
}
});
}

@ReactMethod
public void setUserId(final String userId) {
runOnUi(new Runnable() {
@Override
public void run() {
TestFairy.setUserId(userId);
}
});
}

@ReactMethod
public void setAttribute(final String key, final String value) {
runOnUi(new Runnable() {
@Override
public void run() {
TestFairy.setAttribute(key, value);
}
});
}

@ReactMethod
public void hideView(final int tag) {
runOnUi(new Runnable() {
Expand Down
24 changes: 24 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,30 @@ class TestFairy {
static log(message) {
TestFairyBridge.log(JSON.stringify(message));
}

static setScreenName(name) {
TestFairyBridge.setScreenName(name);
}

static stop() {
TestFairyBridge.stop();
}

static setUserId(userId) {
TestFairyBridge.setUserId(userId);
}

static setAttribute(key, value) {
TestFairyBridge.setAttribute(key, value);
}

static pushFeedbackController() {
TestFairyBridge.pushFeedbackController();
}

static hideWebViewElements(selector) {
TestFairyBridge.hideWebViewElements(selector);
}
}

// var _testfairyConsoleLog = console.log;
Expand Down
36 changes: 36 additions & 0 deletions ios/RCTTestFairyBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,42 @@ @implementation RCTTestFairyBridge
});
}

RCT_EXPORT_METHOD(setScreenName:(NSString *)name) {
dispatch_async(dispatch_get_main_queue(), ^{
[TestFairy setScreenName:name];
});
}

RCT_EXPORT_METHOD(stop) {
dispatch_async(dispatch_get_main_queue(), ^{
[TestFairy stop];
});
}

RCT_EXPORT_METHOD(pushFeedbackController) {
dispatch_async(dispatch_get_main_queue(), ^{
[TestFairy pushFeedbackController];
});
}

RCT_EXPORT_METHOD(setUserId:(NSString *)userId) {
dispatch_async(dispatch_get_main_queue(), ^{
[TestFairy setUserId:userId];
});
}

RCT_EXPORT_METHOD(hideWebViewElements:(NSString *)cssSelector) {
dispatch_async(dispatch_get_main_queue(), ^{
[TestFairy hideWebViewElements:cssSelector];
});
}

RCT_EXPORT_METHOD(setAttribute:(NSString *)key value:(NSString *)value) {
dispatch_async(dispatch_get_main_queue(), ^{
[TestFairy setAttribute:key withValue:value];
});
}

RCT_EXPORT_METHOD(hideView:(nonnull NSNumber *)reactTag) {
dispatch_async(_bridge.uiManager.methodQueue, ^{
[_bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
Expand Down

0 comments on commit f322f41

Please sign in to comment.