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,17 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = 'SurveysparrowIonicPlugin'
|
|
7
|
+
s.version = package['version']
|
|
8
|
+
s.summary = package['description']
|
|
9
|
+
s.license = package['license']
|
|
10
|
+
s.homepage = package['repository']['url']
|
|
11
|
+
s.author = package['author']
|
|
12
|
+
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
|
|
13
|
+
s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
|
+
s.ios.deployment_target = '14.0'
|
|
15
|
+
s.dependency 'Capacitor'
|
|
16
|
+
s.swift_version = '5.1'
|
|
17
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
ext {
|
|
2
|
+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.0'
|
|
4
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.2.1'
|
|
5
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.6.1'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
buildscript {
|
|
9
|
+
repositories {
|
|
10
|
+
google()
|
|
11
|
+
mavenCentral()
|
|
12
|
+
}
|
|
13
|
+
dependencies {
|
|
14
|
+
classpath 'com.android.tools.build:gradle:8.6.1'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
apply plugin: 'com.android.library'
|
|
19
|
+
|
|
20
|
+
android {
|
|
21
|
+
namespace "com.surveysparrow.plugins.ionic"
|
|
22
|
+
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 35
|
|
23
|
+
defaultConfig {
|
|
24
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 23
|
|
25
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 35
|
|
26
|
+
versionCode 1
|
|
27
|
+
versionName "1.0"
|
|
28
|
+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
29
|
+
}
|
|
30
|
+
buildTypes {
|
|
31
|
+
release {
|
|
32
|
+
minifyEnabled false
|
|
33
|
+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
lintOptions {
|
|
37
|
+
abortOnError false
|
|
38
|
+
}
|
|
39
|
+
compileOptions {
|
|
40
|
+
sourceCompatibility JavaVersion.VERSION_21
|
|
41
|
+
targetCompatibility JavaVersion.VERSION_21
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
repositories {
|
|
46
|
+
google()
|
|
47
|
+
mavenCentral()
|
|
48
|
+
maven { url 'https://jitpack.io' }
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
dependencies {
|
|
53
|
+
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
54
|
+
implementation project(':capacitor-android')
|
|
55
|
+
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
56
|
+
testImplementation "junit:junit:$junitVersion"
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
implementation "com.github.surveysparrow:surveysparrow-android-sdk:0.6.3"
|
|
60
|
+
|
|
61
|
+
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
62
|
+
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
63
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
package com.surveysparrow.plugins.ionic;
|
|
2
|
+
|
|
3
|
+
import android.util.Log;
|
|
4
|
+
|
|
5
|
+
import androidx.appcompat.app.AppCompatActivity;
|
|
6
|
+
|
|
7
|
+
import com.getcapacitor.PluginCall;
|
|
8
|
+
import com.surveysparrow.ss_android_sdk.OnSsResponseEventListener;
|
|
9
|
+
import com.surveysparrow.ss_android_sdk.OnSsValidateSurveyEventListener;
|
|
10
|
+
import com.surveysparrow.ss_android_sdk.SsSurvey;
|
|
11
|
+
import com.surveysparrow.ss_android_sdk.SsSurvey.CustomParam;
|
|
12
|
+
import com.surveysparrow.ss_android_sdk.SurveySparrow;
|
|
13
|
+
import org.json.JSONObject;
|
|
14
|
+
import java.util.HashMap;
|
|
15
|
+
|
|
16
|
+
public class SurveySparrowIonicPlugin implements OnSsValidateSurveyEventListener, OnSsResponseEventListener {
|
|
17
|
+
|
|
18
|
+
private static final int SURVEY_REQUEST_CODE = 1;
|
|
19
|
+
private static final int SURVEY_SCHEDULE_REQUEST_CODE = 2;
|
|
20
|
+
private AppCompatActivity activity;
|
|
21
|
+
|
|
22
|
+
public SurveySparrowIonicPlugin(AppCompatActivity activity) {
|
|
23
|
+
activity = activity;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public void loadFullScreenSurvey(String domain, String token, CustomParam[] params, HashMap properties) {
|
|
27
|
+
if(activity == null) {
|
|
28
|
+
throw new RuntimeException("Activity is null. Error fetching activity.");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
SsSurvey survey = new SsSurvey(domain, token, params, properties);
|
|
32
|
+
SurveySparrow surveySparrow = new SurveySparrow(activity, survey)
|
|
33
|
+
.enableBackButton(true)
|
|
34
|
+
.setWaitTime(2000);
|
|
35
|
+
|
|
36
|
+
surveySparrow.startSurveyForResult(SURVEY_REQUEST_CODE);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public void loadFullScreenSurveyWithValidation(String domain, String token, CustomParam[] params, HashMap properties) {
|
|
40
|
+
SsSurvey survey = new SsSurvey(domain, token, params, properties);
|
|
41
|
+
SurveySparrow surveySparrow = new SurveySparrow(activity, survey)
|
|
42
|
+
.enableBackButton(true)
|
|
43
|
+
.setWaitTime(2000);
|
|
44
|
+
|
|
45
|
+
surveySparrow.scheduleSurvey(SURVEY_SCHEDULE_REQUEST_CODE);
|
|
46
|
+
surveySparrow.setValidateSurveyListener(this);
|
|
47
|
+
surveySparrow.startSurvey(SURVEY_REQUEST_CODE);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@Override
|
|
51
|
+
public void onSsValidateSurvey(JSONObject jsonObject) {
|
|
52
|
+
Log.v("SurveySparrow", "Survey validation error json: " + jsonObject.toString());
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@Override
|
|
56
|
+
public void onSsResponseEvent(JSONObject jsonObject) {
|
|
57
|
+
Log.v("SurveySparrow", "Survey response received: " + jsonObject.toString());
|
|
58
|
+
}
|
|
59
|
+
}
|
package/android/src/main/java/com/surveysparrow/plugins/ionic/SurveySparrowIonicPluginPlugin.java
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
package com.surveysparrow.plugins.ionic;
|
|
2
|
+
|
|
3
|
+
import com.getcapacitor.JSArray;
|
|
4
|
+
import com.getcapacitor.JSObject;
|
|
5
|
+
import com.getcapacitor.Plugin;
|
|
6
|
+
import com.getcapacitor.PluginCall;
|
|
7
|
+
import com.getcapacitor.PluginMethod;
|
|
8
|
+
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
9
|
+
|
|
10
|
+
import com.surveysparrow.ss_android_sdk.SsSurvey.CustomParam;
|
|
11
|
+
import org.json.JSONException;
|
|
12
|
+
import java.util.HashMap;
|
|
13
|
+
import java.util.Iterator;
|
|
14
|
+
|
|
15
|
+
@CapacitorPlugin(name = "SurveySparrowIonicPlugin")
|
|
16
|
+
public class SurveySparrowIonicPluginPlugin extends Plugin {
|
|
17
|
+
|
|
18
|
+
private final SurveySparrowIonicPlugin implementation = new SurveySparrowIonicPlugin(this.getActivity());
|
|
19
|
+
|
|
20
|
+
@PluginMethod
|
|
21
|
+
public void loadFullScreenSurvey(PluginCall call) {
|
|
22
|
+
String domain = call.getString("domain");
|
|
23
|
+
String token = call.getString("token");
|
|
24
|
+
CustomParam[] params = parseParams(call.getArray("params"));
|
|
25
|
+
HashMap<String, String> properties = parseProperties(call.getObject("properties"));
|
|
26
|
+
|
|
27
|
+
implementation.loadFullScreenSurvey(domain, token, params, properties);
|
|
28
|
+
call.resolve();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@PluginMethod
|
|
32
|
+
public void loadFullScreenSurveyWithValidation(PluginCall call) {
|
|
33
|
+
String domain = call.getString("domain");
|
|
34
|
+
String token = call.getString("token");
|
|
35
|
+
CustomParam[] params = parseParams(call.getArray("params"));
|
|
36
|
+
HashMap<String, String> properties = parseProperties(call.getObject("properties"));
|
|
37
|
+
|
|
38
|
+
implementation.loadFullScreenSurveyWithValidation(domain, token, params, properties);
|
|
39
|
+
call.resolve();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private CustomParam[] parseParams(JSArray jsParams) {
|
|
43
|
+
if (jsParams == null || jsParams.length() == 0) {
|
|
44
|
+
return new CustomParam[0];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
CustomParam[] params = new CustomParam[jsParams.length()];
|
|
48
|
+
|
|
49
|
+
for (int i = 0; i < jsParams.length(); i++) {
|
|
50
|
+
try {
|
|
51
|
+
JSObject paramObj = (JSObject) jsParams.get(i);
|
|
52
|
+
String key = paramObj.getString("key");
|
|
53
|
+
String value = paramObj.getString("value");
|
|
54
|
+
params[i] = new CustomParam(key, value);
|
|
55
|
+
} catch (JSONException e) {
|
|
56
|
+
throw new RuntimeException("Invalid parameter at index " + i, e);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return params;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
private HashMap<String, String> parseProperties(JSObject jsProperties) {
|
|
64
|
+
HashMap<String, String> properties = new HashMap<>();
|
|
65
|
+
if (jsProperties != null) {
|
|
66
|
+
for (Iterator<String> it = jsProperties.keys(); it.hasNext(); ) {
|
|
67
|
+
String key = it.next();
|
|
68
|
+
properties.put(key, jsProperties.getString(key));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return properties;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
File without changes
|