@capgo/capacitor-contacts 8.0.7 → 8.0.10

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.
@@ -30,7 +30,7 @@ android {
30
30
  buildTypes {
31
31
  release {
32
32
  minifyEnabled false
33
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
33
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
34
34
  }
35
35
  }
36
36
  lintOptions {
@@ -39,7 +39,7 @@ import java.util.Set;
39
39
  )
40
40
  public class CapacitorContactsPlugin extends Plugin {
41
41
 
42
- private final String pluginVersion = "8.0.7";
42
+ private final String pluginVersion = "8.0.10";
43
43
  private static final int BATCH_SIZE = 50;
44
44
 
45
45
  // MARK: - Implemented API surface
@@ -186,9 +186,34 @@ public class CapacitorContactsPlugin extends Plugin {
186
186
 
187
187
  @PluginMethod
188
188
  public void requestPermissions(PluginCall call) {
189
- // In Capacitor 7, the permission system works differently
190
- // We just need to request the permissions defined in the plugin annotation
191
- requestPermissionForAlias("readContacts", call, "handleRequestPermissions");
189
+ JSArray permissions = call.getArray("permissions");
190
+ String[] aliases;
191
+
192
+ if (permissions == null || permissions.length() == 0) {
193
+ aliases = new String[] { "readContacts", "writeContacts" };
194
+ } else {
195
+ List<String> requestedAliases = new ArrayList<>();
196
+
197
+ for (int i = 0; i < permissions.length(); i++) {
198
+ String alias = permissions.optString(i, null);
199
+ if (alias == null) {
200
+ continue;
201
+ }
202
+
203
+ if ("readContacts".equals(alias) || "writeContacts".equals(alias)) {
204
+ requestedAliases.add(alias);
205
+ }
206
+ }
207
+
208
+ if (requestedAliases.isEmpty()) {
209
+ call.reject("No valid permissions requested.");
210
+ return;
211
+ }
212
+
213
+ aliases = requestedAliases.toArray(new String[0]);
214
+ }
215
+
216
+ requestPermissionForAliases(aliases, call, "handleRequestPermissions");
192
217
  }
193
218
 
194
219
  @PermissionCallback
@@ -5,7 +5,7 @@ import UIKit
5
5
 
6
6
  @objc(CapacitorContactsPlugin)
7
7
  public class CapacitorContactsPlugin: CAPPlugin, CAPBridgedPlugin {
8
- private let pluginVersion: String = "8.0.7"
8
+ private let pluginVersion: String = "8.0.10"
9
9
  public let identifier = "CapacitorContactsPlugin"
10
10
  public let jsName = "CapacitorContacts"
11
11
  public let pluginMethods: [CAPPluginMethod] = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-contacts",
3
- "version": "8.0.7",
3
+ "version": "8.0.10",
4
4
  "description": "Work with device contacts using Capacitor APIs",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",