@gachlab/capacitor-dnd-plugin 0.0.2

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.
@@ -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 = 'GachlabCapacitorDndPlugin'
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/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
14
+ s.ios.deployment_target = '13.0'
15
+ s.dependency 'Capacitor'
16
+ s.swift_version = '5.1'
17
+ end
package/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # @gachlab/capacitor-dnd-plugin
2
+
3
+ A plugin to set and monitor the Do Not Disturb state
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @gachlab/capacitor-dnd-plugin
9
+ npx cap sync
10
+ ```
11
+
12
+ ## API
13
+
14
+ <docgen-index>
15
+
16
+ * [`monitor(...)`](#monitor)
17
+ * [`toggleDoNotDisturb()`](#toggledonotdisturb)
18
+ * [Interfaces](#interfaces)
19
+
20
+ </docgen-index>
21
+
22
+ <docgen-api>
23
+ <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
24
+
25
+ ### monitor(...)
26
+
27
+ ```typescript
28
+ monitor(callback: (result: DoNotDisturbState) => void) => Promise<void>
29
+ ```
30
+
31
+ | Param | Type |
32
+ | -------------- | ------------------------------------------------------------------------------------ |
33
+ | **`callback`** | <code>(result: <a href="#donotdisturbstate">DoNotDisturbState</a>) =&gt; void</code> |
34
+
35
+ --------------------
36
+
37
+
38
+ ### toggleDoNotDisturb()
39
+
40
+ ```typescript
41
+ toggleDoNotDisturb() => Promise<void>
42
+ ```
43
+
44
+ --------------------
45
+
46
+
47
+ ### Interfaces
48
+
49
+
50
+ #### DoNotDisturbState
51
+
52
+ | Prop | Type |
53
+ | ------------------ | -------------------- |
54
+ | **`doNotDisturb`** | <code>boolean</code> |
55
+
56
+ </docgen-api>
@@ -0,0 +1,58 @@
1
+ ext {
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
+ }
7
+
8
+ buildscript {
9
+ repositories {
10
+ google()
11
+ mavenCentral()
12
+ }
13
+ dependencies {
14
+ classpath 'com.android.tools.build:gradle:8.0.0'
15
+ }
16
+ }
17
+
18
+ apply plugin: 'com.android.library'
19
+
20
+ android {
21
+ namespace "com.gachlab.capacitor.dnd"
22
+ compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 33
23
+ defaultConfig {
24
+ minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
25
+ targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 33
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_17
41
+ targetCompatibility JavaVersion.VERSION_17
42
+ }
43
+ }
44
+
45
+ repositories {
46
+ google()
47
+ mavenCentral()
48
+ }
49
+
50
+
51
+ dependencies {
52
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
53
+ implementation project(':capacitor-android')
54
+ implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
55
+ testImplementation "junit:junit:$junitVersion"
56
+ androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
57
+ androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
58
+ }
@@ -0,0 +1,2 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ </manifest>
@@ -0,0 +1,72 @@
1
+ package com.gachlab.capacitor.dnd;
2
+
3
+ import static android.Manifest.permission.ACCESS_NOTIFICATION_POLICY;
4
+
5
+ import android.Manifest;
6
+ import android.app.NotificationManager;
7
+ import android.content.Context;
8
+ import android.content.Intent;
9
+ import android.os.Build;
10
+ import android.provider.Settings;
11
+
12
+ import androidx.annotation.RequiresApi;
13
+ import androidx.core.content.ContextCompat;
14
+
15
+ import com.getcapacitor.JSObject;
16
+ import com.getcapacitor.Plugin;
17
+ import com.getcapacitor.PluginCall;
18
+ import com.getcapacitor.PluginMethod;
19
+ import com.getcapacitor.annotation.CapacitorPlugin;
20
+ import com.getcapacitor.annotation.Permission;
21
+
22
+ import java.util.Timer;
23
+ import java.util.TimerTask;
24
+
25
+ @RequiresApi(api = Build.VERSION_CODES.M)
26
+ @CapacitorPlugin(name = "DoNotDisturb",
27
+ permissions = {
28
+ @Permission(alias = "notifications-policy", strings = {ACCESS_NOTIFICATION_POLICY})
29
+ })
30
+ public class DoNotDisturbPlugin extends Plugin {
31
+ @PluginMethod(returnType = PluginMethod.RETURN_CALLBACK)
32
+ public void monitor(PluginCall call) {
33
+ call.setKeepAlive(true);
34
+ JSObject ret = new JSObject();
35
+ new Timer().scheduleAtFixedRate(new TimerTask() {
36
+ @Override
37
+ public void run() {
38
+ try {
39
+ ret.put(
40
+ "doNotDisturb",
41
+ Settings.Global.getInt(getActivity().getApplicationContext().getContentResolver(), "zen_mode") == 1
42
+ );
43
+ } catch (Settings.SettingNotFoundException e) {
44
+ ret.put(
45
+ "doNotDisturb",
46
+ null);
47
+ }
48
+ }
49
+ }, 5000, 10000);
50
+ call.resolve(ret);
51
+ }
52
+
53
+ public void toggleDoNotDisturb() {
54
+ NotificationManager notificationManager = (NotificationManager) getActivity().getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
55
+ // Check if the notification policy access has been granted for the app.
56
+ if (!notificationManager.isNotificationPolicyAccessGranted()) {
57
+ Intent intent = new
58
+ Intent(android.provider.Settings.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS);
59
+ ContextCompat.startActivity(getActivity().getApplicationContext(), intent, null);
60
+ return;
61
+ }
62
+ ToggleDoNotDisturb(notificationManager);
63
+ }
64
+
65
+ private void ToggleDoNotDisturb(NotificationManager notificationManager) {
66
+ if (notificationManager.getCurrentInterruptionFilter() == NotificationManager.INTERRUPTION_FILTER_ALL) {
67
+ notificationManager.setInterruptionFilter(NotificationManager.INTERRUPTION_FILTER_NONE);
68
+ } else {
69
+ notificationManager.setInterruptionFilter(NotificationManager.INTERRUPTION_FILTER_ALL);
70
+ }
71
+ }
72
+ }
File without changes
package/dist/docs.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "api": {
3
+ "name": "DoNotDisturbPlugin",
4
+ "slug": "donotdisturbplugin",
5
+ "docs": "",
6
+ "tags": [],
7
+ "methods": [
8
+ {
9
+ "name": "monitor",
10
+ "signature": "(callback: (result: DoNotDisturbState) => void) => Promise<void>",
11
+ "parameters": [
12
+ {
13
+ "name": "callback",
14
+ "docs": "",
15
+ "type": "(result: DoNotDisturbState) => void"
16
+ }
17
+ ],
18
+ "returns": "Promise<void>",
19
+ "tags": [],
20
+ "docs": "",
21
+ "complexTypes": [
22
+ "DoNotDisturbState"
23
+ ],
24
+ "slug": "monitor"
25
+ },
26
+ {
27
+ "name": "toggleDoNotDisturb",
28
+ "signature": "() => Promise<void>",
29
+ "parameters": [],
30
+ "returns": "Promise<void>",
31
+ "tags": [],
32
+ "docs": "",
33
+ "complexTypes": [],
34
+ "slug": "toggledonotdisturb"
35
+ }
36
+ ],
37
+ "properties": []
38
+ },
39
+ "interfaces": [
40
+ {
41
+ "name": "DoNotDisturbState",
42
+ "slug": "donotdisturbstate",
43
+ "docs": "",
44
+ "tags": [],
45
+ "methods": [],
46
+ "properties": [
47
+ {
48
+ "name": "doNotDisturb",
49
+ "tags": [],
50
+ "docs": "",
51
+ "complexTypes": [],
52
+ "type": "boolean"
53
+ }
54
+ ]
55
+ }
56
+ ],
57
+ "enums": [],
58
+ "typeAliases": [],
59
+ "pluginConfigs": []
60
+ }
@@ -0,0 +1,7 @@
1
+ export interface DoNotDisturbState {
2
+ doNotDisturb: boolean;
3
+ }
4
+ export interface DoNotDisturbPlugin {
5
+ monitor(callback: (result: DoNotDisturbState) => void): Promise<void>;
6
+ toggleDoNotDisturb(): Promise<void>;
7
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=definitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface DoNotDisturbState {\n doNotDisturb: boolean\n}\n\nexport interface DoNotDisturbPlugin {\n monitor(callback: (result: DoNotDisturbState) => void): Promise<void>\n\n toggleDoNotDisturb(): Promise<void>\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type { DoNotDisturbPlugin } from './definitions';
2
+ declare const DoNotDisturb: DoNotDisturbPlugin;
3
+ export * from './definitions';
4
+ export { DoNotDisturb };
@@ -0,0 +1,7 @@
1
+ import { registerPlugin } from '@capacitor/core';
2
+ const DoNotDisturb = registerPlugin('DoNotDisturb', {
3
+ web: () => import('./web').then(m => new m.DoNotDisturbWeb()),
4
+ });
5
+ export * from './definitions';
6
+ export { DoNotDisturb };
7
+ //# sourceMappingURL=index.js.map
@@ -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,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"]}
@@ -0,0 +1,7 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ import type { DoNotDisturbPlugin, DoNotDisturbState } from './definitions';
3
+ export declare class DoNotDisturbWeb extends WebPlugin implements DoNotDisturbPlugin {
4
+ private currentState;
5
+ monitor(callback: (result: DoNotDisturbState) => void): Promise<void>;
6
+ toggleDoNotDisturb(): Promise<void>;
7
+ }
@@ -0,0 +1,16 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ export class DoNotDisturbWeb extends WebPlugin {
3
+ constructor() {
4
+ super(...arguments);
5
+ this.currentState = { doNotDisturb: false };
6
+ }
7
+ monitor(callback) {
8
+ callback(this.currentState);
9
+ return Promise.resolve();
10
+ }
11
+ toggleDoNotDisturb() {
12
+ Object.assign(this.currentState, { doNotDisturb: !this.currentState.doNotDisturb });
13
+ return Promise.resolve();
14
+ }
15
+ }
16
+ //# sourceMappingURL=web.js.map
@@ -0,0 +1 @@
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;IAA9C;;QACU,iBAAY,GAAsB,EAAE,YAAY,EAAE,KAAK,EAAE,CAAA;IAUnE,CAAC;IATC,OAAO,CAAC,QAA6C;QACnD,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;QAC3B,OAAO,OAAO,CAAC,OAAO,EAAE,CAAA;IAC1B,CAAC;IACD,kBAAkB;QAChB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,YAAY,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC,CAAA;QACnF,OAAO,OAAO,CAAC,OAAO,EAAE,CAAA;IAC1B,CAAC;CAEF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { DoNotDisturbPlugin, DoNotDisturbState } from './definitions';\n\nexport class DoNotDisturbWeb extends WebPlugin implements DoNotDisturbPlugin {\n private currentState: DoNotDisturbState = { doNotDisturb: false }\n monitor(callback: (result: DoNotDisturbState) => void): Promise<void> {\n callback(this.currentState)\n return Promise.resolve()\n }\n toggleDoNotDisturb(): Promise<void> {\n Object.assign(this.currentState, { doNotDisturb: !this.currentState.doNotDisturb })\n return Promise.resolve()\n }\n\n}\n"]}
@@ -0,0 +1,32 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var core = require('@capacitor/core');
6
+
7
+ const DoNotDisturb = core.registerPlugin('DoNotDisturb', {
8
+ web: () => Promise.resolve().then(function () { return web; }).then(m => new m.DoNotDisturbWeb()),
9
+ });
10
+
11
+ class DoNotDisturbWeb extends core.WebPlugin {
12
+ constructor() {
13
+ super(...arguments);
14
+ this.currentState = { doNotDisturb: false };
15
+ }
16
+ monitor(callback) {
17
+ callback(this.currentState);
18
+ return Promise.resolve();
19
+ }
20
+ toggleDoNotDisturb() {
21
+ Object.assign(this.currentState, { doNotDisturb: !this.currentState.doNotDisturb });
22
+ return Promise.resolve();
23
+ }
24
+ }
25
+
26
+ var web = /*#__PURE__*/Object.freeze({
27
+ __proto__: null,
28
+ DoNotDisturbWeb: DoNotDisturbWeb
29
+ });
30
+
31
+ exports.DoNotDisturb = DoNotDisturb;
32
+ //# sourceMappingURL=plugin.cjs.js.map
@@ -0,0 +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 constructor() {\n super(...arguments);\n this.currentState = { doNotDisturb: false };\n }\n monitor(callback) {\n callback(this.currentState);\n return Promise.resolve();\n }\n toggleDoNotDisturb() {\n Object.assign(this.currentState, { doNotDisturb: !this.currentState.doNotDisturb });\n return Promise.resolve();\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,WAAW,GAAG;AAClB,QAAQ,KAAK,CAAC,GAAG,SAAS,CAAC,CAAC;AAC5B,QAAQ,IAAI,CAAC,YAAY,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;AACpD,KAAK;AACL,IAAI,OAAO,CAAC,QAAQ,EAAE;AACtB,QAAQ,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;AACpC,QAAQ,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;AACjC,KAAK;AACL,IAAI,kBAAkB,GAAG;AACzB,QAAQ,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,YAAY,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC,CAAC;AAC5F,QAAQ,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;AACjC,KAAK;AACL;;;;;;;;;"}
package/dist/plugin.js ADDED
@@ -0,0 +1,35 @@
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
+ constructor() {
10
+ super(...arguments);
11
+ this.currentState = { doNotDisturb: false };
12
+ }
13
+ monitor(callback) {
14
+ callback(this.currentState);
15
+ return Promise.resolve();
16
+ }
17
+ toggleDoNotDisturb() {
18
+ Object.assign(this.currentState, { doNotDisturb: !this.currentState.doNotDisturb });
19
+ return Promise.resolve();
20
+ }
21
+ }
22
+
23
+ var web = /*#__PURE__*/Object.freeze({
24
+ __proto__: null,
25
+ DoNotDisturbWeb: DoNotDisturbWeb
26
+ });
27
+
28
+ exports.DoNotDisturb = DoNotDisturb;
29
+
30
+ Object.defineProperty(exports, '__esModule', { value: true });
31
+
32
+ return exports;
33
+
34
+ })({}, capacitorExports);
35
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +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 constructor() {\n super(...arguments);\n this.currentState = { doNotDisturb: false };\n }\n monitor(callback) {\n callback(this.currentState);\n return Promise.resolve();\n }\n toggleDoNotDisturb() {\n Object.assign(this.currentState, { doNotDisturb: !this.currentState.doNotDisturb });\n return Promise.resolve();\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,WAAW,GAAG;IAClB,QAAQ,KAAK,CAAC,GAAG,SAAS,CAAC,CAAC;IAC5B,QAAQ,IAAI,CAAC,YAAY,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;IACpD,KAAK;IACL,IAAI,OAAO,CAAC,QAAQ,EAAE;IACtB,QAAQ,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACpC,QAAQ,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IACjC,KAAK;IACL,IAAI,kBAAkB,GAAG;IACzB,QAAQ,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,YAAY,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC,CAAC;IAC5F,QAAQ,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IACjC,KAAK;IACL;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,8 @@
1
+ import Foundation
2
+
3
+ @objc public class DoNotDisturb: NSObject {
4
+ @objc public func echo(_ value: String) -> String {
5
+ print(value)
6
+ return value
7
+ }
8
+ }
@@ -0,0 +1,10 @@
1
+ #import <UIKit/UIKit.h>
2
+
3
+ //! Project version number for Plugin.
4
+ FOUNDATION_EXPORT double PluginVersionNumber;
5
+
6
+ //! Project version string for Plugin.
7
+ FOUNDATION_EXPORT const unsigned char PluginVersionString[];
8
+
9
+ // In this header, you should import all the public headers of your framework using statements like #import <Plugin/PublicHeader.h>
10
+
@@ -0,0 +1,8 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import <Capacitor/Capacitor.h>
3
+
4
+ // Define the plugin using the CAP_PLUGIN Macro, and
5
+ // each method the plugin supports using the CAP_PLUGIN_METHOD macro.
6
+ CAP_PLUGIN(DoNotDisturbPlugin, "DoNotDisturb",
7
+ CAP_PLUGIN_METHOD(echo, CAPPluginReturnPromise);
8
+ )
@@ -0,0 +1,18 @@
1
+ import Foundation
2
+ import Capacitor
3
+
4
+ /**
5
+ * Please read the Capacitor iOS Plugin Development Guide
6
+ * here: https://capacitorjs.com/docs/plugins/ios
7
+ */
8
+ @objc(DoNotDisturbPlugin)
9
+ public class DoNotDisturbPlugin: CAPPlugin {
10
+ private let implementation = DoNotDisturb()
11
+
12
+ @objc func echo(_ call: CAPPluginCall) {
13
+ let value = call.getString("value") ?? ""
14
+ call.resolve([
15
+ "value": implementation.echo(value)
16
+ ])
17
+ }
18
+ }
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>CFBundleDevelopmentRegion</key>
6
+ <string>$(DEVELOPMENT_LANGUAGE)</string>
7
+ <key>CFBundleExecutable</key>
8
+ <string>$(EXECUTABLE_NAME)</string>
9
+ <key>CFBundleIdentifier</key>
10
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11
+ <key>CFBundleInfoDictionaryVersion</key>
12
+ <string>6.0</string>
13
+ <key>CFBundleName</key>
14
+ <string>$(PRODUCT_NAME)</string>
15
+ <key>CFBundlePackageType</key>
16
+ <string>FMWK</string>
17
+ <key>CFBundleShortVersionString</key>
18
+ <string>1.0</string>
19
+ <key>CFBundleVersion</key>
20
+ <string>$(CURRENT_PROJECT_VERSION)</string>
21
+ <key>NSPrincipalClass</key>
22
+ <string></string>
23
+ </dict>
24
+ </plist>
package/package.json ADDED
@@ -0,0 +1,78 @@
1
+ {
2
+ "name": "@gachlab/capacitor-dnd-plugin",
3
+ "version": "0.0.2",
4
+ "description": "A plugin to set and monitor the Do Not Disturb state",
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/Plugin/",
14
+ "GachlabCapacitorDndPlugin.podspec"
15
+ ],
16
+ "author": "Guillermo Carrillo",
17
+ "license": "MIT",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/gachlab/capacitor-do-not-disturb-plugin.git"
21
+ },
22
+ "bugs": {
23
+ "url": "https://github.com/gachlab/capacitor-do-not-disturb-plugin/issues"
24
+ },
25
+ "keywords": [
26
+ "capacitor",
27
+ "plugin",
28
+ "native"
29
+ ],
30
+ "scripts": {
31
+ "verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
32
+ "verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin -destination generic/platform=iOS && cd ..",
33
+ "verify:android": "cd android && ./gradlew clean build test && cd ..",
34
+ "verify:web": "npm run build",
35
+ "lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
36
+ "fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
37
+ "eslint": "eslint . --ext ts",
38
+ "prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
39
+ "swiftlint": "node-swiftlint",
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.js",
42
+ "clean": "rimraf ./dist",
43
+ "watch": "tsc --watch",
44
+ "prepublishOnly": "npm run build"
45
+ },
46
+ "devDependencies": {
47
+ "@capacitor/android": "^5.0.0",
48
+ "@capacitor/core": "^5.0.0",
49
+ "@capacitor/docgen": "^0.0.18",
50
+ "@capacitor/ios": "^5.0.0",
51
+ "@ionic/eslint-config": "^0.3.0",
52
+ "@ionic/prettier-config": "^1.0.1",
53
+ "@ionic/swiftlint-config": "^1.1.2",
54
+ "eslint": "^7.11.0",
55
+ "prettier": "~2.3.0",
56
+ "prettier-plugin-java": "~1.0.2",
57
+ "rimraf": "^3.0.2",
58
+ "rollup": "^2.32.0",
59
+ "swiftlint": "^1.0.1",
60
+ "typescript": "~4.1.5"
61
+ },
62
+ "peerDependencies": {
63
+ "@capacitor/core": "^5.0.0"
64
+ },
65
+ "prettier": "@ionic/prettier-config",
66
+ "swiftlint": "@ionic/swiftlint-config",
67
+ "eslintConfig": {
68
+ "extends": "@ionic/eslint-config/recommended"
69
+ },
70
+ "capacitor": {
71
+ "ios": {
72
+ "src": "ios"
73
+ },
74
+ "android": {
75
+ "src": "android"
76
+ }
77
+ }
78
+ }