diff --git a/CHANGELOG.md b/CHANGELOG.md
index 75bbf07f4..ebb5a9d40 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,8 @@
+## Master
+
+* Adds Chats Api mappings
+* Adds FeatureRequests Api mappings.
+
## Version 0.0.4 (2019-04-14)
* Adds hasRespondedToSurvey API mapping.
diff --git a/README.md b/README.md
index a75022926..6ab79edea 100644
--- a/README.md
+++ b/README.md
@@ -91,6 +91,21 @@ The section below contains the APIs we're planning to implement for our 1.0 rele
| `showSurvey(String surveyToken)` | `showSurvey(String token)`
`+ showSurveyWithToken:` |
| `hasRespondedToSurvey(String surveyToken, Function function)` | `hasRespondToSurvey(String token)`
`+ hasRespondedToSurveyWithToken:` |
+#### `FeatureRequests`
+
+| API Method | Native Equivalent (Android/iOS) |
+|-----------------------------------------------|--------------------------------------------------------------|
+| `show() ` | `show()`
`+ show` |
+| `setEmailFieldRequired(bool isEmailFieldRequired, List actionTypes)` | `setEmailFieldRequired(boolean isEmailRequired, ActionTypes actions)`
`+ setEmailFieldRequired:forAction:` |
+
+
+#### `Chats`
+
+| API Method | Native Equivalent (Android/iOS) |
+|-----------------------------------------------|--------------------------------------------------------------|
+| `show()` | `show()`
`+ show` |
+| `setEnabled(bool isEnabled)` | `setState(Feature.State state)`
`enabled` |
+
## Integration
Creating a Flutter app on the Instabug dashboard isn't possible yet. Create a React Native app instead.
diff --git a/android/src/main/java/com/instabug/instabugflutter/ArgsRegistry.java b/android/src/main/java/com/instabug/instabugflutter/ArgsRegistry.java
index f51d93233..15dd957db 100644
--- a/android/src/main/java/com/instabug/instabugflutter/ArgsRegistry.java
+++ b/android/src/main/java/com/instabug/instabugflutter/ArgsRegistry.java
@@ -5,6 +5,7 @@
import com.instabug.bug.BugReporting;
import com.instabug.bug.invocation.Option;
+import com.instabug.library.ActionType;
import com.instabug.library.InstabugColorTheme;
import com.instabug.library.InstabugCustomTextPlaceHolder;
import com.instabug.library.extendedbugreport.ExtendedBugReport;
@@ -60,6 +61,7 @@ final class ArgsRegistry {
registerCustomTextPlaceHolderKeysArgs(ARGS);
registerInstabugReportTypesArgs(ARGS);
registerInstabugExtendedBugReportModeArgs(ARGS);
+ registerInstabugActionTypesArgs(ARGS);
}
/**
@@ -214,4 +216,13 @@ static void registerInstabugExtendedBugReportModeArgs(Map args)
args.put("ExtendedBugReportMode.enabledWithOptionalFields", ExtendedBugReport.State.ENABLED_WITH_OPTIONAL_FIELDS);
args.put("ExtendedBugReportMode.disabled",ExtendedBugReport.State.DISABLED);
}
+
+ @VisibleForTesting
+ static void registerInstabugActionTypesArgs(Map args) {
+ args.put("ActionType.allActions", ActionType.ALL_ACTIONS);
+ args.put("ActionType.reportBug", ActionType.REPORT_BUG);
+ args.put("ActionType.requestNewFeature",ActionType.REQUEST_NEW_FEATURE);
+ args.put("ActionType.addCommentToFeature",ActionType.ADD_COMMENT_TO_FEATURE);
+ }
+
}
diff --git a/android/src/main/java/com/instabug/instabugflutter/InstabugFlutterPlugin.java b/android/src/main/java/com/instabug/instabugflutter/InstabugFlutterPlugin.java
index 6f93f340f..423b1ffc0 100644
--- a/android/src/main/java/com/instabug/instabugflutter/InstabugFlutterPlugin.java
+++ b/android/src/main/java/com/instabug/instabugflutter/InstabugFlutterPlugin.java
@@ -10,6 +10,7 @@
import com.instabug.bug.invocation.Option;
import com.instabug.chat.Chats;
import com.instabug.chat.Replies;
+import com.instabug.featuresrequest.FeatureRequests;
import com.instabug.library.Feature;
import com.instabug.library.Instabug;
import com.instabug.library.InstabugColorTheme;
@@ -732,4 +733,51 @@ public void hasRespondedToSurveyWithToken(String surveyToken) {
channel.invokeMethod("hasRespondedToSurveyCallback", hasResponded);
}
+ /**
+ * Shows the UI for feature requests list
+ */
+ public void showFeatureRequests() {
+ FeatureRequests.show();
+ }
+
+ /**
+ * Sets whether email field is required or not when submitting
+ * new-feature-request/new-comment-on-feature
+ *
+ * @param isEmailRequired set true to make email field required
+ * @param actionTypes Bitwise-or of actions
+ */
+ public void setEmailFieldRequiredForFeatureRequests(final Boolean isEmailRequired, final List actionTypes) {
+ int[] actions = new int[actionTypes.size()];
+ for (int i = 0; i < actionTypes.size(); i++) {
+ actions[i] = ArgsRegistry.getDeserializedValue(actionTypes.get(i), Integer.class);
+ }
+ FeatureRequests.setEmailFieldRequired(isEmailRequired, actions);
+ }
+
+ /**
+ * Manual invocation for chats view.
+ */
+ public void showChats() {
+ Chats.show();
+ }
+
+ /**
+ * Enables and disables everything related to creating new chats.
+ * @param {boolean} isEnabled
+ */
+ public void setChatsEnabled(final boolean isEnabled) {
+ new Handler(Looper.getMainLooper()).post(new Runnable() {
+ @Override
+ public void run() {
+ if (isEnabled) {
+ Chats.setState(Feature.State.ENABLED);
+ } else {
+ Chats.setState(Feature.State.DISABLED);
+ }
+ }
+ });
+ }
+
+
}
diff --git a/example/lib/main.dart b/example/lib/main.dart
index 0a617fd31..ab19df60a 100644
--- a/example/lib/main.dart
+++ b/example/lib/main.dart
@@ -7,6 +7,8 @@ import 'package:instabug_flutter/Instabug.dart';
import 'package:instabug_flutter/BugReporting.dart';
import 'package:instabug_flutter/InstabugLog.dart';
import 'package:instabug_flutter/Surveys.dart';
+import 'package:instabug_flutter/FeatureRequests.dart';
+import 'package:instabug_flutter/Chats.dart';
void main() => runApp(MyApp());
@@ -123,8 +125,13 @@ class _MyAppState extends State {
// Surveys.getAvailableSurveys(getSurveys);
// Surveys.showSurveyIfAvailable();
// Surveys.setShouldShowWelcomeScreen(true);
- Surveys.showSurvey("BHJI1iaKYhr4CYHHcUAaTg");
+ //Surveys.showSurvey("BHJI1iaKYhr4CYHHcUAaTg");
//BugReporting.showWithOptions(ReportType.bug, [InvocationOption.emailFieldHidden]);
+ // FeatureRequests.setEmailFieldRequired(false, [ActionType.allActions]);
+ // FeatureRequests.show();
+ Chats.setEnabled(true);
+ Chats.show();
+
}
void invokeWithMode() {
diff --git a/ios/Classes/InstabugFlutterPlugin.m b/ios/Classes/InstabugFlutterPlugin.m
index 70fd3fcfa..06db9f942 100644
--- a/ios/Classes/InstabugFlutterPlugin.m
+++ b/ios/Classes/InstabugFlutterPlugin.m
@@ -614,6 +614,46 @@ + (void)hasRespondedToSurveyWithToken:(NSString *)surveyToken {
[channel invokeMethod:@"hasRespondedToSurveyCallback" arguments:boolNumber];
}
+/**
+ * Shows the UI for feature requests list
+ */
++ (void)showFeatureRequests {
+ [IBGFeatureRequests show];
+}
+
+/**
+ * Sets whether email field is required or not when submitting
+ * new-feature-request/new-comment-on-feature
+ *
+ * @param isEmailRequired set true to make email field required
+ * @param actionTypes Bitwise-or of actions
+ */
++ (void)setEmailFieldRequiredForFeatureRequests:(NSNumber*)isEmailFieldRequired forAction:(NSArray *)actionTypesArray {
+ NSDictionary *constants = [self constants];
+ NSInteger actionTypes = 0;
+ for (NSString * actionType in actionTypesArray) {
+ actionTypes |= ((NSNumber *) constants[actionType]).integerValue;
+ }
+ BOOL boolValue = [isEmailFieldRequired boolValue];
+ [IBGFeatureRequests setEmailFieldRequired:boolValue forAction:actionTypes];
+}
+
+/**
+ * Manual invocation for chats view.
+ */
++ (void)showChats {
+ [IBGChats show];
+}
+
+/**
+ * Enables and disables everything related to creating new chats.
+ * @param {boolean} isEnabled
+ */
++ (void)setChatsEnabled:(NSNumber *)isEnabled {
+ BOOL boolValue = [isEnabled boolValue];
+ IBGChats.enabled = boolValue;
+}
+
+ (NSDictionary *)constants {
return @{
@@ -696,6 +736,11 @@ + (NSDictionary *)constants {
@"ExtendedBugReportMode.enabledWithRequiredFields": @(IBGExtendedBugReportModeEnabledWithRequiredFields),
@"ExtendedBugReportMode.enabledWithOptionalFields": @(IBGExtendedBugReportModeEnabledWithOptionalFields),
@"ExtendedBugReportMode.disabled": @(IBGExtendedBugReportModeDisabled),
+
+ @"ActionType.allActions": @(IBGActionAllActions),
+ @"ActionType.reportBug": @(IBGActionReportBug),
+ @"ActionType.requestNewFeature": @(IBGActionRequestNewFeature),
+ @"ActionType.addCommentToFeature": @(IBGActionAddCommentToFeature),
};
};
diff --git a/lib/Chats.dart b/lib/Chats.dart
new file mode 100644
index 000000000..a1a2271ea
--- /dev/null
+++ b/lib/Chats.dart
@@ -0,0 +1,28 @@
+import 'dart:async';
+import 'package:flutter/foundation.dart';
+import 'package:flutter/services.dart';
+import 'package:instabug_flutter/Instabug.dart';
+
+
+class Chats {
+
+ static const MethodChannel _channel = MethodChannel('instabug_flutter');
+
+ static Future get platformVersion async {
+ final String version = await _channel.invokeMethod('getPlatformVersion');
+ return version;
+ }
+
+ ///Manual invocation for chats view.
+ static void show() async {
+ await _channel.invokeMethod