Skip to content

Commit b59ae35

Browse files
committed
Add implementation to react native methods
1 parent 3365be2 commit b59ae35

File tree

3 files changed

+73
-15
lines changed

3 files changed

+73
-15
lines changed

InstabugSample/index.ios.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export default class InstabugSample extends Component {
2828
constructor(props) {
2929
super(props);
3030
Instabug.startWithToken('0f0dc916bd9175e3b5d2fdf0cfa49a69', Instabug.invocationEvent.shake);
31+
3132
const ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
3233
this.state = {
3334
dataSource: ds.cloneWithRows(this._genRows({})),
@@ -61,7 +62,8 @@ export default class InstabugSample extends Component {
6162
"Unread messages count",
6263
"Set locale",
6364
"Set color theme",
64-
"Set primary color"
65+
"Set primary color",
66+
"Show surveys"
6567
];
6668
return dataBlob;
6769
}
@@ -85,6 +87,8 @@ export default class InstabugSample extends Component {
8587
this._showColorThemeActionSheet();
8688
} else if (rowID == 7) {
8789
this._showPrimaryColorActionSheet();
90+
} else if (rowID == 8) {
91+
this._showSurveys();
8892
}
8993
}
9094

@@ -225,6 +229,11 @@ export default class InstabugSample extends Component {
225229
});
226230
}
227231

232+
_showSurveys() {
233+
console.log("show surveys")
234+
Instabug.showSurveysIfAvailable()
235+
}
236+
228237
_renderSeparator(sectionID: number, rowID: number, adjacentRowHighlighted: bool) {
229238
return (
230239
<View

InstabugSample/ios/InstabugSample.xcodeproj/project.pbxproj

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
2D02E4C81E0B4AEC006451C7 /* libRCTWebSocket-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAD3E991DF850E9000B6D8A /* libRCTWebSocket-tvOS.a */; };
3535
2D02E4C91E0B4AEC006451C7 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAD3EA31DF850E9000B6D8A /* libReact.a */; };
3636
2DCD954D1E0B4F2C00145EB5 /* InstabugSampleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* InstabugSampleTests.m */; };
37-
3F14AAB3F8DF4F53A90F3677 /* libRNInstabug.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E4D43295C2849C9ABADE838 /* libRNInstabug.a */; };
3837
5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */; };
3938
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; };
39+
E55D333604B942E09167708C /* libRNInstabug.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5632439F28464ECB86D23318 /* libRNInstabug.a */; };
4040
FB6237B8BC81FC0C990E8BE6 /* libPods-InstabugSample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E9562565B465A2839B076D83 /* libPods-InstabugSample.a */; };
4141
/* End PBXBuildFile section */
4242

@@ -104,9 +104,9 @@
104104
remoteGlobalIDString = 83CBBA2E1A601D0E00E9B192;
105105
remoteInfo = React;
106106
};
107-
2460ED191E530B9B0043EDA4 /* PBXContainerItemProxy */ = {
107+
24C9AC781EFA773C00D07EFB /* PBXContainerItemProxy */ = {
108108
isa = PBXContainerItemProxy;
109-
containerPortal = 330102236E534C228083A4A1 /* RNInstabug.xcodeproj */;
109+
containerPortal = 68353C997C7F4ED0910B4CFA /* RNInstabug.xcodeproj */;
110110
proxyType = 2;
111111
remoteGlobalIDString = 24DF11ED1DA3A2B90056F77C;
112112
remoteInfo = RNInstabug;
@@ -262,9 +262,9 @@
262262
21DED4D3594E0D93E837631F /* Pods-InstabugSample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InstabugSample.release.xcconfig"; path = "Pods/Target Support Files/Pods-InstabugSample/Pods-InstabugSample.release.xcconfig"; sourceTree = "<group>"; };
263263
2D02E47B1E0B4A5D006451C7 /* InstabugSample-tvOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "InstabugSample-tvOS.app"; sourceTree = BUILT_PRODUCTS_DIR; };
264264
2D02E4901E0B4A5D006451C7 /* InstabugSample-tvOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "InstabugSample-tvOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
265-
330102236E534C228083A4A1 /* RNInstabug.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNInstabug.xcodeproj; path = "../node_modules/instabug-reactnative/ios/RNInstabug.xcodeproj"; sourceTree = "<group>"; };
266-
5E4D43295C2849C9ABADE838 /* libRNInstabug.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNInstabug.a; sourceTree = "<group>"; };
265+
5632439F28464ECB86D23318 /* libRNInstabug.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNInstabug.a; sourceTree = "<group>"; };
267266
5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTAnimation.xcodeproj; path = "../node_modules/react-native/Libraries/NativeAnimation/RCTAnimation.xcodeproj"; sourceTree = "<group>"; };
267+
68353C997C7F4ED0910B4CFA /* RNInstabug.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNInstabug.xcodeproj; path = "../node_modules/instabug-reactnative/ios/RNInstabug.xcodeproj"; sourceTree = "<group>"; };
268268
78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = "<group>"; };
269269
832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = "<group>"; };
270270
8601D784DB38337F6E545397 /* Pods-InstabugSample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InstabugSample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InstabugSample/Pods-InstabugSample.debug.xcconfig"; sourceTree = "<group>"; };
@@ -295,8 +295,8 @@
295295
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */,
296296
00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */,
297297
139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */,
298-
3F14AAB3F8DF4F53A90F3677 /* libRNInstabug.a in Frameworks */,
299298
FB6237B8BC81FC0C990E8BE6 /* libPods-InstabugSample.a in Frameworks */,
299+
E55D333604B942E09167708C /* libRNInstabug.a in Frameworks */,
300300
);
301301
runOnlyForDeploymentPostprocessing = 0;
302302
};
@@ -431,14 +431,21 @@
431431
name = Products;
432432
sourceTree = "<group>";
433433
};
434-
2460ECFD1E530B9B0043EDA4 /* Products */ = {
434+
24C9AC5C1EFA773C00D07EFB /* Products */ = {
435435
isa = PBXGroup;
436436
children = (
437-
2460ED1A1E530B9B0043EDA4 /* libRNInstabug.a */,
437+
24C9AC791EFA773C00D07EFB /* libRNInstabug.a */,
438438
);
439439
name = Products;
440440
sourceTree = "<group>";
441441
};
442+
24ED9F161EFA6BE300D771DA /* Recovered References */ = {
443+
isa = PBXGroup;
444+
children = (
445+
);
446+
name = "Recovered References";
447+
sourceTree = "<group>";
448+
};
442449
443E311BD736B6F07D8B5811 /* Frameworks */ = {
443450
isa = PBXGroup;
444451
children = (
@@ -488,7 +495,7 @@
488495
832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */,
489496
00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */,
490497
139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */,
491-
330102236E534C228083A4A1 /* RNInstabug.xcodeproj */,
498+
68353C997C7F4ED0910B4CFA /* RNInstabug.xcodeproj */,
492499
);
493500
name = Libraries;
494501
sourceTree = "<group>";
@@ -511,6 +518,7 @@
511518
83CBBA001A601CBA00E9B192 /* Products */,
512519
8098B839B3C5F5897B38D9B3 /* Pods */,
513520
443E311BD736B6F07D8B5811 /* Frameworks */,
521+
24ED9F161EFA6BE300D771DA /* Recovered References */,
514522
);
515523
indentWidth = 2;
516524
sourceTree = "<group>";
@@ -618,6 +626,9 @@
618626
CreatedOnToolsVersion = 6.2;
619627
TestTargetID = 13B07F861A680F5B00A75B9A;
620628
};
629+
13B07F861A680F5B00A75B9A = {
630+
DevelopmentTeam = 56S6Q9SA8U;
631+
};
621632
2D02E47A1E0B4A5D006451C7 = {
622633
CreatedOnToolsVersion = 8.2.1;
623634
ProvisioningStyle = Automatic;
@@ -686,8 +697,8 @@
686697
ProjectRef = 146833FF1AC3E56700842450 /* React.xcodeproj */;
687698
},
688699
{
689-
ProductGroup = 2460ECFD1E530B9B0043EDA4 /* Products */;
690-
ProjectRef = 330102236E534C228083A4A1 /* RNInstabug.xcodeproj */;
700+
ProductGroup = 24C9AC5C1EFA773C00D07EFB /* Products */;
701+
ProjectRef = 68353C997C7F4ED0910B4CFA /* RNInstabug.xcodeproj */;
691702
},
692703
);
693704
projectRoot = "";
@@ -757,11 +768,11 @@
757768
remoteRef = 146834031AC3E56700842450 /* PBXContainerItemProxy */;
758769
sourceTree = BUILT_PRODUCTS_DIR;
759770
};
760-
2460ED1A1E530B9B0043EDA4 /* libRNInstabug.a */ = {
771+
24C9AC791EFA773C00D07EFB /* libRNInstabug.a */ = {
761772
isa = PBXReferenceProxy;
762773
fileType = archive.ar;
763774
path = libRNInstabug.a;
764-
remoteRef = 2460ED191E530B9B0043EDA4 /* PBXContainerItemProxy */;
775+
remoteRef = 24C9AC781EFA773C00D07EFB /* PBXContainerItemProxy */;
765776
sourceTree = BUILT_PRODUCTS_DIR;
766777
};
767778
3DAD3E841DF850E9000B6D8A /* libRCTImage-tvOS.a */ = {
@@ -1110,7 +1121,9 @@
11101121
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
11111122
CURRENT_PROJECT_VERSION = 1;
11121123
DEAD_CODE_STRIPPING = NO;
1124+
DEVELOPMENT_TEAM = 56S6Q9SA8U;
11131125
INFOPLIST_FILE = InstabugSample/Info.plist;
1126+
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
11141127
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
11151128
OTHER_LDFLAGS = (
11161129
"$(inherited)",
@@ -1128,7 +1141,9 @@
11281141
buildSettings = {
11291142
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
11301143
CURRENT_PROJECT_VERSION = 1;
1144+
DEVELOPMENT_TEAM = 56S6Q9SA8U;
11311145
INFOPLIST_FILE = InstabugSample/Info.plist;
1146+
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
11321147
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
11331148
OTHER_LDFLAGS = (
11341149
"$(inherited)",

ios/RNInstabug/InstabugReactBridge.m

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ @implementation InstabugReactBridge
1414
@"IBGpreSendingHandler",
1515
@"IBGpreInvocationHandler",
1616
@"IBGpostInvocationHandler",
17-
@"IBGonNewMessageHandler"
17+
@"IBGonNewMessageHandler",
18+
@"IBGWillShowSurvey",
19+
@"IBGDidDismissSurvey"
1820
];
1921
}
2022

@@ -292,6 +294,38 @@ - (dispatch_queue_t)methodQueue {
292294
[Instabug logError:log];
293295
}
294296

297+
RCT_EXPORT_METHOD(setSurveysEnabled:(BOOL)surveysEnabled) {
298+
[Instabug setSurveysEnabled:surveysEnabled];
299+
}
300+
301+
RCT_EXPORT_METHOD(showSurveysIfAvailable) {
302+
[Instabug showSurveyIfAvailable];
303+
}
304+
305+
RCT_EXPORT_METHOD(setWillShowSurveyHandler:(RCTResponseSenderBlock)callBack) {
306+
if (callBack != nil) {
307+
[Instabug setWillShowSurveyHandler:^{
308+
[self sendEventWithName:@"IBGWillShowSurvey" body:nil];
309+
}];
310+
} else {
311+
[Instabug setWillShowSurveyHandler:nil];
312+
}
313+
}
314+
315+
RCT_EXPORT_METHOD(setDidDismissSurveyHandler:(RCTResponseSenderBlock)callBack) {
316+
if (callBack != nil) {
317+
[Instabug setDidDismissSurveyHandler:^{
318+
[self sendEventWithName:@"IBGDidDismissSurvey" body:nil];
319+
}];
320+
} else {
321+
[Instabug setDidDismissSurveyHandler:nil];
322+
}
323+
}
324+
325+
RCT_EXPORT_METHOD(setViewHirearchyEnabled:(BOOL)viewHirearchyEnabled) {
326+
[Instabug setViewHierarchyEnabled:viewHirearchyEnabled];
327+
}
328+
295329
- (NSDictionary *)constantsToExport
296330
{
297331
return @{ @"invocationEventNone" : @(IBGInvocationEventNone),

0 commit comments

Comments
 (0)