Skip to content

Commit 2cdd64f

Browse files
authored
🤝 Merge pull request #46 from Instabug/feature/new_release_apis
Feature/new release apis
2 parents 033dbd7 + 0479232 commit 2cdd64f

30 files changed

+198
-65
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ android {
2121
}
2222

2323
dependencies {
24-
compile 'com.instabug.library:instabug:4.6.1'
24+
compile 'com.instabug.library:instabug:4.7.0'
2525
compile 'com.android.support:multidex:1.0.0'
2626
}

src/android/IBGPlugin.java

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import org.apache.cordova.CordovaInterface;
1515
import org.apache.cordova.CordovaPlugin;
1616
import org.apache.cordova.CordovaWebView;
17+
import org.apache.cordova.PluginResult.Status;
18+
import org.apache.cordova.PluginResult;
1719
import org.json.JSONArray;
1820
import org.json.JSONException;
1921
import org.json.JSONObject;
@@ -148,6 +150,12 @@ public boolean execute(final String action, JSONArray args, final CallbackContex
148150
} else if ("getUserAttribute".equals(action)) {
149151
getUserAttribute(callbackContext, args.optString(0));
150152

153+
} else if ("showSurveyWithToken".equals(action)) {
154+
showSurveyWithToken(callbackContext, args.optString(0));
155+
156+
} else if ("hasRespondedToSurveyWithToken".equals(action)) {
157+
hasRespondedToSurveyWithToken(callbackContext, args.optString(0));
158+
151159
} else if ("setVideoRecordingFloatingButtonPosition".equals(action)) {
152160
setVideoRecordingFloatingButtonPosition(callbackContext, args.optString(0));
153161

@@ -342,6 +350,24 @@ private void setUserData(final CallbackContext callbackContext, String data) {
342350
} else callbackContext.error("User data must be provided.");
343351
}
344352

353+
/**
354+
* Shows survey with a specific token.
355+
* Does nothing if there are no available surveys with that specific token.
356+
* Answered and cancelled surveys won't show up again.
357+
* @param surveyToken - A String with a survey token.
358+
*
359+
*/
360+
private void showSurveyWithToken(final CallbackContext callbackContext, String surveyToken) {
361+
if (surveyToken != null && surveyToken.length() > 0) {
362+
try {
363+
Instabug.showSurvey(surveyToken);
364+
callbackContext.success();
365+
} catch (IllegalStateException e) {
366+
callbackContext.error(errorMsg);
367+
}
368+
} else callbackContext.error("Survey token must be provided.");
369+
}
370+
345371
/**
346372
* Uploads the specified file along with upcoming reports.
347373
*
@@ -576,6 +602,23 @@ private void getUserAttribute(final CallbackContext callbackContext, String key)
576602
}
577603
}
578604

605+
/**
606+
* Returns true if the survey with a specific token was answered before.
607+
* Will return false if the token does not exist or if the survey was not answered before.
608+
* @param surveyToken - A String with a survey token.
609+
* @param callbackContext callback with argument as the desired value of the whether
610+
* the survey has been responded to or not.
611+
*
612+
*/
613+
private void hasRespondedToSurveyWithToken(final CallbackContext callbackContext, String surveyToken) {
614+
try {
615+
boolean hasResponded = Instabug.hasRespondToSurvey(surveyToken);
616+
callbackContext.sendPluginResult(new PluginResult(Status.OK, hasResponded));
617+
} catch (IllegalStateException e) {
618+
callbackContext.error(errorMsg);
619+
}
620+
}
621+
579622
/**
580623
* Sets the default position at which the Instabug screen recording button will be shown.
581624
* Different orientations are already handled.

src/ios/IBGPlugin.m

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,54 @@ - (void) setUserName:(CDVInvokedUrlCommand*)command
182182
[self.commandDelegate sendPluginResult:result callbackId:[command callbackId]];
183183
}
184184

185+
/**
186+
* Shows survey with a specific token.
187+
* Does nothing if there are no available surveys with that specific token.
188+
* Answered and cancelled surveys won't show up again.
189+
*
190+
* @param {CDVInvokedUrlCommand*} command
191+
* The command sent from JavaScript
192+
*/
193+
- (void) showSurveyWithToken:(CDVInvokedUrlCommand*)command
194+
{
195+
CDVPluginResult* result;
196+
197+
NSString* surveyToken = [command argumentAtIndex:0];
198+
199+
if ([surveyToken length] > 0) {
200+
[Instabug showSurveyWithToken:surveyToken];
201+
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
202+
} else {
203+
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
204+
messageAsString:@"A survey token must be provided."];
205+
}
206+
207+
[self.commandDelegate sendPluginResult:result callbackId:[command callbackId]];
208+
}
209+
210+
/**
211+
* Returns true if the survey with a specific token was answered before.
212+
* Will return false if the token does not exist or if the survey was not answered before.
213+
*
214+
* @param {CDVInvokedUrlCommand*} command
215+
* The command sent from JavaScript
216+
*/
217+
- (void) hasRespondedToSurveyWithToken:(CDVInvokedUrlCommand*)command
218+
{
219+
CDVPluginResult* result;
220+
NSString *surveyToken = [command argumentAtIndex:0];
221+
222+
if (surveyToken.length > 0) {
223+
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
224+
messageAsBool:[Instabug hasRespondedToSurveyWithToken:surveyToken]];
225+
} else {
226+
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
227+
messageAsString:@"A non-empty survey token must be provided."];
228+
}
229+
230+
[self.commandDelegate sendPluginResult:result callbackId:[command callbackId]];
231+
}
232+
185233
/**
186234
* Sets the user data that’s attached with each bug report sent.
187235
* Maximum size of the string is 1000 characters.

src/ios/Instabug.framework/Headers/Instabug.h

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
Copyright: (c) 2013-2017 by Instabug, Inc., all rights reserved.
77
8-
Version: 7.5
8+
Version: 7.6.1
99
*/
1010

1111
#import <Foundation/Foundation.h>
@@ -618,8 +618,14 @@ typedef void (^NetworkObfuscationCompletionBlock)(NSData *data, NSURLResponse *r
618618
extraScreenShot:(BOOL)extraScreenShot
619619
galleryImage:(BOOL)galleryImage
620620
voiceNote:(BOOL)voiceNote
621-
screenRecording:(BOOL)screenRecording;
621+
screenRecording:(BOOL)screenRecording DEPRECATED_MSG_ATTRIBUTE("Starting from v8.0, use setAttachmentOptions: instead");
622622

623+
/**
624+
@brief Sets whether attachments in bug reporting and in-app messaging are enabled.
625+
626+
@param attachmentTypes A NS_OPTIONS to add enabled attachments type.
627+
*/
628+
+ (void)setEnabledAttachmentTypes:(IBGAttachmentType)attachmentTypes;
623629
/**
624630
@brief Enables/disables showing in-app notifications when the user receives a new message.
625631
@@ -1153,6 +1159,24 @@ OBJC_EXTERN void IBGNSLogWithLevel(NSString *format, va_list args, IBGLogLevel l
11531159
*/
11541160
+ (void)setDidDismissSurveyHandler:(void (^)(void))didShowSurveyHandler;
11551161

1162+
/**
1163+
@brief Shows Survey with a specific token.
1164+
1165+
@discussion Does nothing if there are no available surveys with that specific token. Answered and canceled surveys won't show up again.
1166+
1167+
@param surveyToken A String with a survey token.
1168+
*/
1169+
+ (void)showSurveyWithToken:(NSString *)surveyToken;
1170+
1171+
/**
1172+
@brief Returns true if the survey with a specific token was answered before .
1173+
1174+
@discussion Will return false if the token does not exist or if the survey was not answered before.
1175+
1176+
@param surveyToken A String with a survey token.
1177+
*/
1178+
+ (BOOL)hasRespondedToSurveyWithToken:(NSString *)surveyToken;
1179+
11561180
#pragma mark - SDK Debugging
11571181

11581182
/**

src/ios/Instabug.framework/Info.plist

2 Bytes
Binary file not shown.

src/ios/Instabug.framework/Instabug

16.6 KB
Binary file not shown.

src/ios/Instabug.framework/_CodeSignature/CodeResources

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
<dict>
77
<key>Headers/Instabug.h</key>
88
<data>
9-
xcDqpr1ALuKw7dmbnzNWh8B2H0M=
9+
wbRGHXdBl0uQRZhJAsvdO+5ARfU=
1010
</data>
1111
<key>Info.plist</key>
1212
<data>
13-
uZAnUh7C/NBKYvvbjRZxsn2h8cw=
13+
lCGWkFUMspzePxMCyoe61a364pw=
1414
</data>
1515
<key>Modules/module.modulemap</key>
1616
<data>
@@ -23,11 +23,11 @@
2323
<dict>
2424
<key>hash</key>
2525
<data>
26-
xcDqpr1ALuKw7dmbnzNWh8B2H0M=
26+
wbRGHXdBl0uQRZhJAsvdO+5ARfU=
2727
</data>
2828
<key>hash2</key>
2929
<data>
30-
RH1mGgfTfrjNKsUKU/GyzsXbdlyVqmYPdD2tqPYFFUo=
30+
/beRz83/JfRE3ERsVSNwUaAFbEc3w28rX4aVpoNOC9k=
3131
</data>
3232
</dict>
3333
<key>Modules/module.modulemap</key>

src/ios/InstabugCore.framework/Headers/IBGTypes.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,16 @@ typedef NS_ENUM(NSInteger, IBGLogLevel) {
291291
IBGLogLevelFatal
292292
};
293293

294+
/**
295+
The attachment types selected in Attachment action sheet.
296+
*/
297+
typedef NS_OPTIONS(NSInteger, IBGAttachmentType) {
298+
IBGAttachmentTypeScreenShot = 1 << 1,
299+
IBGAttachmentTypeExtraScreenShot = 1 << 2,
300+
IBGAttachmentTypeGalleryImage = 1 << 4,
301+
IBGAttachmentTypeScreenRecording = 1 << 6,
302+
};
303+
294304
@interface UIView (Instabug)
295305

296306
/**
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)