surveysparrow-ionic-plugin 0.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/Package.swift +30 -0
- package/README.md +858 -0
- package/SurveysparrowIonicPlugin.podspec +17 -0
- package/android/build.gradle +63 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/surveysparrow/plugins/ionic/SurveySparrowIonicPlugin.java +59 -0
- package/android/src/main/java/com/surveysparrow/plugins/ionic/SurveySparrowIonicPluginPlugin.java +74 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +4485 -0
- package/dist/esm/definitions.d.ts +14 -0
- package/dist/esm/definitions.js +2 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/plugin.cjs.js +8 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +11 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Sources/SurveySparrowIonicPluginPlugin/SurveySparrowIonicPlugin.swift +82 -0
- package/ios/Sources/SurveySparrowIonicPluginPlugin/SurveySparrowIonicPluginPlugin.swift +49 -0
- package/ios/Tests/SurveySparrowIonicPluginPluginTests/SurveySparrowIonicPluginPluginTests.swift +67 -0
- package/package.json +80 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface SurveySparrowIonicPluginPlugin {
|
|
2
|
+
loadFullScreenSurvey(options: {
|
|
3
|
+
domain: String;
|
|
4
|
+
token: String;
|
|
5
|
+
params: Array<Object>;
|
|
6
|
+
properties: Object;
|
|
7
|
+
}): Promise<void>;
|
|
8
|
+
loadFullScreenSurveyWithValidation(options: {
|
|
9
|
+
domain: String;
|
|
10
|
+
token: String;
|
|
11
|
+
params: Array<Object>;
|
|
12
|
+
properties: Object;
|
|
13
|
+
}): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface SurveySparrowIonicPluginPlugin {\n \n loadFullScreenSurvey(options: {\n domain: String;\n token: String;\n params: Array<Object>;\n properties: Object;\n }): Promise<void>;\n \n loadFullScreenSurveyWithValidation(options: {\n domain: String;\n token: String;\n params: Array<Object>;\n properties: Object;\n }): Promise<void>;\n \n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,wBAAwB,GAAG,cAAc,CAAiC,0BAA0B,CAAC,CAAC;AAE5G,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,wBAAwB,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { SurveySparrowIonicPluginPlugin } from './definitions';\n\nconst SurveySparrowIonicPlugin = registerPlugin<SurveySparrowIonicPluginPlugin>('SurveySparrowIonicPlugin');\n\nexport * from './definitions';\nexport { SurveySparrowIonicPlugin };\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst SurveySparrowIonicPlugin = registerPlugin('SurveySparrowIonicPlugin');\nexport * from './definitions';\nexport { SurveySparrowIonicPlugin };\n//# sourceMappingURL=index.js.map"],"names":["registerPlugin"],"mappings":";;;;AACK,MAAC,wBAAwB,GAAGA,mBAAc,CAAC,0BAA0B;;;;"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
var capacitorSurveySparrowIonicPlugin = (function (exports, core) {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const SurveySparrowIonicPlugin = core.registerPlugin('SurveySparrowIonicPlugin');
|
|
5
|
+
|
|
6
|
+
exports.SurveySparrowIonicPlugin = SurveySparrowIonicPlugin;
|
|
7
|
+
|
|
8
|
+
return exports;
|
|
9
|
+
|
|
10
|
+
})({}, capacitorExports);
|
|
11
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst SurveySparrowIonicPlugin = registerPlugin('SurveySparrowIonicPlugin');\nexport * from './definitions';\nexport { SurveySparrowIonicPlugin };\n//# sourceMappingURL=index.js.map"],"names":["registerPlugin"],"mappings":";;;AACK,OAAC,wBAAwB,GAAGA,mBAAc,CAAC,0BAA0B;;;;;;;;;;"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
|
|
2
|
+
import Foundation
|
|
3
|
+
import SwiftUI
|
|
4
|
+
import SurveySparrowSdk
|
|
5
|
+
|
|
6
|
+
@objc public class SurveySparrowIonicPlugin: NSObject {
|
|
7
|
+
|
|
8
|
+
@objc public func loadFullScreenSurvey(domain: String, token: String, params: [String: String], properties: [String: Any]) {
|
|
9
|
+
FullScreenSurveyView(domain: domain, token: token, params: params, properties: properties)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
@objc public func loadFullScreenSurveyWithValidation(domain: String, token: String, params: [String: String], properties: [String: Any]) {
|
|
13
|
+
FullScreenSurveyWithValidation(domain: domain, token: token, properties: properties, params: params).startFullScreenSurveyWithValidation()
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
struct FullScreenSurveyView: UIViewControllerRepresentable {
|
|
18
|
+
|
|
19
|
+
var domain: String
|
|
20
|
+
var token: String
|
|
21
|
+
let params: [String: String]
|
|
22
|
+
let properties: [String: Any]
|
|
23
|
+
|
|
24
|
+
@State private var isSurveyLoaded: Bool = false
|
|
25
|
+
|
|
26
|
+
func makeUIViewController(context: Context) -> SsSurveyViewController{
|
|
27
|
+
let ssSurveyViewController = SsSurveyViewController()
|
|
28
|
+
ssSurveyViewController.domain = domain
|
|
29
|
+
ssSurveyViewController.token = token
|
|
30
|
+
ssSurveyViewController.params = params
|
|
31
|
+
ssSurveyViewController.properties = properties
|
|
32
|
+
ssSurveyViewController.getSurveyLoadedResponse = true
|
|
33
|
+
ssSurveyViewController.surveyDelegate = SurveyDelegate()
|
|
34
|
+
return ssSurveyViewController
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
func updateUIViewController(_ uiViewController: SsSurveyViewController, context: Context) {}
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
struct FullScreenSurveyWithValidation {
|
|
42
|
+
|
|
43
|
+
let domain: String?
|
|
44
|
+
let token: String?
|
|
45
|
+
let properties: [String: Any]
|
|
46
|
+
let params: [String: String]?
|
|
47
|
+
|
|
48
|
+
func startFullScreenSurveyWithValidation() {
|
|
49
|
+
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
|
|
50
|
+
let rootViewController = windowScene.windows.first?.rootViewController else {
|
|
51
|
+
print("Error: Unable to access rootViewController.")
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
let surveyView = SsSurveyView(properties: properties)
|
|
56
|
+
surveyView.loadFullscreenSurvey(
|
|
57
|
+
parent: rootViewController,
|
|
58
|
+
delegate: SurveyDelegate(),
|
|
59
|
+
domain: domain,
|
|
60
|
+
token: token,
|
|
61
|
+
params: params
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
class SsDelegate: SsSurveyDelegate {
|
|
67
|
+
public func handleSurveyResponse(response: [String: AnyObject]) {
|
|
68
|
+
print(response)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public func handleSurveyLoaded(response: [String: AnyObject]) {
|
|
72
|
+
print(response)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public func handleSurveyValidation(response: [String: AnyObject]) {
|
|
76
|
+
print(response)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
public func handleCloseButtonTap() {
|
|
80
|
+
print("CloseButtonTapped")
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
@objc(SurveySparrowIonicPluginPlugin)
|
|
5
|
+
public class SurveySparrowIonicPluginPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
6
|
+
|
|
7
|
+
public let identifier = "SurveySparrowIonicPluginPlugin"
|
|
8
|
+
public let jsName = "SurveySparrowIonicPlugin"
|
|
9
|
+
public let pluginMethods: [CAPPluginMethod] = [
|
|
10
|
+
CAPPluginMethod(name: "echo", returnType: CAPPluginReturnPromise)
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
private let implementation = SurveySparrowIonicPlugin()
|
|
14
|
+
|
|
15
|
+
@objc public func loadFullScreenSurvey(_ call: CAPPluginCall) {
|
|
16
|
+
|
|
17
|
+
let domain = call.getString("domain") as? String
|
|
18
|
+
let token = call.getString("token") as? String
|
|
19
|
+
let params = call.getObject("params") as? [String : String]
|
|
20
|
+
let properties = call.getObject("properties") as? [String : Any]
|
|
21
|
+
|
|
22
|
+
guard let domain = domain, let token = token, let params = params, let properties = properties else {
|
|
23
|
+
call.reject("Invalid or missing parameters")
|
|
24
|
+
return
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
DispatchQueue.main.async {
|
|
28
|
+
self.implementation.loadFullScreenSurvey(domain: domain, token: token, params: params, properties: properties)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@objc public func loadFullScreenSurveyWithValidation(_ call: CAPPluginCall) {
|
|
34
|
+
|
|
35
|
+
let domain = call.getString("domain") as? String
|
|
36
|
+
let token = call.getString("token") as? String
|
|
37
|
+
let params = call.getObject("params") as? [String : String]
|
|
38
|
+
let properties = call.getObject("properties") as? [String : Any]
|
|
39
|
+
|
|
40
|
+
guard let domain = domain, let token = token, let params = params, let properties = properties else {
|
|
41
|
+
call.reject("Invalid or missing parameters")
|
|
42
|
+
return
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
DispatchQueue.main.async {
|
|
46
|
+
self.implementation.loadFullScreenSurveyWithValidation(domain: domain, token: token, params: params, properties: properties)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
package/ios/Tests/SurveySparrowIonicPluginPluginTests/SurveySparrowIonicPluginPluginTests.swift
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import XCTest
|
|
2
|
+
@testable import SurveySparrowIonicPluginPlugin
|
|
3
|
+
|
|
4
|
+
class SurveySparrowIonicPluginPluginTests: XCTestCase {
|
|
5
|
+
|
|
6
|
+
var plugin: SurveySparrowIonicPluginPlugin!
|
|
7
|
+
var mockCall: CAPPluginCall!
|
|
8
|
+
|
|
9
|
+
override func setUp() {
|
|
10
|
+
super.setUp()
|
|
11
|
+
plugin = SurveySparrowIonicPluginPlugin()
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
override func tearDown() {
|
|
15
|
+
plugin = nil
|
|
16
|
+
mockCall = nil
|
|
17
|
+
super.tearDown()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
func testLoadFullScreenSurvey() {
|
|
21
|
+
|
|
22
|
+
let domain = "gokulkrishnaraju1183.surveysparrow.com"
|
|
23
|
+
let token = "tt-ChaSVQWRDF7"
|
|
24
|
+
let params: [String: String] = ["emailaddress": "email@email.com", "email": "email@email.com"]
|
|
25
|
+
let properties: [String: Any] = [
|
|
26
|
+
"sparrowLang": "en",
|
|
27
|
+
"isCloseButtonEnabled": true
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
mockCall = CAPPluginCall(callbackId: "testCallbackId", options: [
|
|
31
|
+
"domain": domain,
|
|
32
|
+
"token": token,
|
|
33
|
+
"params": params,
|
|
34
|
+
"properties": properties
|
|
35
|
+
]) { result, _ in
|
|
36
|
+
XCTAssertNotNil(result)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
plugin.loadFullScreenSurvey(mockCall)
|
|
40
|
+
|
|
41
|
+
XCTAssertNotNil(plugin)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
func testLoadFullScreenSurveyWithValidation() {
|
|
45
|
+
|
|
46
|
+
let domain = "gokulkrishnaraju1183.surveysparrow.com"
|
|
47
|
+
let token = "tt-ChaSVQWRDF7"
|
|
48
|
+
let params: [String: String] = ["emailaddress": "email@email.com", "email": "email@email.com"]
|
|
49
|
+
let properties: [String: Any] = [
|
|
50
|
+
"sparrowLang": "en",
|
|
51
|
+
"isCloseButtonEnabled": true
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
mockCall = CAPPluginCall(callbackId: "testCallbackId", options: [
|
|
55
|
+
"domain": domain,
|
|
56
|
+
"token": token,
|
|
57
|
+
"params": params,
|
|
58
|
+
"properties": properties
|
|
59
|
+
]) { result, _ in
|
|
60
|
+
XCTAssertNotNil(result)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
plugin.loadFullScreenSurveyWithValidation(mockCall)
|
|
64
|
+
|
|
65
|
+
XCTAssertNotNil(plugin)
|
|
66
|
+
}
|
|
67
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "surveysparrow-ionic-plugin",
|
|
3
|
+
"version": "0.0.1",
|
|
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
|
+
"main": "dist/plugin.cjs.js",
|
|
6
|
+
"module": "dist/esm/index.js",
|
|
7
|
+
"types": "dist/esm/index.d.ts",
|
|
8
|
+
"unpkg": "dist/plugin.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"android/src/main/",
|
|
11
|
+
"android/build.gradle",
|
|
12
|
+
"dist/",
|
|
13
|
+
"ios/Sources",
|
|
14
|
+
"ios/Tests",
|
|
15
|
+
"Package.swift",
|
|
16
|
+
"SurveysparrowIonicPlugin.podspec"
|
|
17
|
+
],
|
|
18
|
+
"author": "Gokulkrishna-Raju",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/surveysparrow/surveysparrow-ionic-plugin.git"
|
|
23
|
+
},
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/surveysparrow/surveysparrow-ionic-plugin/issues"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"capacitor",
|
|
29
|
+
"plugin",
|
|
30
|
+
"native"
|
|
31
|
+
],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
|
|
34
|
+
"verify:ios": "xcodebuild -scheme SurveysparrowIonicPlugin -destination generic/platform=iOS",
|
|
35
|
+
"verify:android": "cd android && ./gradlew clean build test && cd ..",
|
|
36
|
+
"verify:web": "npm run build",
|
|
37
|
+
"lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
|
|
38
|
+
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
|
|
39
|
+
"eslint": "eslint . --ext ts",
|
|
40
|
+
"prettier": "prettier \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
|
|
41
|
+
"swiftlint": "node-swiftlint",
|
|
42
|
+
"docgen": "docgen --api SurveySparrowIonicPluginPlugin --output-readme README.md --output-json dist/docs.json",
|
|
43
|
+
"build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.mjs",
|
|
44
|
+
"clean": "rimraf ./dist",
|
|
45
|
+
"watch": "tsc --watch",
|
|
46
|
+
"prepublishOnly": "npm run build"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@capacitor/android": "^7.0.0",
|
|
50
|
+
"@capacitor/core": "^7.0.0",
|
|
51
|
+
"@capacitor/docgen": "^0.3.0",
|
|
52
|
+
"@capacitor/ios": "^7.0.0",
|
|
53
|
+
"@ionic/eslint-config": "^0.4.0",
|
|
54
|
+
"@ionic/prettier-config": "^4.0.0",
|
|
55
|
+
"@ionic/swiftlint-config": "^2.0.0",
|
|
56
|
+
"eslint": "^8.57.0",
|
|
57
|
+
"prettier": "^3.4.2",
|
|
58
|
+
"prettier-plugin-java": "^2.6.6",
|
|
59
|
+
"rimraf": "^6.0.1",
|
|
60
|
+
"rollup": "^4.30.1",
|
|
61
|
+
"swiftlint": "^2.0.0",
|
|
62
|
+
"typescript": "~4.1.5"
|
|
63
|
+
},
|
|
64
|
+
"peerDependencies": {
|
|
65
|
+
"@capacitor/core": ">=7.0.0"
|
|
66
|
+
},
|
|
67
|
+
"prettier": "@ionic/prettier-config",
|
|
68
|
+
"swiftlint": "@ionic/swiftlint-config",
|
|
69
|
+
"eslintConfig": {
|
|
70
|
+
"extends": "@ionic/eslint-config/recommended"
|
|
71
|
+
},
|
|
72
|
+
"capacitor": {
|
|
73
|
+
"ios": {
|
|
74
|
+
"src": "ios"
|
|
75
|
+
},
|
|
76
|
+
"android": {
|
|
77
|
+
"src": "android"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|