@gachlab/capacitor-dnd-plugin 1.1.0 → 1.3.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/README.md CHANGED
@@ -14,6 +14,7 @@ npx cap sync
14
14
  <docgen-index>
15
15
 
16
16
  * [`monitor()`](#monitor)
17
+ * [`set(...)`](#set)
17
18
 
18
19
  </docgen-index>
19
20
 
@@ -23,10 +24,23 @@ npx cap sync
23
24
  ### monitor()
24
25
 
25
26
  ```typescript
26
- monitor() => Promise<any>
27
+ monitor() => Promise<{ enabled: boolean; }>
27
28
  ```
28
29
 
29
- **Returns:** <code>Promise&lt;any&gt;</code>
30
+ **Returns:** <code>Promise&lt;{ enabled: boolean; }&gt;</code>
31
+
32
+ --------------------
33
+
34
+
35
+ ### set(...)
36
+
37
+ ```typescript
38
+ set(options: { enabled: boolean; }) => Promise<void>
39
+ ```
40
+
41
+ | Param | Type |
42
+ | ------------- | ---------------------------------- |
43
+ | **`options`** | <code>{ enabled: boolean; }</code> |
30
44
 
31
45
  --------------------
32
46
 
@@ -1,20 +1,3 @@
1
1
  <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
- <application>
3
- <service android:name="NotificationListener"
4
- android:label="@string/service_name"
5
- android:exported="false"
6
- android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
7
- <intent-filter>
8
- <action android:name="android.service.notification.NotificationListenerService" />
9
- </intent-filter>
10
- <meta-data
11
- android:name="android.service.notification.default_filter_types"
12
- android:value="conversations|alerting">
13
- </meta-data>
14
- <meta-data
15
- android:name="android.service.notification.disabled_filter_types"
16
- android:value="ongoing|silent">
17
- </meta-data>
18
- </service>
19
- </application>
2
+ <uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />
20
3
  </manifest>
@@ -1,11 +1,48 @@
1
1
  package com.gachlab.capacitor.dnd;
2
2
 
3
- import android.util.Log;
3
+ import android.app.NotificationManager;
4
+ import android.content.BroadcastReceiver;
5
+ import android.content.Context;
6
+ import android.content.Intent;
7
+ import android.content.IntentFilter;
4
8
 
5
9
  public class DoNotDisturb {
6
-
7
- public String echo(String value) {
8
- Log.i("Echo", value);
9
- return value;
10
+ private Context context;
11
+ private BroadcastReceiver receiver;
12
+ private Runnable callback;
13
+
14
+ public DoNotDisturb(Context context) {
15
+ this.context = context;
16
+ }
17
+
18
+ public boolean isEnabled() {
19
+ NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
20
+ return nm.getCurrentInterruptionFilter() != NotificationManager.INTERRUPTION_FILTER_ALL;
21
+ }
22
+
23
+ public void setEnabled(boolean enabled) {
24
+ NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
25
+ if (!nm.isNotificationPolicyAccessGranted()) {
26
+ return;
27
+ }
28
+ nm.setInterruptionFilter(enabled ? NotificationManager.INTERRUPTION_FILTER_NONE : NotificationManager.INTERRUPTION_FILTER_ALL);
29
+ }
30
+
31
+ public void startListening(Runnable callback) {
32
+ this.callback = callback;
33
+ receiver = new BroadcastReceiver() {
34
+ @Override
35
+ public void onReceive(Context context, Intent intent) {
36
+ if (callback != null) callback.run();
37
+ }
38
+ };
39
+ context.registerReceiver(receiver, new IntentFilter(NotificationManager.ACTION_INTERRUPTION_FILTER_CHANGED));
40
+ }
41
+
42
+ public void stopListening() {
43
+ if (receiver != null) {
44
+ context.unregisterReceiver(receiver);
45
+ receiver = null;
46
+ }
10
47
  }
11
48
  }
@@ -1,6 +1,10 @@
1
1
  package com.gachlab.capacitor.dnd;
2
2
 
3
3
  import android.Manifest;
4
+ import android.app.NotificationManager;
5
+ import android.content.Context;
6
+ import android.content.Intent;
7
+ import android.provider.Settings;
4
8
 
5
9
  import com.getcapacitor.JSObject;
6
10
  import com.getcapacitor.Plugin;
@@ -14,14 +18,51 @@ import com.getcapacitor.annotation.Permission;
14
18
  })
15
19
  public class DoNotDisturbPlugin extends Plugin {
16
20
 
17
- private DoNotDisturb implementation = new DoNotDisturb();
21
+ private DoNotDisturb implementation;
18
22
 
19
- @PluginMethod
20
- public void echo(PluginCall call) {
21
- String value = call.getString("value");
23
+ @Override
24
+ public void load() {
25
+ implementation = new DoNotDisturb(getContext());
26
+ implementation.startListening(() -> {
27
+ JSObject ret = new JSObject();
28
+ ret.put("enabled", implementation.isEnabled());
29
+ notifyListeners("monitor", ret);
30
+ });
31
+ }
22
32
 
33
+ @PluginMethod
34
+ public void monitor(PluginCall call) {
35
+ NotificationManager nm = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE);
36
+ if (!nm.isNotificationPolicyAccessGranted()) {
37
+ Intent intent = new Intent(Settings.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS);
38
+ getActivity().startActivity(intent);
39
+ }
23
40
  JSObject ret = new JSObject();
24
- ret.put("value", implementation.echo(value));
41
+ ret.put("enabled", implementation.isEnabled());
25
42
  call.resolve(ret);
26
43
  }
44
+
45
+ @PluginMethod
46
+ public void set(PluginCall call) {
47
+ boolean enabled = call.getBoolean("enabled", false);
48
+ NotificationManager nm = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE);
49
+ if (!nm.isNotificationPolicyAccessGranted()) {
50
+ call.reject("Permission required: Go to Settings > Apps > [App Name] > Permissions > Do Not Disturb access");
51
+ return;
52
+ }
53
+ implementation.setEnabled(enabled);
54
+ JSObject ret = new JSObject();
55
+ ret.put("enabled", implementation.isEnabled());
56
+ notifyListeners("monitor", ret);
57
+ call.resolve();
58
+ }
59
+
60
+
61
+
62
+ @Override
63
+ protected void handleOnDestroy() {
64
+ if (implementation != null) {
65
+ implementation.stopListening();
66
+ }
67
+ }
27
68
  }
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <resources>
3
+ <string name="service_name">DND Service</string>
4
+ </resources>
@@ -1,3 +1,8 @@
1
1
  export interface DoNotDisturbPlugin {
2
- monitor(): Promise<any>;
2
+ monitor(): Promise<{
3
+ enabled: boolean;
4
+ }>;
5
+ set(options: {
6
+ enabled: boolean;
7
+ }): Promise<void>;
3
8
  }
package/dist/esm/index.js CHANGED
@@ -1,7 +1,8 @@
1
- import { registerPlugin } from '@capacitor/core';
2
- const DoNotDisturb = registerPlugin('DoNotDisturb', {
3
- web: () => import('./web').then(m => new m.DoNotDisturbWeb()),
1
+ import { registerPlugin as o } from "@capacitor/core";
2
+ const e = o("DoNotDisturb", {
3
+ web: () => import("../web-CTERRVO0.mjs").then((t) => new t.DoNotDisturbWeb())
4
4
  });
5
- export * from './definitions';
6
- export { DoNotDisturb };
7
- //# sourceMappingURL=index.js.map
5
+ export {
6
+ e as DoNotDisturb
7
+ };
8
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,YAAY,GAAG,cAAc,CAAqB,cAAc,EAAE;IACtE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;CAC9D,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { DoNotDisturbPlugin } from './definitions';\n\nconst DoNotDisturb = registerPlugin<DoNotDisturbPlugin>('DoNotDisturb', {\n web: () => import('./web').then(m => new m.DoNotDisturbWeb()),\n});\n\nexport * from './definitions';\nexport { DoNotDisturb };\n"]}
1
+ {"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { DoNotDisturbPlugin } from './definitions';\n\nconst DoNotDisturb = registerPlugin<DoNotDisturbPlugin>('DoNotDisturb', {\n web: () => import('./web').then(m => new m.DoNotDisturbWeb()),\n});\n\nexport * from './definitions';\nexport { DoNotDisturb };\n"],"names":["DoNotDisturb","registerPlugin","m"],"mappings":";AAIM,MAAAA,IAAeC,EAAmC,gBAAgB;AAAA,EACtE,KAAK,MAAM,OAAO,qBAAO,EAAE,KAAK,CAAKC,MAAA,IAAIA,EAAE,gBAAiB,CAAA;AAC9D,CAAC;"}
package/dist/esm/web.d.ts CHANGED
@@ -1,5 +1,10 @@
1
1
  import { WebPlugin } from "@capacitor/core";
2
2
  import type { DoNotDisturbPlugin } from "./definitions";
3
3
  export declare class DoNotDisturbWeb extends WebPlugin implements DoNotDisturbPlugin {
4
- monitor(): Promise<any>;
4
+ monitor(): Promise<{
5
+ enabled: boolean;
6
+ }>;
7
+ set(_options: {
8
+ enabled: boolean;
9
+ }): Promise<void>;
5
10
  }
@@ -1,21 +1,2 @@
1
- 'use strict';
2
-
3
- var core = require('@capacitor/core');
4
-
5
- const DoNotDisturb = core.registerPlugin('DoNotDisturb', {
6
- web: () => Promise.resolve().then(function () { return web; }).then(m => new m.DoNotDisturbWeb()),
7
- });
8
-
9
- class DoNotDisturbWeb extends core.WebPlugin {
10
- monitor() {
11
- throw new Error("Method not implemented in web.");
12
- }
13
- }
14
-
15
- var web = /*#__PURE__*/Object.freeze({
16
- __proto__: null,
17
- DoNotDisturbWeb: DoNotDisturbWeb
18
- });
19
-
20
- exports.DoNotDisturb = DoNotDisturb;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@capacitor/core"),o=t.registerPlugin("DoNotDisturb",{web:()=>Promise.resolve().then(()=>require("./web-CK137vPX.js")).then(e=>new e.DoNotDisturbWeb)});exports.DoNotDisturb=o;
21
2
  //# sourceMappingURL=plugin.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst DoNotDisturb = registerPlugin('DoNotDisturb', {\n web: () => import('./web').then(m => new m.DoNotDisturbWeb()),\n});\nexport * from './definitions';\nexport { DoNotDisturb };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from \"@capacitor/core\";\nexport class DoNotDisturbWeb extends WebPlugin {\n monitor() {\n throw new Error(\"Method not implemented in web.\");\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,YAAY,GAAGA,mBAAc,CAAC,cAAc,EAAE;AACpD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;AACjE,CAAC;;ACFM,MAAM,eAAe,SAASC,cAAS,CAAC;AAC/C,IAAI,OAAO,GAAG;AACd,QAAQ,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC;AACzD;AACA;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.cjs.js","sources":["../src/index.ts"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { DoNotDisturbPlugin } from './definitions';\n\nconst DoNotDisturb = registerPlugin<DoNotDisturbPlugin>('DoNotDisturb', {\n web: () => import('./web').then(m => new m.DoNotDisturbWeb()),\n});\n\nexport * from './definitions';\nexport { DoNotDisturb };\n"],"names":["DoNotDisturb","registerPlugin","m"],"mappings":"mHAIMA,EAAeC,iBAAmC,eAAgB,CACtE,IAAK,IAAM,QAAO,QAAA,EAAA,KAAA,IAAA,QAAA,mBAAO,GAAE,KAAUC,GAAA,IAAIA,EAAE,eAAiB,CAC9D,CAAC"}
package/dist/plugin.js CHANGED
@@ -1,24 +1,2 @@
1
- var capacitorDoNotDisturb = (function (exports, core) {
2
- 'use strict';
3
-
4
- const DoNotDisturb = core.registerPlugin('DoNotDisturb', {
5
- web: () => Promise.resolve().then(function () { return web; }).then(m => new m.DoNotDisturbWeb()),
6
- });
7
-
8
- class DoNotDisturbWeb extends core.WebPlugin {
9
- monitor() {
10
- throw new Error("Method not implemented in web.");
11
- }
12
- }
13
-
14
- var web = /*#__PURE__*/Object.freeze({
15
- __proto__: null,
16
- DoNotDisturbWeb: DoNotDisturbWeb
17
- });
18
-
19
- exports.DoNotDisturb = DoNotDisturb;
20
-
21
- return exports;
22
-
23
- })({}, capacitorExports);
1
+ var capacitorDoNotDisturb=function(t,e){"use strict";const r=e.registerPlugin("DoNotDisturb",{web:()=>Promise.resolve().then(()=>s).then(o=>new o.DoNotDisturbWeb)});class n extends e.WebPlugin{async monitor(){return{enabled:!1}}async set(i){throw new Error("Setting DND state not supported on web")}}const s=Object.freeze(Object.defineProperty({__proto__:null,DoNotDisturbWeb:n},Symbol.toStringTag,{value:"Module"}));return t.DoNotDisturb=r,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),t}({},capacitorExports);
24
2
  //# sourceMappingURL=plugin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst DoNotDisturb = registerPlugin('DoNotDisturb', {\n web: () => import('./web').then(m => new m.DoNotDisturbWeb()),\n});\nexport * from './definitions';\nexport { DoNotDisturb };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from \"@capacitor/core\";\nexport class DoNotDisturbWeb extends WebPlugin {\n monitor() {\n throw new Error(\"Method not implemented in web.\");\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,YAAY,GAAGA,mBAAc,CAAC,cAAc,EAAE;IACpD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACjE,CAAC;;ICFM,MAAM,eAAe,SAASC,cAAS,CAAC;IAC/C,IAAI,OAAO,GAAG;IACd,QAAQ,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC;IACzD;IACA;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.js","sources":["../src/index.ts","../src/web.ts"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { DoNotDisturbPlugin } from './definitions';\n\nconst DoNotDisturb = registerPlugin<DoNotDisturbPlugin>('DoNotDisturb', {\n web: () => import('./web').then(m => new m.DoNotDisturbWeb()),\n});\n\nexport * from './definitions';\nexport { DoNotDisturb };\n","import { WebPlugin } from \"@capacitor/core\";\n\nimport type { DoNotDisturbPlugin } from \"./definitions\";\n\nexport class DoNotDisturbWeb extends WebPlugin implements DoNotDisturbPlugin {\n async monitor(): Promise<{ enabled: boolean }> {\n return { enabled: false };\n }\n\n async set(_options: { enabled: boolean }): Promise<void> {\n throw new Error('Setting DND state not supported on web');\n }\n\n\n}\n"],"names":["DoNotDisturb","registerPlugin","web","m","DoNotDisturbWeb","WebPlugin","_options"],"mappings":"qDAIM,MAAAA,EAAeC,iBAAmC,eAAgB,CACtE,IAAK,IAAM,QAAA,QAAA,EAAA,KAAA,IAAAC,CAAA,EAAgB,KAAUC,GAAA,IAAIA,EAAE,eAAiB,CAC9D,CAAC,ECFM,MAAMC,UAAwBC,EAAAA,SAAwC,CAC3E,MAAM,SAAyC,CACtC,MAAA,CAAE,QAAS,EAAM,CAAA,CAG1B,MAAM,IAAIC,EAA+C,CACjD,MAAA,IAAI,MAAM,wCAAwC,CAAA,CAI5D"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@capacitor/core");class t extends e.WebPlugin{async monitor(){return{enabled:!1}}async set(r){throw new Error("Setting DND state not supported on web")}}exports.DoNotDisturbWeb=t;
2
+ //# sourceMappingURL=web-CK137vPX.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-CK137vPX.js","sources":["../src/web.ts"],"sourcesContent":["import { WebPlugin } from \"@capacitor/core\";\n\nimport type { DoNotDisturbPlugin } from \"./definitions\";\n\nexport class DoNotDisturbWeb extends WebPlugin implements DoNotDisturbPlugin {\n async monitor(): Promise<{ enabled: boolean }> {\n return { enabled: false };\n }\n\n async set(_options: { enabled: boolean }): Promise<void> {\n throw new Error('Setting DND state not supported on web');\n }\n\n\n}\n"],"names":["DoNotDisturbWeb","WebPlugin","_options"],"mappings":"mHAIO,MAAMA,UAAwBC,EAAAA,SAAwC,CAC3E,MAAM,SAAyC,CACtC,MAAA,CAAE,QAAS,EAAM,CAAA,CAG1B,MAAM,IAAIC,EAA+C,CACjD,MAAA,IAAI,MAAM,wCAAwC,CAAA,CAI5D"}
@@ -0,0 +1,13 @@
1
+ import { WebPlugin as t } from "@capacitor/core";
2
+ class r extends t {
3
+ async monitor() {
4
+ return { enabled: !1 };
5
+ }
6
+ async set(o) {
7
+ throw new Error("Setting DND state not supported on web");
8
+ }
9
+ }
10
+ export {
11
+ r as DoNotDisturbWeb
12
+ };
13
+ //# sourceMappingURL=web-CTERRVO0.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-CTERRVO0.mjs","sources":["../src/web.ts"],"sourcesContent":["import { WebPlugin } from \"@capacitor/core\";\n\nimport type { DoNotDisturbPlugin } from \"./definitions\";\n\nexport class DoNotDisturbWeb extends WebPlugin implements DoNotDisturbPlugin {\n async monitor(): Promise<{ enabled: boolean }> {\n return { enabled: false };\n }\n\n async set(_options: { enabled: boolean }): Promise<void> {\n throw new Error('Setting DND state not supported on web');\n }\n\n\n}\n"],"names":["DoNotDisturbWeb","WebPlugin","_options"],"mappings":";AAIO,MAAMA,UAAwBC,EAAwC;AAAA,EAC3E,MAAM,UAAyC;AACtC,WAAA,EAAE,SAAS,GAAM;AAAA,EAAA;AAAA,EAG1B,MAAM,IAAIC,GAA+C;AACjD,UAAA,IAAI,MAAM,wCAAwC;AAAA,EAAA;AAI5D;"}
@@ -1,8 +1,34 @@
1
1
  import Foundation
2
+ import UserNotifications
2
3
 
3
4
  @objc public class DoNotDisturb: NSObject {
4
- @objc public func echo(_ value: String) -> String {
5
- print(value)
6
- return value
5
+ private var callback: (() -> Void)?
6
+ private var timer: Timer?
7
+ private var lastState: Bool = false
8
+
9
+ @objc public func isEnabled() -> Bool {
10
+ // iOS doesn't provide API to detect Focus/DND state
11
+ return false
12
+ }
13
+
14
+ @objc public func setEnabled(_ enabled: Bool) {
15
+ // iOS doesn't allow programmatic DND control
16
+ }
17
+
18
+ @objc public func startListening(callback: @escaping () -> Void) {
19
+ self.callback = callback
20
+ lastState = isEnabled()
21
+ timer = Timer.scheduledTimer(withTimeInterval: 2.0, repeats: true) { _ in
22
+ let currentState = self.isEnabled()
23
+ if currentState != self.lastState {
24
+ self.lastState = currentState
25
+ callback()
26
+ }
27
+ }
28
+ }
29
+
30
+ @objc public func stopListening() {
31
+ timer?.invalidate()
32
+ timer = nil
7
33
  }
8
34
  }
@@ -4,5 +4,6 @@
4
4
  // Define the plugin using the CAP_PLUGIN Macro, and
5
5
  // each method the plugin supports using the CAP_PLUGIN_METHOD macro.
6
6
  CAP_PLUGIN(DoNotDisturbPlugin, "DoNotDisturb",
7
- CAP_PLUGIN_METHOD(echo, CAPPluginReturnPromise);
7
+ CAP_PLUGIN_METHOD(monitor, CAPPluginReturnPromise);
8
+ CAP_PLUGIN_METHOD(set, CAPPluginReturnPromise);
8
9
  )
@@ -1,18 +1,31 @@
1
1
  import Foundation
2
2
  import Capacitor
3
3
 
4
- /**
5
- * Please read the Capacitor iOS Plugin Development Guide
6
- * here: https://capacitorjs.com/docs/plugins/ios
7
- */
8
4
  @objc(DoNotDisturbPlugin)
9
5
  public class DoNotDisturbPlugin: CAPPlugin {
10
6
  private let implementation = DoNotDisturb()
11
7
 
12
- @objc func echo(_ call: CAPPluginCall) {
13
- let value = call.getString("value") ?? ""
8
+ public override func load() {
9
+ implementation.startListening {
10
+ self.notifyListeners("monitor", data: [
11
+ "enabled": self.implementation.isEnabled()
12
+ ])
13
+ }
14
+ }
15
+
16
+ @objc func monitor(_ call: CAPPluginCall) {
14
17
  call.resolve([
15
- "value": implementation.echo(value)
18
+ "enabled": implementation.isEnabled()
16
19
  ])
17
20
  }
21
+
22
+ @objc func set(_ call: CAPPluginCall) {
23
+ call.reject("iOS doesn't allow programmatic DND control")
24
+ }
25
+
26
+
27
+
28
+ deinit {
29
+ implementation.stopListening()
30
+ }
18
31
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gachlab/capacitor-dnd-plugin",
3
- "version": "1.1.0",
3
+ "version": "1.3.0",
4
4
  "description": "A plugin to set and monitor the Do Not Disturb state",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -38,16 +38,17 @@
38
38
  "prettier": "prettier \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
39
39
  "swiftlint": "node-swiftlint",
40
40
  "docgen": "docgen --api DoNotDisturbPlugin --output-readme README.md --output-json dist/docs.json",
41
- "build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.mjs",
41
+ "build": "npm run clean && npm run docgen && vite build && npm run build:types",
42
+ "build:types": "tsc --emitDeclarationOnly",
42
43
  "clean": "rimraf ./dist",
43
- "watch": "tsc --watch",
44
+ "watch": "vite build --watch",
44
45
  "prepublishOnly": "npm run build"
45
46
  },
46
47
  "devDependencies": {
47
- "@capacitor/android": "^7.0.0",
48
- "@capacitor/core": "^7.0.0",
48
+ "@capacitor/android": "7.4.2",
49
+ "@capacitor/core": "7.4.2",
49
50
  "@capacitor/docgen": "^0.3.0",
50
- "@capacitor/ios": "^7.0.0",
51
+ "@capacitor/ios": "7.4.2",
51
52
  "@ionic/eslint-config": "^0.4.0",
52
53
  "@ionic/prettier-config": "^4.0.0",
53
54
  "@ionic/swiftlint-config": "^2.0.0",
@@ -55,12 +56,12 @@
55
56
  "prettier": "^3.4.2",
56
57
  "prettier-plugin-java": "^2.6.6",
57
58
  "rimraf": "^6.0.1",
58
- "rollup": "^4.30.1",
59
59
  "swiftlint": "^2.0.0",
60
- "typescript": "~5.3.3"
60
+ "typescript": "~5.3.3",
61
+ "vite": "^5.0.0"
61
62
  },
62
63
  "peerDependencies": {
63
- "@capacitor/core": ">=7.0.0"
64
+ "@capacitor/core": ">=7.4.2"
64
65
  },
65
66
  "prettier": "@ionic/prettier-config",
66
67
  "swiftlint": "@ionic/swiftlint-config",
package/dist/docs.json DELETED
@@ -1,25 +0,0 @@
1
- {
2
- "api": {
3
- "name": "DoNotDisturbPlugin",
4
- "slug": "donotdisturbplugin",
5
- "docs": "",
6
- "tags": [],
7
- "methods": [
8
- {
9
- "name": "monitor",
10
- "signature": "() => Promise<any>",
11
- "parameters": [],
12
- "returns": "Promise<any>",
13
- "tags": [],
14
- "docs": "",
15
- "complexTypes": [],
16
- "slug": "monitor"
17
- }
18
- ],
19
- "properties": []
20
- },
21
- "interfaces": [],
22
- "enums": [],
23
- "typeAliases": [],
24
- "pluginConfigs": []
25
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=definitions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface DoNotDisturbPlugin {\n monitor(): Promise<any>;\n}\n"]}
package/dist/esm/web.js DELETED
@@ -1,7 +0,0 @@
1
- import { WebPlugin } from "@capacitor/core";
2
- export class DoNotDisturbWeb extends WebPlugin {
3
- monitor() {
4
- throw new Error("Method not implemented in web.");
5
- }
6
- }
7
- //# sourceMappingURL=web.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAC5C,OAAO;QACL,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACpD,CAAC;CACF","sourcesContent":["import { WebPlugin } from \"@capacitor/core\";\n\nimport type { DoNotDisturbPlugin } from \"./definitions\";\n\nexport class DoNotDisturbWeb extends WebPlugin implements DoNotDisturbPlugin {\n monitor(): Promise<any> {\n throw new Error(\"Method not implemented in web.\");\n }\n}\n"]}