capacitor-event-bird 0.0.29 → 0.0.30

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
@@ -13,14 +13,12 @@ npx cap sync
13
13
 
14
14
  <docgen-index>
15
15
 
16
- * [`echo(...)`](#echo)
17
- * [`logout()`](#logout)
18
16
  * [`signupWithGoogle()`](#signupwithgoogle)
19
17
  * [`waitlistAfterInit()`](#waitlistafterinit)
20
18
  * [`openHelpModal()`](#openhelpmodal)
21
19
  * [`getDeviceId()`](#getdeviceid)
22
- * [`getGoogleData()`](#getgoogledata)
23
20
  * [`getFCMToken(...)`](#getfcmtoken)
21
+ * [`saveCredentials(...)`](#savecredentials)
24
22
  * [`addListener('fcmTokenRefreshed', ...)`](#addlistenerfcmtokenrefreshed-)
25
23
  * [Interfaces](#interfaces)
26
24
 
@@ -29,36 +27,14 @@ npx cap sync
29
27
  <docgen-api>
30
28
  <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
31
29
 
32
- ### echo(...)
33
-
34
- ```typescript
35
- echo(options: { value: string; }) => Promise<{ value: string; }>
36
- ```
37
-
38
- | Param | Type |
39
- | ------------- | ------------------------------- |
40
- | **`options`** | <code>{ value: string; }</code> |
41
-
42
- **Returns:** <code>Promise&lt;{ value: string; }&gt;</code>
43
-
44
- --------------------
45
-
46
-
47
- ### logout()
48
-
49
- ```typescript
50
- logout() => Promise<void>
51
- ```
52
-
53
- --------------------
54
-
55
-
56
30
  ### signupWithGoogle()
57
31
 
58
32
  ```typescript
59
- signupWithGoogle() => Promise<void>
33
+ signupWithGoogle() => Promise<{ displayName: string; email: string; firebaseToken: string; }>
60
34
  ```
61
35
 
36
+ **Returns:** <code>Promise&lt;{ displayName: string; email: string; firebaseToken: string; }&gt;</code>
37
+
62
38
  --------------------
63
39
 
64
40
 
@@ -91,28 +67,32 @@ getDeviceId() => Promise<{ value: string; }>
91
67
  --------------------
92
68
 
93
69
 
94
- ### getGoogleData()
70
+ ### getFCMToken(...)
95
71
 
96
72
  ```typescript
97
- getGoogleData() => Promise<{ displayName: string; email: string; firebaseToken: string; }>
73
+ getFCMToken(options: { value: string; }) => Promise<{ value: string; }>
98
74
  ```
99
75
 
100
- **Returns:** <code>Promise&lt;{ displayName: string; email: string; firebaseToken: string; }&gt;</code>
76
+ | Param | Type |
77
+ | ------------- | ------------------------------- |
78
+ | **`options`** | <code>{ value: string; }</code> |
79
+
80
+ **Returns:** <code>Promise&lt;{ value: string; }&gt;</code>
101
81
 
102
82
  --------------------
103
83
 
104
84
 
105
- ### getFCMToken(...)
85
+ ### saveCredentials(...)
106
86
 
107
87
  ```typescript
108
- getFCMToken(options: { value: string; }) => Promise<{ value: string; }>
88
+ saveCredentials(options: { username: string; password: string; }) => Promise<{ isSuccess: boolean; }>
109
89
  ```
110
90
 
111
- | Param | Type |
112
- | ------------- | ------------------------------- |
113
- | **`options`** | <code>{ value: string; }</code> |
91
+ | Param | Type |
92
+ | ------------- | ---------------------------------------------------- |
93
+ | **`options`** | <code>{ username: string; password: string; }</code> |
114
94
 
115
- **Returns:** <code>Promise&lt;{ value: string; }&gt;</code>
95
+ **Returns:** <code>Promise&lt;{ isSuccess: boolean; }&gt;</code>
116
96
 
117
97
  --------------------
118
98
 
package/dist/docs.json CHANGED
@@ -5,37 +5,11 @@
5
5
  "docs": "",
6
6
  "tags": [],
7
7
  "methods": [
8
- {
9
- "name": "echo",
10
- "signature": "(options: { value: string; }) => Promise<{ value: string; }>",
11
- "parameters": [
12
- {
13
- "name": "options",
14
- "docs": "",
15
- "type": "{ value: string; }"
16
- }
17
- ],
18
- "returns": "Promise<{ value: string; }>",
19
- "tags": [],
20
- "docs": "",
21
- "complexTypes": [],
22
- "slug": "echo"
23
- },
24
- {
25
- "name": "logout",
26
- "signature": "() => Promise<void>",
27
- "parameters": [],
28
- "returns": "Promise<void>",
29
- "tags": [],
30
- "docs": "",
31
- "complexTypes": [],
32
- "slug": "logout"
33
- },
34
8
  {
35
9
  "name": "signupWithGoogle",
36
- "signature": "() => Promise<void>",
10
+ "signature": "() => Promise<{ displayName: string; email: string; firebaseToken: string; }>",
37
11
  "parameters": [],
38
- "returns": "Promise<void>",
12
+ "returns": "Promise<{ displayName: string; email: string; firebaseToken: string; }>",
39
13
  "tags": [],
40
14
  "docs": "",
41
15
  "complexTypes": [],
@@ -71,16 +45,6 @@
71
45
  "complexTypes": [],
72
46
  "slug": "getdeviceid"
73
47
  },
74
- {
75
- "name": "getGoogleData",
76
- "signature": "() => Promise<{ displayName: string; email: string; firebaseToken: string; }>",
77
- "parameters": [],
78
- "returns": "Promise<{ displayName: string; email: string; firebaseToken: string; }>",
79
- "tags": [],
80
- "docs": "",
81
- "complexTypes": [],
82
- "slug": "getgoogledata"
83
- },
84
48
  {
85
49
  "name": "getFCMToken",
86
50
  "signature": "(options: { value: string; }) => Promise<{ value: string; }>",
@@ -97,6 +61,22 @@
97
61
  "complexTypes": [],
98
62
  "slug": "getfcmtoken"
99
63
  },
64
+ {
65
+ "name": "saveCredentials",
66
+ "signature": "(options: { username: string; password: string; }) => Promise<{ isSuccess: boolean; }>",
67
+ "parameters": [
68
+ {
69
+ "name": "options",
70
+ "docs": "",
71
+ "type": "{ username: string; password: string; }"
72
+ }
73
+ ],
74
+ "returns": "Promise<{ isSuccess: boolean; }>",
75
+ "tags": [],
76
+ "docs": "",
77
+ "complexTypes": [],
78
+ "slug": "savecredentials"
79
+ },
100
80
  {
101
81
  "name": "addListener",
102
82
  "signature": "(eventName: 'fcmTokenRefreshed', listenerFunc: (data: { token: string; }) => void) => Promise<PluginListenerHandle>",
@@ -1,27 +1,26 @@
1
1
  import { PluginListenerHandle } from '@capacitor/core';
2
2
  export interface CapacitorEventBirdPlugin {
3
- echo(options: {
4
- value: string;
5
- }): Promise<{
6
- value: string;
3
+ signupWithGoogle(): Promise<{
4
+ displayName: string;
5
+ email: string;
6
+ firebaseToken: string;
7
7
  }>;
8
- logout(): Promise<void>;
9
- signupWithGoogle(): Promise<void>;
10
8
  waitlistAfterInit(): Promise<void>;
11
9
  openHelpModal(): Promise<void>;
12
10
  getDeviceId(): Promise<{
13
11
  value: string;
14
12
  }>;
15
- getGoogleData(): Promise<{
16
- displayName: string;
17
- email: string;
18
- firebaseToken: string;
19
- }>;
20
13
  getFCMToken(options: {
21
14
  value: string;
22
15
  }): Promise<{
23
16
  value: string;
24
17
  }>;
18
+ saveCredentials(options: {
19
+ username: string;
20
+ password: string;
21
+ }): Promise<{
22
+ isSuccess: boolean;
23
+ }>;
25
24
  addListener(eventName: 'fcmTokenRefreshed', listenerFunc: (data: {
26
25
  token: string;
27
26
  }) => void): Promise<PluginListenerHandle>;
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import { PluginListenerHandle } from '@capacitor/core';\n\nexport interface CapacitorEventBirdPlugin {\n echo(options: { value: string }): Promise<{ value: string }>;\n logout(): Promise<void>;\n signupWithGoogle(): Promise<void>;\n waitlistAfterInit(): Promise<void>;\n openHelpModal(): Promise<void>;\n getDeviceId(): Promise<{ value: string }>;\n getGoogleData(): Promise<{ displayName: string; email: string; firebaseToken: string }>;\n getFCMToken(options: { value: string }): Promise<{ value: string }>;\n addListener(\n eventName: 'fcmTokenRefreshed',\n listenerFunc: (data: { token: string }) => void,\n ): Promise<PluginListenerHandle>;\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import { PluginListenerHandle } from '@capacitor/core';\n\nexport interface CapacitorEventBirdPlugin {\n signupWithGoogle(): Promise<{ displayName: string; email: string; firebaseToken: string }>;\n waitlistAfterInit(): Promise<void>;\n openHelpModal(): Promise<void>;\n getDeviceId(): Promise<{ value: string }>;\n getFCMToken(options: { value: string }): Promise<{ value: string }>;\n saveCredentials(options: { username: string; password: string }): Promise<{ isSuccess: boolean }>;\n addListener(\n eventName: 'fcmTokenRefreshed',\n listenerFunc: (data: { token: string }) => void,\n ): Promise<PluginListenerHandle>;\n}\n"]}
package/dist/esm/web.d.ts CHANGED
@@ -1,26 +1,25 @@
1
1
  import { WebPlugin } from '@capacitor/core';
2
2
  import type { CapacitorEventBirdPlugin } from './definitions';
3
3
  export declare class CapacitorEventBirdWeb extends WebPlugin implements CapacitorEventBirdPlugin {
4
- echo(options: {
5
- value: string;
4
+ saveCredentials(_: {
5
+ username: string;
6
+ password: string;
6
7
  }): Promise<{
7
- value: string;
8
+ isSuccess: boolean;
8
9
  }>;
9
10
  getFCMToken(options: {
10
11
  value: string;
11
12
  }): Promise<{
12
13
  value: string;
13
14
  }>;
14
- logout(): Promise<void>;
15
- signupWithGoogle(): Promise<void>;
15
+ signupWithGoogle(): Promise<{
16
+ displayName: string;
17
+ email: string;
18
+ firebaseToken: string;
19
+ }>;
16
20
  openHelpModal(): Promise<void>;
17
21
  waitlistAfterInit(): Promise<void>;
18
22
  getDeviceId(): Promise<{
19
23
  value: string;
20
24
  }>;
21
- getGoogleData(): Promise<{
22
- displayName: string;
23
- email: string;
24
- firebaseToken: string;
25
- }>;
26
25
  }
package/dist/esm/web.js CHANGED
@@ -1,18 +1,19 @@
1
1
  import { WebPlugin } from '@capacitor/core';
2
2
  export class CapacitorEventBirdWeb extends WebPlugin {
3
- async echo(options) {
4
- console.log('ECHO', options);
5
- return options;
3
+ saveCredentials(_) {
4
+ throw new Error('Method not implemented.');
6
5
  }
7
6
  async getFCMToken(options) {
8
7
  console.log('getFCMToken', options);
9
8
  return options;
10
9
  }
11
- async logout() {
12
- console.log('logout in web isnt really needed it already works');
13
- }
14
10
  async signupWithGoogle() {
15
11
  console.log('signupWithGoogle in web isnt really needed it already works');
12
+ return {
13
+ displayName: '',
14
+ email: '',
15
+ firebaseToken: '',
16
+ };
16
17
  }
17
18
  async openHelpModal() {
18
19
  console.log('openHelpModal in web isnt really needed it already works');
@@ -23,12 +24,5 @@ export class CapacitorEventBirdWeb extends WebPlugin {
23
24
  async getDeviceId() {
24
25
  return { value: 'ios device id is not needed for web' };
25
26
  }
26
- async getGoogleData() {
27
- return {
28
- displayName: '',
29
- email: '',
30
- firebaseToken: '',
31
- };
32
- }
33
27
  }
34
28
  //# sourceMappingURL=web.js.map
@@ -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,qBAAsB,SAAQ,SAAS;IAClD,KAAK,CAAC,IAAI,CAAC,OAA0B;QACnC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC7B,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,OAA0B;QAC1C,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QACpC,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,MAAM;QACV,OAAO,CAAC,GAAG,CAAC,mDAAmD,CAAC,CAAC;IACnE,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,CAAC,GAAG,CAAC,6DAA6D,CAAC,CAAC;IAC7E,CAAC;IAED,KAAK,CAAC,aAAa;QACjB,OAAO,CAAC,GAAG,CAAC,0DAA0D,CAAC,CAAC;IAC1E,CAAC;IAED,KAAK,CAAC,iBAAiB;QACrB,OAAO,CAAC,GAAG,CAAC,8DAA8D,CAAC,CAAC;IAC9E,CAAC;IAED,KAAK,CAAC,WAAW;QACf,OAAO,EAAE,KAAK,EAAE,qCAAqC,EAAE,CAAC;IAC1D,CAAC;IAED,KAAK,CAAC,aAAa;QACjB,OAAO;YACL,WAAW,EAAE,EAAE;YACf,KAAK,EAAE,EAAE;YACT,aAAa,EAAE,EAAE;SAClB,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { CapacitorEventBirdPlugin } from './definitions';\n\nexport class CapacitorEventBirdWeb extends WebPlugin implements CapacitorEventBirdPlugin {\n async echo(options: { value: string }): Promise<{ value: string }> {\n console.log('ECHO', options);\n return options;\n }\n\n async getFCMToken(options: { value: string }): Promise<{ value: string }> {\n console.log('getFCMToken', options);\n return options;\n }\n\n async logout(): Promise<void> {\n console.log('logout in web isnt really needed it already works');\n }\n\n async signupWithGoogle(): Promise<void> {\n console.log('signupWithGoogle in web isnt really needed it already works');\n }\n\n async openHelpModal(): Promise<void> {\n console.log('openHelpModal in web isnt really needed it already works');\n }\n\n async waitlistAfterInit(): Promise<void> {\n console.log('waitlistAfterInit in web isnt really needed it already works');\n }\n\n async getDeviceId(): Promise<{ value: string }> {\n return { value: 'ios device id is not needed for web' };\n }\n\n async getGoogleData(): Promise<{ displayName: string; email: string; firebaseToken: string }> {\n return {\n displayName: '',\n email: '',\n firebaseToken: '',\n };\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,qBAAsB,SAAQ,SAAS;IAClD,eAAe,CAAC,CAAyC;QACvD,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,OAA0B;QAC1C,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QACpC,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,CAAC,GAAG,CAAC,6DAA6D,CAAC,CAAC;QAC3E,OAAO;YACL,WAAW,EAAE,EAAE;YACf,KAAK,EAAE,EAAE;YACT,aAAa,EAAE,EAAE;SAClB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,aAAa;QACjB,OAAO,CAAC,GAAG,CAAC,0DAA0D,CAAC,CAAC;IAC1E,CAAC;IAED,KAAK,CAAC,iBAAiB;QACrB,OAAO,CAAC,GAAG,CAAC,8DAA8D,CAAC,CAAC;IAC9E,CAAC;IAED,KAAK,CAAC,WAAW;QACf,OAAO,EAAE,KAAK,EAAE,qCAAqC,EAAE,CAAC;IAC1D,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { CapacitorEventBirdPlugin } from './definitions';\n\nexport class CapacitorEventBirdWeb extends WebPlugin implements CapacitorEventBirdPlugin {\n saveCredentials(_: { username: string; password: string }): Promise<{ isSuccess: boolean }> {\n throw new Error('Method not implemented.');\n }\n\n async getFCMToken(options: { value: string }): Promise<{ value: string }> {\n console.log('getFCMToken', options);\n return options;\n }\n\n async signupWithGoogle(): Promise<{ displayName: string; email: string; firebaseToken: string }> {\n console.log('signupWithGoogle in web isnt really needed it already works');\n return {\n displayName: '',\n email: '',\n firebaseToken: '',\n };\n }\n\n async openHelpModal(): Promise<void> {\n console.log('openHelpModal in web isnt really needed it already works');\n }\n\n async waitlistAfterInit(): Promise<void> {\n console.log('waitlistAfterInit in web isnt really needed it already works');\n }\n\n async getDeviceId(): Promise<{ value: string }> {\n return { value: 'ios device id is not needed for web' };\n }\n}\n"]}
@@ -7,33 +7,35 @@ public class CapacitorEventBirdPlugin: CAPPlugin, CAPBridgedPlugin {
7
7
  public let jsName = "CapacitorEventBird"
8
8
 
9
9
  public let pluginMethods: [CAPPluginMethod] = [
10
- CAPPluginMethod(name: "echo", returnType: CAPPluginReturnPromise),
11
10
  CAPPluginMethod(name: "getFCMToken", returnType: CAPPluginReturnPromise),
12
- CAPPluginMethod(name: "logout", returnType: CAPPluginReturnPromise),
13
- CAPPluginMethod(name: "signupWithGoogle", returnType: CAPPluginReturnPromise),
14
11
  CAPPluginMethod(name: "waitlistAfterInit", returnType: CAPPluginReturnPromise),
15
12
  CAPPluginMethod(name: "openHelpModal", returnType: CAPPluginReturnPromise),
16
13
  CAPPluginMethod(name: "getDeviceId", returnType: CAPPluginReturnPromise),
17
- CAPPluginMethod(name: "getGoogleData", returnType: CAPPluginReturnPromise),
14
+ CAPPluginMethod(name: "signupWithGoogle", returnType: CAPPluginReturnPromise),
15
+ CAPPluginMethod(name: "saveCredentials", returnType: CAPPluginReturnPromise),
18
16
  ]
19
17
 
20
- private var pendingEchoCalls: [CAPPluginCall] = []
21
18
  private var pendingFCMCalls: [CAPPluginCall] = []
22
19
  private var pendingGoogleCalls: [CAPPluginCall] = []
20
+ private var pendingSaveCredentialsCall: [CAPPluginCall] = []
23
21
 
24
- private var savedToken: String?
25
22
  private var savedFCMToken: String?
26
23
 
27
- private let implementation = CapacitorEventBird()
24
+ @objc func saveCredentials(_ call: CAPPluginCall) {
25
+ let username = call.getString("username") ?? ""
26
+ let password = call.getString("password") ?? ""
28
27
 
29
- @objc func echo(_ call: CAPPluginCall) {
30
- if let token = savedToken {
31
- print("[Native] JS called echo, passing the token.")
32
- call.resolve(["value": token])
33
- } else {
34
- print("[Native] JS called echo, but token not ready. Queuing callback.")
35
- pendingEchoCalls.append(call)
28
+ NotificationCenter.default.post(name: Notification.Name("SaveCredentials"), object: ["username": username, "password": password])
29
+ pendingSaveCredentialsCall.append(call)
30
+ }
31
+
32
+ @objc public func saveCredentialsResult(_ isSuccess: Bool) {
33
+ print("[Native] saveCredentialsResult()")
34
+
35
+ for call in pendingSaveCredentialsCall {
36
+ call.resolve(["isSuccess": isSuccess])
36
37
  }
38
+ pendingSaveCredentialsCall.removeAll()
37
39
  }
38
40
 
39
41
  @objc func getFCMToken(_ call: CAPPluginCall) {
@@ -51,8 +53,9 @@ public class CapacitorEventBirdPlugin: CAPPlugin, CAPBridgedPlugin {
51
53
  return
52
54
  }
53
55
 
54
- @objc func getGoogleData(_ call: CAPPluginCall) {
55
- print("[Native] JS called getGoogleData, but data not ready. Queuing callback.")
56
+ @objc func signupWithGoogle(_ call: CAPPluginCall) {
57
+ NotificationCenter.default.post(name: Notification.Name("CapacitorSignupWithGoogle"), object: nil)
58
+ print("[Native] JS called getGoogleData, sending CapacitorSignupWithGoogle event")
56
59
  pendingGoogleCalls.append(call)
57
60
  }
58
61
 
@@ -71,33 +74,11 @@ public class CapacitorEventBirdPlugin: CAPPlugin, CAPBridgedPlugin {
71
74
  for call in pendingFCMCalls {
72
75
  call.resolve(["value": token])
73
76
  }
74
- pendingFCMCalls.removeAll()
75
77
 
78
+ pendingFCMCalls.removeAll()
76
79
  notifyListeners("fcmTokenRefreshed", data: ["token": token])
77
80
  }
78
81
 
79
- @objc public func setAuthToken(_ token: String) {
80
- print("[Native] Setting auth token in plugin")
81
- self.savedToken = token
82
-
83
- for call in pendingEchoCalls {
84
- call.resolve(["value": token])
85
- }
86
- pendingEchoCalls.removeAll()
87
- }
88
-
89
- @objc func logout(_ call: CAPPluginCall) {
90
- NotificationCenter.default.post(name: Notification.Name("NativeLogoutEvent"), object: nil)
91
- savedToken = nil
92
- pendingEchoCalls.removeAll()
93
- call.resolve()
94
- }
95
-
96
- @objc func signupWithGoogle(_ call: CAPPluginCall) {
97
- NotificationCenter.default.post(name: Notification.Name("CapacitorSignupWithGoogle"), object: nil)
98
- call.resolve()
99
- }
100
-
101
82
  @objc func openHelpModal(_ call: CAPPluginCall) {
102
83
  NotificationCenter.default.post(name: Notification.Name("HelpBeaconOpenEvent"), object: nil)
103
84
  call.resolve()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capacitor-event-bird",
3
- "version": "0.0.29",
3
+ "version": "0.0.30",
4
4
  "description": "returns events back to native env",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -1,8 +0,0 @@
1
- import Foundation
2
-
3
- @objc public class CapacitorEventBird: NSObject {
4
- @objc public func echo(_ value: String) -> String {
5
- print(value)
6
- return value
7
- }
8
- }