@droponio/capacitor-intent-fragment 2.0.0 → 2.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.
package/README.md CHANGED
@@ -25,12 +25,12 @@ npx cap sync
25
25
  ### registerBroadcastReceiver(...)
26
26
 
27
27
  ```typescript
28
- registerBroadcastReceiver(options: { filters: string[]; }, callback: (data: { [key: string]: any; }) => void) => Promise<string>
28
+ registerBroadcastReceiver(options: { filters: string[]; exported?: boolean; }, callback: (data: { [key: string]: any; }) => void) => Promise<string>
29
29
  ```
30
30
 
31
31
  | Param | Type |
32
32
  | -------------- | ------------------------------------------------------- |
33
- | **`options`** | <code>{ filters: string[]; }</code> |
33
+ | **`options`** | <code>{ filters: string[]; exported?: boolean; }</code> |
34
34
  | **`callback`** | <code>(data: { [key: string]: any; }) =&gt; void</code> |
35
35
 
36
36
  **Returns:** <code>Promise&lt;string&gt;</code>
@@ -89,15 +89,38 @@ public class CapacitorIntentPlugin extends Plugin {
89
89
  }
90
90
  );
91
91
 
92
- this.getContext().registerReceiver(receiverMap.get(callBackID), ifilt);
92
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
93
+ int flag = Boolean.TRUE.equals(call.getBoolean("exported", false))
94
+ ? Context.RECEIVER_EXPORTED
95
+ : Context.RECEIVER_NOT_EXPORTED;
96
+ this.getContext().registerReceiver(receiverMap.get(callBackID), ifilt, flag);
97
+ } else {
98
+ this.getContext().registerReceiver(receiverMap.get(callBackID), ifilt);
99
+ }
93
100
  } else {
94
101
  call.reject("Filters are required: at least 1 entry");
95
102
  }
96
103
  }
97
104
 
98
105
  private void removeReceiver(String callBackID) {
99
- this.getContext().unregisterReceiver(receiverMap.get(callBackID));
100
- this.receiverMap.remove(callBackID);
106
+ BroadcastReceiver receiver = receiverMap.remove(callBackID);
107
+ if (receiver == null) {
108
+ return;
109
+ }
110
+ try {
111
+ this.getContext().unregisterReceiver(receiver);
112
+ } catch (IllegalArgumentException e) {
113
+ Log.d(LOG_TAG, "Receiver already unregistered: " + callBackID);
114
+ }
115
+ }
116
+
117
+ @Override
118
+ protected void handleOnDestroy() {
119
+ for (String callBackID : new ArrayList<>(receiverMap.keySet())) {
120
+ removeReceiver(callBackID);
121
+ }
122
+ watchingCalls.clear();
123
+ super.handleOnDestroy();
101
124
  }
102
125
 
103
126
  private static Object toJsonValue(final Object value) throws JSONException {
package/dist/docs.json CHANGED
@@ -7,12 +7,12 @@
7
7
  "methods": [
8
8
  {
9
9
  "name": "registerBroadcastReceiver",
10
- "signature": "(options: { filters: string[]; }, callback: (data: { [key: string]: any; }) => void) => Promise<string>",
10
+ "signature": "(options: { filters: string[]; exported?: boolean; }, callback: (data: { [key: string]: any; }) => void) => Promise<string>",
11
11
  "parameters": [
12
12
  {
13
13
  "name": "options",
14
14
  "docs": "",
15
- "type": "{ filters: string[]; }"
15
+ "type": "{ filters: string[]; exported?: boolean | undefined; }"
16
16
  },
17
17
  {
18
18
  "name": "callback",
@@ -1,6 +1,7 @@
1
1
  export interface CapacitorIntentPlugin {
2
2
  registerBroadcastReceiver(options: {
3
3
  filters: string[];
4
+ exported?: boolean;
4
5
  }, callback: (data: {
5
6
  [key: string]: any;
6
7
  }) => void): Promise<string>;
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface CapacitorIntentPlugin {\n registerBroadcastReceiver(\n options: { filters: string[] },\n callback: (data: { [key: string]: any }) => void\n ): Promise<string>;\n\n unregisterBroadcastReceiver(options: { id: string }): Promise<void>;\n\n sendBroadcastIntent(options: { action: string; value: { [key: string]: any } }): Promise<void>;\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface CapacitorIntentPlugin {\n registerBroadcastReceiver(\n options: { filters: string[]; exported?: boolean },\n callback: (data: { [key: string]: any }) => void\n ): Promise<string>;\n\n unregisterBroadcastReceiver(options: { id: string }): Promise<void>;\n\n sendBroadcastIntent(options: { action: string; value: { [key: string]: any } }): Promise<void>;\n}\n"]}
package/dist/esm/web.d.ts CHANGED
@@ -3,6 +3,7 @@ import type { CapacitorIntentPlugin } from './definitions';
3
3
  export declare class CapacitorIntentWeb extends WebPlugin implements CapacitorIntentPlugin {
4
4
  registerBroadcastReceiver(_options: {
5
5
  filters: string[];
6
+ exported?: boolean;
6
7
  }, _callback: (data: {
7
8
  [key: string]: any;
8
9
  }) => void): Promise<string>;
@@ -1 +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,kBACX,SAAQ,SAAS;IAGjB,KAAK,CAAC,yBAAyB,CAC7B,QAA+B,EAC/B,SAAiD;QAEjD,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,2BAA2B,CAAC,QAAwB;QACxD,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,mBAAmB,CAAC,QAGzB;QACC,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { CapacitorIntentPlugin } from './definitions';\n\nexport class CapacitorIntentWeb\n extends WebPlugin\n implements CapacitorIntentPlugin\n{\n async registerBroadcastReceiver(\n _options: { filters: string[] },\n _callback: (data: { [key: string]: any }) => void,\n ): Promise<string> {\n throw new Error('Feature not implemented in web.');\n }\n\n async unregisterBroadcastReceiver(_options: { id: string }) {\n throw new Error('Feature not implemented in web.');\n }\n\n async sendBroadcastIntent(_options: {\n action: string;\n value: { [key: string]: any };\n }): Promise<void> {\n throw new Error('Feature not implemented in web.');\n }\n}\n"]}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,kBACX,SAAQ,SAAS;IAGjB,KAAK,CAAC,yBAAyB,CAC7B,QAAmD,EACnD,SAAiD;QAEjD,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,2BAA2B,CAAC,QAAwB;QACxD,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,mBAAmB,CAAC,QAGzB;QACC,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { CapacitorIntentPlugin } from './definitions';\n\nexport class CapacitorIntentWeb\n extends WebPlugin\n implements CapacitorIntentPlugin\n{\n async registerBroadcastReceiver(\n _options: { filters: string[]; exported?: boolean },\n _callback: (data: { [key: string]: any }) => void,\n ): Promise<string> {\n throw new Error('Feature not implemented in web.');\n }\n\n async unregisterBroadcastReceiver(_options: { id: string }) {\n throw new Error('Feature not implemented in web.');\n }\n\n async sendBroadcastIntent(_options: {\n action: string;\n value: { [key: string]: any };\n }): Promise<void> {\n throw new Error('Feature not implemented in web.');\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@droponio/capacitor-intent-fragment",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "Capacitor Js plugin for receveing and sending intents",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",