@dghathway/firebase-remote-config 0.1.7 → 2.0.0
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/CapacitorCommunityFirebaseRemoteConfig.podspec +4 -3
- package/DghathwayFirebaseRemoteConfig.podspec +5 -4
- package/android/build.gradle +16 -13
- package/android/gradle/wrapper/gradle-wrapper.properties +1 -2
- package/android/src/main/AndroidManifest.xml +2 -5
- package/android/src/main/java/com/getcapacitor/community/firebaserc/FirebaseRemoteConfig.java +44 -64
- package/dist/esm/definitions.js +1 -0
- package/dist/esm/web.d.ts +2 -2
- package/dist/esm/web.js +106 -125
- package/dist/esm/web.js.map +1 -1
- package/ios/Plugin/Plugin.m +1 -3
- package/ios/Plugin/Plugin.swift +112 -78
- package/ios/Podfile +2 -3
- package/package.json +8 -18
- package/android/.npmignore +0 -1
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
|
|
2
2
|
Pod::Spec.new do |s|
|
|
3
3
|
s.name = 'CapacitorCommunityFirebaseRemoteConfig'
|
|
4
|
-
s.version = '0.
|
|
4
|
+
s.version = '2.0.0'
|
|
5
5
|
s.summary = 'A native plugin for firebase remote config'
|
|
6
6
|
s.license = 'MIT'
|
|
7
7
|
s.homepage = 'https://github.com/capacitor-community/firebase-remote-config'
|
|
8
8
|
s.author = 'Priyank Patel <priyank.patel@stackspace.ca>'
|
|
9
9
|
s.source = { :git => 'https://github.com/capacitor-community/firebase-remote-config', :tag => s.version.to_s }
|
|
10
10
|
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
11
|
-
s.ios.deployment_target = '
|
|
11
|
+
s.ios.deployment_target = '13.4'
|
|
12
|
+
s.swift_version = '5.9'
|
|
12
13
|
s.dependency 'Capacitor'
|
|
13
14
|
s.static_framework = true
|
|
14
|
-
s.dependency 'Firebase/RemoteConfig'
|
|
15
|
+
s.dependency 'Firebase/RemoteConfig', '~> 11.0'
|
|
15
16
|
end
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
|
|
2
2
|
Pod::Spec.new do |s|
|
|
3
|
-
s.name = '
|
|
4
|
-
s.version = '0.
|
|
3
|
+
s.name = 'DghathwayFirebaseRemoteConfig'
|
|
4
|
+
s.version = '2.0.0'
|
|
5
5
|
s.summary = 'A native plugin for firebase remote config'
|
|
6
6
|
s.license = 'MIT'
|
|
7
7
|
s.homepage = 'https://github.com/capacitor-community/firebase-remote-config'
|
|
8
8
|
s.author = 'Priyank Patel <priyank.patel@stackspace.ca>'
|
|
9
9
|
s.source = { :git => 'https://github.com/dghathway/firebase-remote-config', :tag => s.version.to_s }
|
|
10
10
|
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
11
|
-
s.ios.deployment_target = '
|
|
11
|
+
s.ios.deployment_target = '13.4'
|
|
12
|
+
s.swift_version = '5.9'
|
|
12
13
|
s.dependency 'Capacitor'
|
|
13
14
|
s.static_framework = true
|
|
14
|
-
s.dependency 'Firebase/RemoteConfig'
|
|
15
|
+
s.dependency 'Firebase/RemoteConfig', '~> 11.0'
|
|
15
16
|
end
|
package/android/build.gradle
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
ext {
|
|
2
|
-
junitVersion =
|
|
3
|
-
androidxAppCompatVersion =
|
|
4
|
-
androidxJunitVersion =
|
|
5
|
-
androidxEspressoCoreVersion =
|
|
2
|
+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.6.1'
|
|
4
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.5'
|
|
5
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.5.1'
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
buildscript {
|
|
9
9
|
repositories {
|
|
10
10
|
google()
|
|
11
|
-
|
|
11
|
+
mavenCentral()
|
|
12
12
|
}
|
|
13
13
|
dependencies {
|
|
14
|
-
classpath 'com.android.tools.build:gradle:
|
|
15
|
-
classpath 'com.google.gms:google-services:4.3.3'
|
|
14
|
+
classpath 'com.android.tools.build:gradle:8.2.1'
|
|
16
15
|
}
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
apply plugin: 'com.android.library'
|
|
20
19
|
|
|
21
20
|
android {
|
|
22
|
-
|
|
21
|
+
namespace "com.getcapacitor.community.firebaserc"
|
|
22
|
+
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 34
|
|
23
23
|
defaultConfig {
|
|
24
|
-
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion :
|
|
25
|
-
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion :
|
|
24
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
|
|
25
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 34
|
|
26
26
|
versionCode 1
|
|
27
27
|
versionName "1.0"
|
|
28
28
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
@@ -36,21 +36,24 @@ android {
|
|
|
36
36
|
lintOptions {
|
|
37
37
|
abortOnError false
|
|
38
38
|
}
|
|
39
|
+
compileOptions {
|
|
40
|
+
sourceCompatibility JavaVersion.VERSION_17
|
|
41
|
+
targetCompatibility JavaVersion.VERSION_17
|
|
42
|
+
}
|
|
39
43
|
}
|
|
40
44
|
|
|
41
45
|
repositories {
|
|
42
46
|
google()
|
|
43
|
-
jcenter()
|
|
44
47
|
mavenCentral()
|
|
45
48
|
}
|
|
46
49
|
|
|
47
|
-
|
|
48
50
|
dependencies {
|
|
49
51
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
50
52
|
implementation project(':capacitor-android')
|
|
51
53
|
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
54
|
+
implementation platform('com.google.firebase:firebase-bom:33.7.0')
|
|
55
|
+
implementation 'com.google.firebase:firebase-config'
|
|
52
56
|
testImplementation "junit:junit:$junitVersion"
|
|
53
57
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
54
58
|
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
55
|
-
implementation 'com.google.firebase:firebase-config:19.1.4'
|
|
56
59
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
#Fri Dec 01 12:41:00 CST 2017
|
|
2
1
|
distributionBase=GRADLE_USER_HOME
|
|
3
2
|
distributionPath=wrapper/dists
|
|
4
3
|
zipStoreBase=GRADLE_USER_HOME
|
|
5
4
|
zipStorePath=wrapper/dists
|
|
6
|
-
distributionUrl=https\://services.gradle.org/distributions/gradle-
|
|
5
|
+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-all.zip
|
package/android/src/main/java/com/getcapacitor/community/firebaserc/FirebaseRemoteConfig.java
CHANGED
|
@@ -2,13 +2,10 @@ package com.getcapacitor.community.firebaserc;
|
|
|
2
2
|
|
|
3
3
|
import static com.getcapacitor.community.firebaserc.Constant.ERROR_MISSING_KEY;
|
|
4
4
|
|
|
5
|
-
import android.Manifest;
|
|
6
5
|
import android.Manifest;
|
|
7
6
|
import android.content.Context;
|
|
8
|
-
import android.os.Bundle;
|
|
9
7
|
import androidx.annotation.NonNull;
|
|
10
8
|
import com.getcapacitor.JSObject;
|
|
11
|
-
import com.getcapacitor.NativePlugin;
|
|
12
9
|
import com.getcapacitor.Plugin;
|
|
13
10
|
import com.getcapacitor.PluginCall;
|
|
14
11
|
import com.getcapacitor.PluginMethod;
|
|
@@ -20,7 +17,6 @@ import com.google.android.gms.tasks.Task;
|
|
|
20
17
|
import com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings;
|
|
21
18
|
import com.google.firebase.remoteconfig.FirebaseRemoteConfigValue;
|
|
22
19
|
import java.util.Collections;
|
|
23
|
-
import java.util.Iterator;
|
|
24
20
|
import java.util.Objects;
|
|
25
21
|
|
|
26
22
|
@CapacitorPlugin(
|
|
@@ -70,7 +66,7 @@ public class FirebaseRemoteConfig extends Plugin {
|
|
|
70
66
|
.build();
|
|
71
67
|
this.mFirebaseRemoteConfig.setConfigSettingsAsync(configSettings);
|
|
72
68
|
|
|
73
|
-
call.
|
|
69
|
+
call.resolve();
|
|
74
70
|
}
|
|
75
71
|
|
|
76
72
|
@PluginMethod
|
|
@@ -79,17 +75,12 @@ public class FirebaseRemoteConfig extends Plugin {
|
|
|
79
75
|
.addOnCompleteListener(
|
|
80
76
|
bridge.getActivity(),
|
|
81
77
|
new OnCompleteListener<Void>() {
|
|
82
|
-
|
|
83
78
|
@Override
|
|
84
79
|
public void onComplete(@NonNull Task<Void> task) {
|
|
85
80
|
if (task.isSuccessful()) {
|
|
86
|
-
call.
|
|
87
|
-
} else if (task.isCanceled()) {
|
|
88
|
-
call.error(
|
|
89
|
-
Objects.requireNonNull(task.getException()).getMessage()
|
|
90
|
-
);
|
|
81
|
+
call.resolve();
|
|
91
82
|
} else {
|
|
92
|
-
call.
|
|
83
|
+
call.reject(
|
|
93
84
|
Objects.requireNonNull(task.getException()).getMessage()
|
|
94
85
|
);
|
|
95
86
|
}
|
|
@@ -104,17 +95,12 @@ public class FirebaseRemoteConfig extends Plugin {
|
|
|
104
95
|
.addOnCompleteListener(
|
|
105
96
|
bridge.getActivity(),
|
|
106
97
|
new OnCompleteListener<Boolean>() {
|
|
107
|
-
|
|
108
98
|
@Override
|
|
109
99
|
public void onComplete(@NonNull Task<Boolean> task) {
|
|
110
100
|
if (task.isSuccessful()) {
|
|
111
|
-
call.
|
|
112
|
-
} else if (task.isCanceled()) {
|
|
113
|
-
call.error(
|
|
114
|
-
Objects.requireNonNull(task.getException()).getMessage()
|
|
115
|
-
);
|
|
101
|
+
call.resolve();
|
|
116
102
|
} else {
|
|
117
|
-
call.
|
|
103
|
+
call.reject(
|
|
118
104
|
Objects.requireNonNull(task.getException()).getMessage()
|
|
119
105
|
);
|
|
120
106
|
}
|
|
@@ -129,17 +115,12 @@ public class FirebaseRemoteConfig extends Plugin {
|
|
|
129
115
|
.addOnCompleteListener(
|
|
130
116
|
bridge.getActivity(),
|
|
131
117
|
new OnCompleteListener<Boolean>() {
|
|
132
|
-
|
|
133
118
|
@Override
|
|
134
119
|
public void onComplete(@NonNull Task<Boolean> task) {
|
|
135
120
|
if (task.isSuccessful()) {
|
|
136
|
-
call.
|
|
137
|
-
} else if (task.isCanceled()) {
|
|
138
|
-
call.error(
|
|
139
|
-
Objects.requireNonNull(task.getException()).getMessage()
|
|
140
|
-
);
|
|
121
|
+
call.resolve();
|
|
141
122
|
} else {
|
|
142
|
-
call.
|
|
123
|
+
call.reject(
|
|
143
124
|
Objects.requireNonNull(task.getException()).getMessage()
|
|
144
125
|
);
|
|
145
126
|
}
|
|
@@ -148,10 +129,9 @@ public class FirebaseRemoteConfig extends Plugin {
|
|
|
148
129
|
)
|
|
149
130
|
.addOnFailureListener(
|
|
150
131
|
new OnFailureListener() {
|
|
151
|
-
|
|
152
132
|
@Override
|
|
153
133
|
public void onFailure(@NonNull Exception e) {
|
|
154
|
-
call.
|
|
134
|
+
call.reject(e.getLocalizedMessage());
|
|
155
135
|
}
|
|
156
136
|
}
|
|
157
137
|
);
|
|
@@ -159,58 +139,58 @@ public class FirebaseRemoteConfig extends Plugin {
|
|
|
159
139
|
|
|
160
140
|
@PluginMethod
|
|
161
141
|
public void getBoolean(PluginCall call) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
result.put("value", getFirebaseRCValue(key).asBoolean());
|
|
167
|
-
result.put("source", getFirebaseRCValue(key).getSource());
|
|
168
|
-
call.success(result);
|
|
169
|
-
} else {
|
|
170
|
-
call.error(ERROR_MISSING_KEY);
|
|
142
|
+
String key = call.getString("key");
|
|
143
|
+
if (key == null) {
|
|
144
|
+
call.reject(ERROR_MISSING_KEY);
|
|
145
|
+
return;
|
|
171
146
|
}
|
|
147
|
+
JSObject result = new JSObject();
|
|
148
|
+
result.put("key", key);
|
|
149
|
+
result.put("value", getFirebaseRCValue(key).asBoolean());
|
|
150
|
+
result.put("source", getFirebaseRCValue(key).getSource());
|
|
151
|
+
call.resolve(result);
|
|
172
152
|
}
|
|
173
153
|
|
|
174
154
|
@PluginMethod
|
|
175
155
|
public void getByteArray(PluginCall call) {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
result.put("value", getFirebaseRCValue(key).asByteArray());
|
|
181
|
-
result.put("source", getFirebaseRCValue(key).getSource());
|
|
182
|
-
call.success(result);
|
|
183
|
-
} else {
|
|
184
|
-
call.error(ERROR_MISSING_KEY);
|
|
156
|
+
String key = call.getString("key");
|
|
157
|
+
if (key == null) {
|
|
158
|
+
call.reject(ERROR_MISSING_KEY);
|
|
159
|
+
return;
|
|
185
160
|
}
|
|
161
|
+
JSObject result = new JSObject();
|
|
162
|
+
result.put("key", key);
|
|
163
|
+
result.put("value", getFirebaseRCValue(key).asByteArray());
|
|
164
|
+
result.put("source", getFirebaseRCValue(key).getSource());
|
|
165
|
+
call.resolve(result);
|
|
186
166
|
}
|
|
187
167
|
|
|
188
168
|
@PluginMethod
|
|
189
169
|
public void getNumber(PluginCall call) {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
result.put("value", getFirebaseRCValue(key).asDouble());
|
|
195
|
-
result.put("source", getFirebaseRCValue(key).getSource());
|
|
196
|
-
call.success(result);
|
|
197
|
-
} else {
|
|
198
|
-
call.error(ERROR_MISSING_KEY);
|
|
170
|
+
String key = call.getString("key");
|
|
171
|
+
if (key == null) {
|
|
172
|
+
call.reject(ERROR_MISSING_KEY);
|
|
173
|
+
return;
|
|
199
174
|
}
|
|
175
|
+
JSObject result = new JSObject();
|
|
176
|
+
result.put("key", key);
|
|
177
|
+
result.put("value", getFirebaseRCValue(key).asDouble());
|
|
178
|
+
result.put("source", getFirebaseRCValue(key).getSource());
|
|
179
|
+
call.resolve(result);
|
|
200
180
|
}
|
|
201
181
|
|
|
202
182
|
@PluginMethod
|
|
203
183
|
public void getString(PluginCall call) {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
result.put("value", getFirebaseRCValue(key).asString());
|
|
209
|
-
result.put("source", getFirebaseRCValue(key).getSource());
|
|
210
|
-
call.success(result);
|
|
211
|
-
} else {
|
|
212
|
-
call.error(ERROR_MISSING_KEY);
|
|
184
|
+
String key = call.getString("key");
|
|
185
|
+
if (key == null) {
|
|
186
|
+
call.reject(ERROR_MISSING_KEY);
|
|
187
|
+
return;
|
|
213
188
|
}
|
|
189
|
+
JSObject result = new JSObject();
|
|
190
|
+
result.put("key", key);
|
|
191
|
+
result.put("value", getFirebaseRCValue(key).asString());
|
|
192
|
+
result.put("source", getFirebaseRCValue(key).getSource());
|
|
193
|
+
call.resolve(result);
|
|
214
194
|
}
|
|
215
195
|
|
|
216
196
|
private FirebaseRemoteConfigValue getFirebaseRCValue(String key) {
|
package/dist/esm/definitions.js
CHANGED
package/dist/esm/web.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { WebPlugin } from "@capacitor/core";
|
|
2
|
-
import { FirebaseRemoteConfigPlugin, RCValueOption, RCReturnData, RCReturnDataArray } from "./definitions";
|
|
2
|
+
import type { FirebaseRemoteConfigPlugin, RCValueOption, RCReturnData, RCReturnDataArray } from "./definitions";
|
|
3
3
|
export declare class FirebaseRemoteConfigWeb extends WebPlugin implements FirebaseRemoteConfigPlugin {
|
|
4
|
-
readonly ready: Promise<
|
|
4
|
+
readonly ready: Promise<void>;
|
|
5
5
|
private readyResolver;
|
|
6
6
|
private remoteConfigRef;
|
|
7
7
|
private scripts;
|
package/dist/esm/web.js
CHANGED
|
@@ -1,142 +1,119 @@
|
|
|
1
1
|
import { WebPlugin } from "@capacitor/core";
|
|
2
2
|
export class FirebaseRemoteConfigWeb extends WebPlugin {
|
|
3
3
|
constructor() {
|
|
4
|
-
super(
|
|
5
|
-
name: "FirebaseRemoteConfig",
|
|
6
|
-
platforms: ["web"],
|
|
7
|
-
});
|
|
4
|
+
super();
|
|
8
5
|
this.scripts = [
|
|
9
6
|
{
|
|
10
7
|
key: "firebase-app",
|
|
11
|
-
src: "https://www.gstatic.com/firebasejs/
|
|
8
|
+
src: "https://www.gstatic.com/firebasejs/10.14.1/firebase-app-compat.js",
|
|
12
9
|
},
|
|
13
10
|
{
|
|
14
11
|
key: "firebase-rc",
|
|
15
|
-
src: "https://www.gstatic.com/firebasejs/
|
|
12
|
+
src: "https://www.gstatic.com/firebasejs/10.14.1/firebase-remote-config-compat.js",
|
|
16
13
|
},
|
|
17
14
|
];
|
|
18
15
|
this.ready = new Promise((resolve) => (this.readyResolver = resolve));
|
|
19
16
|
this.configure();
|
|
20
17
|
}
|
|
21
|
-
initializeFirebase(options) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
reject("Firebase App already initialized.");
|
|
31
|
-
});
|
|
18
|
+
async initializeFirebase(options) {
|
|
19
|
+
await this.ready;
|
|
20
|
+
if (options && !this.isFirebaseInitialized()) {
|
|
21
|
+
const app = window.firebase.initializeApp(options);
|
|
22
|
+
this.remoteConfigRef = app.remoteConfig();
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
throw new Error("Firebase App already initialized.");
|
|
32
26
|
}
|
|
33
|
-
setDefaultWebConfig(options) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
this.remoteConfigRef.defaultConfig = options;
|
|
45
|
-
resolve();
|
|
46
|
-
});
|
|
27
|
+
async setDefaultWebConfig(options) {
|
|
28
|
+
await this.ready;
|
|
29
|
+
if (!options) {
|
|
30
|
+
throw new Error("No default configuration found.");
|
|
31
|
+
}
|
|
32
|
+
if (!this.remoteConfigRef) {
|
|
33
|
+
throw new Error("Remote config is not initialized. Make sure initializeFirebase() is called first.");
|
|
34
|
+
}
|
|
35
|
+
this.remoteConfigRef.defaultConfig = options;
|
|
47
36
|
}
|
|
48
|
-
initialize(options) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
minimumFetchIntervalInSeconds: interval,
|
|
60
|
-
};
|
|
61
|
-
resolve();
|
|
62
|
-
});
|
|
37
|
+
async initialize(options) {
|
|
38
|
+
await this.ready;
|
|
39
|
+
if (!this.remoteConfigRef) {
|
|
40
|
+
throw new Error("Remote config is not initialized. Make sure initializeFirebase() is called first.");
|
|
41
|
+
}
|
|
42
|
+
const interval = options && options.minimumFetchIntervalInSeconds
|
|
43
|
+
? options.minimumFetchIntervalInSeconds
|
|
44
|
+
: 3600;
|
|
45
|
+
this.remoteConfigRef.settings = {
|
|
46
|
+
minimumFetchIntervalInSeconds: interval,
|
|
47
|
+
};
|
|
63
48
|
}
|
|
64
|
-
fetch() {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
this.remoteConfigRef.fetch().then(resolve).catch(reject);
|
|
72
|
-
});
|
|
49
|
+
async fetch() {
|
|
50
|
+
await this.ready;
|
|
51
|
+
if (!this.remoteConfigRef) {
|
|
52
|
+
throw new Error("Remote config is not initialized. Make sure initializeFirebase() is called first.");
|
|
53
|
+
}
|
|
54
|
+
await this.remoteConfigRef.fetch();
|
|
73
55
|
}
|
|
74
|
-
activate() {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
this.remoteConfigRef.activate().then(resolve).catch(reject);
|
|
82
|
-
});
|
|
56
|
+
async activate() {
|
|
57
|
+
await this.ready;
|
|
58
|
+
if (!this.remoteConfigRef) {
|
|
59
|
+
throw new Error("Remote config is not initialized. Make sure initializeFirebase() is called first.");
|
|
60
|
+
}
|
|
61
|
+
await this.remoteConfigRef.activate();
|
|
83
62
|
}
|
|
84
|
-
fetchAndActivate() {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
window.firebase
|
|
92
|
-
.remoteConfig()
|
|
93
|
-
.fetchAndActivate()
|
|
94
|
-
.then((data) => {
|
|
95
|
-
console.log(data);
|
|
96
|
-
resolve(data);
|
|
97
|
-
})
|
|
98
|
-
.catch(reject);
|
|
99
|
-
});
|
|
63
|
+
async fetchAndActivate() {
|
|
64
|
+
await this.ready;
|
|
65
|
+
if (!this.remoteConfigRef) {
|
|
66
|
+
throw new Error("Remote config is not initialized. Make sure initializeFirebase() is called first.");
|
|
67
|
+
}
|
|
68
|
+
await this.remoteConfigRef.fetchAndActivate();
|
|
100
69
|
}
|
|
101
|
-
getBoolean(options) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
70
|
+
async getBoolean(options) {
|
|
71
|
+
await this.ready;
|
|
72
|
+
if (!this.remoteConfigRef) {
|
|
73
|
+
throw new Error("Remote config is not initialized. Make sure initializeFirebase() is called first.");
|
|
74
|
+
}
|
|
75
|
+
const rcValue = this.remoteConfigRef.getValue(options.key);
|
|
76
|
+
return {
|
|
77
|
+
key: options.key,
|
|
78
|
+
value: String(rcValue.asBoolean()),
|
|
79
|
+
source: String(rcValue.getSource()),
|
|
80
|
+
};
|
|
110
81
|
}
|
|
111
|
-
getByteArray(options) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
82
|
+
async getByteArray(options) {
|
|
83
|
+
await this.ready;
|
|
84
|
+
if (!this.remoteConfigRef) {
|
|
85
|
+
throw new Error("Remote config is not initialized. Make sure initializeFirebase() is called first.");
|
|
86
|
+
}
|
|
87
|
+
const rcValue = this.remoteConfigRef.getValue(options.key);
|
|
88
|
+
return {
|
|
89
|
+
key: options.key,
|
|
90
|
+
value: Array.from(rcValue.asString()),
|
|
91
|
+
source: String(rcValue.getSource()),
|
|
92
|
+
};
|
|
120
93
|
}
|
|
121
|
-
getNumber(options) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
94
|
+
async getNumber(options) {
|
|
95
|
+
await this.ready;
|
|
96
|
+
if (!this.remoteConfigRef) {
|
|
97
|
+
throw new Error("Remote config is not initialized. Make sure initializeFirebase() is called first.");
|
|
98
|
+
}
|
|
99
|
+
const rcValue = this.remoteConfigRef.getValue(options.key);
|
|
100
|
+
return {
|
|
101
|
+
key: options.key,
|
|
102
|
+
value: String(rcValue.asNumber()),
|
|
103
|
+
source: String(rcValue.getSource()),
|
|
104
|
+
};
|
|
130
105
|
}
|
|
131
|
-
getString(options) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
106
|
+
async getString(options) {
|
|
107
|
+
await this.ready;
|
|
108
|
+
if (!this.remoteConfigRef) {
|
|
109
|
+
throw new Error("Remote config is not initialized. Make sure initializeFirebase() is called first.");
|
|
110
|
+
}
|
|
111
|
+
const rcValue = this.remoteConfigRef.getValue(options.key);
|
|
112
|
+
return {
|
|
113
|
+
key: options.key,
|
|
114
|
+
value: rcValue.asString(),
|
|
115
|
+
source: String(rcValue.getSource()),
|
|
116
|
+
};
|
|
140
117
|
}
|
|
141
118
|
get remoteConfig() {
|
|
142
119
|
return this.remoteConfigRef;
|
|
@@ -147,12 +124,9 @@ export class FirebaseRemoteConfigWeb extends WebPlugin {
|
|
|
147
124
|
if (window.firebase && this.isFirebaseInitialized()) {
|
|
148
125
|
this.remoteConfigRef = window.firebase.remoteConfig();
|
|
149
126
|
}
|
|
150
|
-
else {
|
|
151
|
-
console.error("Firebase App has not yet initialized.");
|
|
152
|
-
}
|
|
153
127
|
}
|
|
154
128
|
catch (error) {
|
|
155
|
-
|
|
129
|
+
console.error("Failed to load Firebase scripts:", error);
|
|
156
130
|
}
|
|
157
131
|
const interval = setInterval(() => {
|
|
158
132
|
if (!window.firebase) {
|
|
@@ -164,17 +138,24 @@ export class FirebaseRemoteConfigWeb extends WebPlugin {
|
|
|
164
138
|
}
|
|
165
139
|
loadScripts() {
|
|
166
140
|
return new Promise((resolve, reject) => {
|
|
167
|
-
const
|
|
168
|
-
if (document.getElementById(
|
|
169
|
-
document.getElementById(
|
|
170
|
-
|
|
141
|
+
const scriptIds = this.scripts.map((script) => script.key);
|
|
142
|
+
if (document.getElementById(scriptIds[0]) &&
|
|
143
|
+
document.getElementById(scriptIds[1])) {
|
|
144
|
+
resolve();
|
|
145
|
+
return;
|
|
171
146
|
}
|
|
147
|
+
let loaded = 0;
|
|
172
148
|
this.scripts.forEach((script) => {
|
|
173
149
|
const file = document.createElement("script");
|
|
174
150
|
file.type = "text/javascript";
|
|
175
151
|
file.src = script.src;
|
|
176
152
|
file.id = script.key;
|
|
177
|
-
file.onload =
|
|
153
|
+
file.onload = () => {
|
|
154
|
+
loaded++;
|
|
155
|
+
if (loaded === this.scripts.length) {
|
|
156
|
+
resolve();
|
|
157
|
+
}
|
|
158
|
+
};
|
|
178
159
|
file.onerror = reject;
|
|
179
160
|
document.querySelector("head").appendChild(file);
|
|
180
161
|
});
|
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAU5C,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAU5C,MAAM,OAAO,uBACX,SAAQ,SAAS;IAkBjB;QACE,KAAK,EAAE,CAAC;QAZF,YAAO,GAAG;YAChB;gBACE,GAAG,EAAE,cAAc;gBACnB,GAAG,EAAE,mEAAmE;aACzE;YACD;gBACE,GAAG,EAAE,aAAa;gBAClB,GAAG,EAAE,6EAA6E;aACnF;SACF,CAAC;QAKA,IAAI,CAAC,KAAK,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,CAAC,CAAC;QAC5E,IAAI,CAAC,SAAS,EAAE,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,OAAY;QACnC,MAAM,IAAI,CAAC,KAAK,CAAC;QAEjB,IAAI,OAAO,IAAI,CAAC,IAAI,CAAC,qBAAqB,EAAE,EAAE,CAAC;YAC7C,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;YACnD,IAAI,CAAC,eAAe,GAAG,GAAG,CAAC,YAAY,EAAE,CAAC;YAC1C,OAAO;QACT,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,mBAAmB,CAAC,OAAY;QACpC,MAAM,IAAI,CAAC,KAAK,CAAC;QAEjB,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACrD,CAAC;QAED,IAAI,CA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AI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;YACrB,OAAO,KAAK,CAAC;QACf,CAAC;QAED,MAAM,YAAY,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;QAC1C,IAAI,YAAY,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC9C,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
package/ios/Plugin/Plugin.m
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
#import <Foundation/Foundation.h>
|
|
2
2
|
#import <Capacitor/Capacitor.h>
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
// each method the plugin supports using the CAP_PLUGIN_METHOD macro.
|
|
6
|
-
CAP_PLUGIN(FirebaseRemoteConfig, "FirebaseRemoteConfig",
|
|
4
|
+
CAP_PLUGIN(FirebaseRemoteConfigPlugin, "FirebaseRemoteConfig",
|
|
7
5
|
CAP_PLUGIN_METHOD(initialize, CAPPluginReturnPromise);
|
|
8
6
|
CAP_PLUGIN_METHOD(fetch, CAPPluginReturnPromise);
|
|
9
7
|
CAP_PLUGIN_METHOD(activate, CAPPluginReturnPromise);
|
package/ios/Plugin/Plugin.swift
CHANGED
|
@@ -3,28 +3,37 @@ import Capacitor
|
|
|
3
3
|
import FirebaseCore
|
|
4
4
|
import FirebaseRemoteConfig
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
public
|
|
6
|
+
@objc(FirebaseRemoteConfigPlugin)
|
|
7
|
+
public class FirebaseRemoteConfigPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
8
|
+
|
|
9
|
+
public let identifier = "FirebaseRemoteConfigPlugin"
|
|
10
|
+
public let jsName = "FirebaseRemoteConfig"
|
|
11
|
+
public let pluginMethods: [CAPPluginMethod] = [
|
|
12
|
+
CAPPluginMethod(name: "initialize", returnType: CAPPluginReturnPromise),
|
|
13
|
+
CAPPluginMethod(name: "fetch", returnType: CAPPluginReturnPromise),
|
|
14
|
+
CAPPluginMethod(name: "activate", returnType: CAPPluginReturnPromise),
|
|
15
|
+
CAPPluginMethod(name: "fetchAndActivate", returnType: CAPPluginReturnPromise),
|
|
16
|
+
CAPPluginMethod(name: "getBoolean", returnType: CAPPluginReturnPromise),
|
|
17
|
+
CAPPluginMethod(name: "getString", returnType: CAPPluginReturnPromise),
|
|
18
|
+
CAPPluginMethod(name: "getNumber", returnType: CAPPluginReturnPromise),
|
|
19
|
+
CAPPluginMethod(name: "getByteArray", returnType: CAPPluginReturnPromise),
|
|
20
|
+
]
|
|
12
21
|
|
|
13
22
|
var remoteConfig: RemoteConfig?
|
|
14
23
|
|
|
15
24
|
public override func load() {
|
|
16
|
-
if
|
|
17
|
-
|
|
25
|
+
if FirebaseApp.app() == nil {
|
|
26
|
+
FirebaseApp.configure()
|
|
18
27
|
}
|
|
19
28
|
|
|
20
29
|
if self.remoteConfig == nil {
|
|
21
30
|
self.remoteConfig = RemoteConfig.remoteConfig()
|
|
22
31
|
|
|
23
32
|
let standardUserDefaults = UserDefaults.standard
|
|
24
|
-
let remoteConfigDefaults = standardUserDefaults.object(forKey: "
|
|
33
|
+
let remoteConfigDefaults = standardUserDefaults.object(forKey: "firebaseremoteconfigdefaults")
|
|
25
34
|
|
|
26
|
-
if remoteConfigDefaults
|
|
27
|
-
self.remoteConfig?.setDefaults(fromPlist:
|
|
35
|
+
if let plistName = remoteConfigDefaults as? String {
|
|
36
|
+
self.remoteConfig?.setDefaults(fromPlist: plistName)
|
|
28
37
|
}
|
|
29
38
|
}
|
|
30
39
|
}
|
|
@@ -32,106 +41,131 @@ public class FirebaseRemoteConfig: CAPPlugin {
|
|
|
32
41
|
@objc func initialize(_ call: CAPPluginCall) {
|
|
33
42
|
let minFetchInterval = call.getInt("minimumFetchIntervalInSeconds") ?? 0
|
|
34
43
|
|
|
35
|
-
if self.remoteConfig
|
|
36
|
-
let settings
|
|
44
|
+
if let config = self.remoteConfig {
|
|
45
|
+
let settings = RemoteConfigSettings()
|
|
37
46
|
settings.minimumFetchInterval = TimeInterval(minFetchInterval)
|
|
38
|
-
|
|
47
|
+
config.configSettings = settings
|
|
39
48
|
}
|
|
40
49
|
|
|
41
|
-
call.
|
|
50
|
+
call.resolve()
|
|
42
51
|
}
|
|
43
52
|
|
|
44
53
|
@objc func fetch(_ call: CAPPluginCall) {
|
|
45
|
-
self.remoteConfig
|
|
54
|
+
guard let config = self.remoteConfig else {
|
|
55
|
+
call.reject("Remote config is not initialized")
|
|
56
|
+
return
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
config.fetch { status, error in
|
|
46
60
|
if status == .success {
|
|
47
|
-
call.
|
|
61
|
+
call.resolve()
|
|
48
62
|
} else {
|
|
49
|
-
call.
|
|
63
|
+
call.reject(error?.localizedDescription ?? "Error occurred while executing fetch()")
|
|
50
64
|
}
|
|
51
|
-
}
|
|
65
|
+
}
|
|
52
66
|
}
|
|
53
67
|
|
|
54
68
|
@objc func activate(_ call: CAPPluginCall) {
|
|
55
|
-
self.remoteConfig
|
|
56
|
-
|
|
57
|
-
|
|
69
|
+
guard let config = self.remoteConfig else {
|
|
70
|
+
call.reject("Remote config is not initialized")
|
|
71
|
+
return
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
config.activate { _, error in
|
|
75
|
+
if let error = error {
|
|
76
|
+
call.reject(error.localizedDescription)
|
|
58
77
|
} else {
|
|
59
|
-
call.
|
|
78
|
+
call.resolve()
|
|
60
79
|
}
|
|
61
|
-
}
|
|
80
|
+
}
|
|
62
81
|
}
|
|
63
82
|
|
|
64
83
|
@objc func fetchAndActivate(_ call: CAPPluginCall) {
|
|
65
|
-
self.remoteConfig
|
|
84
|
+
guard let config = self.remoteConfig else {
|
|
85
|
+
call.reject("Remote config is not initialized")
|
|
86
|
+
return
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
config.fetchAndActivate { status, error in
|
|
66
90
|
if status == .successFetchedFromRemote || status == .successUsingPreFetchedData {
|
|
67
|
-
call.
|
|
91
|
+
call.resolve()
|
|
68
92
|
} else {
|
|
69
|
-
call.error
|
|
93
|
+
call.reject(error?.localizedDescription ?? "Error occurred while executing fetchAndActivate()")
|
|
70
94
|
}
|
|
71
|
-
}
|
|
95
|
+
}
|
|
72
96
|
}
|
|
73
97
|
|
|
74
98
|
@objc func getBoolean(_ call: CAPPluginCall) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
"key": key! as String,
|
|
83
|
-
"value": value! as Bool,
|
|
84
|
-
"source": source!.rawValue as Int
|
|
85
|
-
])
|
|
86
|
-
} else {
|
|
87
|
-
call.error("Key is missing")
|
|
88
|
-
}
|
|
89
|
-
} else {
|
|
90
|
-
call.error("Key is missing")
|
|
99
|
+
guard let key = call.getString("key") else {
|
|
100
|
+
call.reject("Key is missing")
|
|
101
|
+
return
|
|
102
|
+
}
|
|
103
|
+
guard let config = self.remoteConfig else {
|
|
104
|
+
call.reject("Remote config is not initialized")
|
|
105
|
+
return
|
|
91
106
|
}
|
|
107
|
+
|
|
108
|
+
let rcValue = config.configValue(forKey: key)
|
|
109
|
+
call.resolve([
|
|
110
|
+
"key": key,
|
|
111
|
+
"value": rcValue.boolValue,
|
|
112
|
+
"source": rcValue.source.rawValue
|
|
113
|
+
])
|
|
92
114
|
}
|
|
93
115
|
|
|
94
116
|
@objc func getNumber(_ call: CAPPluginCall) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if key != nil {
|
|
99
|
-
let value = self.remoteConfig?.configValue(forKey: key).numberValue
|
|
100
|
-
let source = self.remoteConfig?.configValue(forKey: key).source
|
|
101
|
-
call.success([
|
|
102
|
-
"key": key! as String,
|
|
103
|
-
"value": value!,
|
|
104
|
-
"source": source!.rawValue as Int
|
|
105
|
-
])
|
|
106
|
-
} else {
|
|
107
|
-
call.error("Key is missing")
|
|
108
|
-
}
|
|
109
|
-
} else {
|
|
110
|
-
call.error("Key is missing")
|
|
117
|
+
guard let key = call.getString("key") else {
|
|
118
|
+
call.reject("Key is missing")
|
|
119
|
+
return
|
|
111
120
|
}
|
|
121
|
+
guard let config = self.remoteConfig else {
|
|
122
|
+
call.reject("Remote config is not initialized")
|
|
123
|
+
return
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
let rcValue = config.configValue(forKey: key)
|
|
127
|
+
call.resolve([
|
|
128
|
+
"key": key,
|
|
129
|
+
"value": rcValue.numberValue,
|
|
130
|
+
"source": rcValue.source.rawValue
|
|
131
|
+
])
|
|
112
132
|
}
|
|
113
133
|
|
|
114
134
|
@objc func getString(_ call: CAPPluginCall) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
"key": key! as String,
|
|
123
|
-
"value": value!,
|
|
124
|
-
"source": source!.rawValue as Int
|
|
125
|
-
])
|
|
126
|
-
} else {
|
|
127
|
-
call.error("Key is missing")
|
|
128
|
-
}
|
|
129
|
-
} else {
|
|
130
|
-
call.error("Key is missing")
|
|
135
|
+
guard let key = call.getString("key") else {
|
|
136
|
+
call.reject("Key is missing")
|
|
137
|
+
return
|
|
138
|
+
}
|
|
139
|
+
guard let config = self.remoteConfig else {
|
|
140
|
+
call.reject("Remote config is not initialized")
|
|
141
|
+
return
|
|
131
142
|
}
|
|
143
|
+
|
|
144
|
+
let rcValue = config.configValue(forKey: key)
|
|
145
|
+
call.resolve([
|
|
146
|
+
"key": key,
|
|
147
|
+
"value": rcValue.stringValue ?? "",
|
|
148
|
+
"source": rcValue.source.rawValue
|
|
149
|
+
])
|
|
132
150
|
}
|
|
133
151
|
|
|
134
152
|
@objc func getByteArray(_ call: CAPPluginCall) {
|
|
135
|
-
call.
|
|
153
|
+
guard let key = call.getString("key") else {
|
|
154
|
+
call.reject("Key is missing")
|
|
155
|
+
return
|
|
156
|
+
}
|
|
157
|
+
guard let config = self.remoteConfig else {
|
|
158
|
+
call.reject("Remote config is not initialized")
|
|
159
|
+
return
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
let rcValue = config.configValue(forKey: key)
|
|
163
|
+
let data = rcValue.dataValue
|
|
164
|
+
let byteArray = [UInt8](data)
|
|
165
|
+
call.resolve([
|
|
166
|
+
"key": key,
|
|
167
|
+
"value": byteArray,
|
|
168
|
+
"source": rcValue.source.rawValue
|
|
169
|
+
])
|
|
136
170
|
}
|
|
137
|
-
}
|
|
171
|
+
}
|
package/ios/Podfile
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
platform :ios, '
|
|
1
|
+
platform :ios, '13.4'
|
|
2
2
|
|
|
3
3
|
def capacitor_pods
|
|
4
|
-
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
|
|
5
4
|
use_frameworks!
|
|
6
5
|
pod 'Capacitor', :path => '../node_modules/@capacitor/ios'
|
|
7
6
|
pod 'CapacitorCordova', :path => '../node_modules/@capacitor/ios'
|
|
@@ -9,7 +8,7 @@ end
|
|
|
9
8
|
|
|
10
9
|
target 'Plugin' do
|
|
11
10
|
capacitor_pods
|
|
12
|
-
pod 'Firebase/RemoteConfig'
|
|
11
|
+
pod 'Firebase/RemoteConfig', '~> 11.0'
|
|
13
12
|
end
|
|
14
13
|
|
|
15
14
|
target 'PluginTests' do
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dghathway/firebase-remote-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "A native plugin for firebase remote config",
|
|
5
5
|
"main": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/esm/index.d.ts",
|
|
@@ -8,29 +8,19 @@
|
|
|
8
8
|
"build": "npm run clean && tsc",
|
|
9
9
|
"clean": "rimraf ./dist",
|
|
10
10
|
"watch": "tsc --watch",
|
|
11
|
-
"prepublishOnly": "npm run build"
|
|
12
|
-
"npm-publish": "np"
|
|
11
|
+
"prepublishOnly": "npm run build"
|
|
13
12
|
},
|
|
14
13
|
"author": "Priyank Patel <priyank.patel@stackspace.ca>",
|
|
15
14
|
"license": "MIT",
|
|
16
15
|
"dependencies": {
|
|
17
|
-
"@capacitor/core": "
|
|
16
|
+
"@capacitor/core": "^6.0.0"
|
|
18
17
|
},
|
|
19
18
|
"devDependencies": {
|
|
20
|
-
"@capacitor/android": "
|
|
21
|
-
"@capacitor/ios": "
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"prettier-plugin-java": "^0.8.0",
|
|
26
|
-
"pretty-quick": "^2.0.1",
|
|
27
|
-
"rimraf": "^3.0.2",
|
|
28
|
-
"typescript": "^3.9.5"
|
|
29
|
-
},
|
|
30
|
-
"husky": {
|
|
31
|
-
"hooks": {
|
|
32
|
-
"pre-commit": "pretty-quick --staged"
|
|
33
|
-
}
|
|
19
|
+
"@capacitor/android": "^6.0.0",
|
|
20
|
+
"@capacitor/ios": "^6.0.0",
|
|
21
|
+
"prettier": "^3.0.0",
|
|
22
|
+
"rimraf": "^5.0.0",
|
|
23
|
+
"typescript": "~5.5.0"
|
|
34
24
|
},
|
|
35
25
|
"files": [
|
|
36
26
|
"dist/",
|
package/android/.npmignore
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/build
|