surveysparrow-ionic-plugin 0.1.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # surveysparrow-ionic-plugin
2
2
 
3
- SurveySparrow SDK enables you to collect feedback from your mobile app. Embed the Classic, Chat & NPS surveys in your ionic application seamlessly with few lines of code.
3
+ SurveySparrow SDK enables you to collect feedback from your mobile app. Embed the Classic, Chat & NPS surveys in your Ionic application seamlessly with few lines of code.
4
4
 
5
5
  ## Install
6
6
 
@@ -9,19 +9,40 @@ npm install surveysparrow-ionic-plugin
9
9
  npx cap sync
10
10
  ```
11
11
 
12
- ## API
12
+ ## Permissions Required
13
+
14
+ To use this plugin, ensure the following permissions are added to your app:
15
+
16
+ ### Android
17
+
18
+ Add these permissions to your `AndroidManifest.xml`:
19
+
20
+ ```xml
21
+ <uses-permission android:name="android.permission.INTERNET" />
22
+ <uses-permission android:name="android.permission.CAMERA" />
23
+ <uses-permission android:name="android.permission.RECORD_AUDIO" />
24
+ ```
13
25
 
14
- <docgen-index>
26
+ ### iOS
15
27
 
16
- * [`loadFullScreenSurvey(...)`](#loadfullscreensurvey)
17
- * [`loadFullScreenSurveyWithValidation(...)`](#loadfullscreensurveywithvalidation)
18
- * [Interfaces](#interfaces)
19
- * [Type Aliases](#type-aliases)
28
+ Add the necessary permissions to your `Info.plist`:
20
29
 
21
- </docgen-index>
30
+ ```xml
31
+ <key>NSCameraUsageDescription</key>
32
+ <string>We need camera access to capture photos and videos.</string>
33
+ <key>NSMicrophoneUsageDescription</key>
34
+ <string>We need microphone access to record audio.</string>
35
+ ```
36
+
37
+ ### General Note
38
+
39
+ Based on the survey type being used, ensure the necessary permissions (e.g., for photos, videos, audio, or storage) are added to your app's configuration.
22
40
 
23
- <docgen-api>
24
- <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
41
+ ## API
42
+
43
+ [loadFullScreenSurvey(...)](#loadfullscreensurvey)
44
+
45
+ [loadFullScreenSurveyWithValidation(...)](#loadfullscreensurveywithvalidation)
25
46
 
26
47
  ### loadFullScreenSurvey(...)
27
48
 
@@ -35,7 +56,6 @@ loadFullScreenSurvey(options: { domain: String; token: String; params: Object; p
35
56
 
36
57
  --------------------
37
58
 
38
-
39
59
  ### loadFullScreenSurveyWithValidation(...)
40
60
 
41
61
  ```typescript
@@ -45,5 +65,31 @@ loadFullScreenSurveyWithValidation(options: { domain: String; token: String; par
45
65
  | Param | Type |
46
66
  | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
47
67
  | **`options`** | <code>{ domain: <a href="#string">String</a>; token: <a href="#string">String</a>; params: <a href="#object">Object</a>; properties: <a href="#object">Object</a>; }</code> |
48
-
49
68
  --------------------
69
+
70
+ ## Validations
71
+
72
+ Validations include **Limit Submission Per User** and **Survey Throttling**.
73
+
74
+ To achieve this, the **`emailaddress`** of the user must be passed in the `params` object.
75
+
76
+ ## Params
77
+
78
+ The `params` object allows passing **survey variables**, which can be accessed in the survey's end-user interface. Ensure that the spelling of survey variables matches the configured values. Additionally, make sure to include the **`emailaddress`** field.
79
+
80
+ ## Properties
81
+
82
+ The `properties` object includes the following parameters:
83
+
84
+ 1. **`isCloseButtonEnabled`** (default: `true`)
85
+ - If set to `false`, the close button will be removed.
86
+ - **Note:** Disabling this option will also disable the close button inside the survey.
87
+
88
+ 2. **`langcode`** (default: `en`)
89
+ - To load the survey in a specific language, pass the corresponding language code.
90
+ - Ensure that the language is configured in the SurveySparrow app.
91
+ - A list of supported language codes can be found [here](https://docs.google.com/document/d/1cmmWJQba8B3UkV6g5m93DgpenVojclzeOB0mdn-rlrg/edit?usp=sharing).
92
+
93
+
94
+ ## Support
95
+ For questions or issues, contact us at [support@surveysparrow.com](mailto:support@surveysparrow.com).
@@ -209,6 +209,7 @@ import WebKit
209
209
  let ssSurveyViewController = SsSurveyViewController()
210
210
  ssSurveyViewController.domain = domain
211
211
  ssSurveyViewController.token = token
212
+ ssSurveyViewController.modalPresentationStyle = .fullScreen
212
213
  ssSurveyViewController.properties = self.properties ?? [:]
213
214
  if(params != nil){
214
215
  ssSurveyViewController.params = params ?? [:]
@@ -10,6 +10,7 @@ import SwiftUI
10
10
  ssSurveyViewController.domain = domain
11
11
  ssSurveyViewController.token = token
12
12
  ssSurveyViewController.params = params
13
+ ssSurveyViewController.modalPresentationStyle = .fullScreen
13
14
  ssSurveyViewController.properties = properties
14
15
  ssSurveyViewController.getSurveyLoadedResponse = true
15
16
  ssSurveyViewController.surveyDelegate = SsDelegate()
@@ -14,37 +14,37 @@ public class SurveySparrowIonicPluginPlugin: CAPPlugin, CAPBridgedPlugin {
14
14
  private let implementation = SurveySparrowIonicPlugin()
15
15
 
16
16
  @objc public func loadFullScreenSurvey(_ call: CAPPluginCall) {
17
-
18
- let domain = call.getString("domain")
19
- let token = call.getString("token")
20
- let params = call.getObject("params") as? [String : String]
21
- let properties = call.getObject("properties")
22
-
23
- guard let domain = domain, let token = token, let params = params, let properties = properties else {
24
- call.reject("Invalid or missing parameters")
25
- return
26
- }
27
-
28
- DispatchQueue.main.async {
29
- self.implementation.loadFullScreenSurvey(domain: domain, token: token, params: params, properties: properties)
30
- }
31
-
17
+ handleFullScreenSurvey(call, withValidation: false)
32
18
  }
33
19
 
34
20
  @objc public func loadFullScreenSurveyWithValidation(_ call: CAPPluginCall) {
35
-
36
- let domain = call.getString("domain")
37
- let token = call.getString("token")
38
- let params = call.getObject("params") as? [String : String]
39
- let properties = call.getObject("properties")
40
-
41
- guard let domain = domain, let token = token, let params = params, let properties = properties else {
21
+ handleFullScreenSurvey(call, withValidation: true)
22
+ }
23
+
24
+ private func handleFullScreenSurvey(_ call: CAPPluginCall, withValidation: Bool) {
25
+ guard
26
+ let domain = call.getString("domain"),
27
+ let token = call.getString("token"),
28
+ let params = call.getObject("params") as? [String: String],
29
+ var properties = call.getObject("properties")
30
+ else {
42
31
  call.reject("Invalid or missing parameters")
43
32
  return
44
33
  }
45
-
34
+
35
+ if let langCode = properties["langCode"] {
36
+ properties["sparrowLang"] = langCode
37
+ properties.removeValue(forKey: "langCode")
38
+ } else {
39
+ properties["sparrowLang"] = "en"
40
+ }
41
+
46
42
  DispatchQueue.main.async {
47
- self.implementation.loadFullScreenSurveyWithValidation(domain: domain, token: token, params: params, properties: properties)
43
+ if withValidation {
44
+ self.implementation.loadFullScreenSurveyWithValidation(domain: domain, token: token, params: params, properties: properties)
45
+ } else {
46
+ self.implementation.loadFullScreenSurvey(domain: domain, token: token, params: params, properties: properties)
47
+ }
48
48
  }
49
49
  }
50
50
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "surveysparrow-ionic-plugin",
3
- "version": "0.1.0",
3
+ "version": "1.0.1",
4
4
  "description": "SurveySparrow SDK enables you to collect feedback from your mobile app. Embed the Classic, Chat & NPS surveys in your ionic application seamlessly with few lines of code.",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",