@nitra/cap 1.1.2 → 6.1.3
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/package.json +4 -1
- package/save-token/README.md +21 -26
- package/save-token/index.js +1 -1
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nitra/cap",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.1.3",
|
|
4
4
|
"description": "Nitra capacitor components",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./index.js"
|
|
8
|
+
},
|
|
6
9
|
"scripts": {
|
|
7
10
|
"fix": "yarn dlx eslint --fix . && npx prettier --write . "
|
|
8
11
|
},
|
package/save-token/README.md
CHANGED
|
@@ -14,34 +14,18 @@ This library interacts with Firebase for token management and Capacitor to check
|
|
|
14
14
|
saveToken() => Promise<void>
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
## usage with Vite
|
|
18
|
-
|
|
19
|
-
### Set vapid key : `import.meta.env.VITE_VAPID_KEY`
|
|
20
|
-
|
|
21
|
-
### Set host url of the notify project: `import.meta.env.VITE_NOTIFY_URL`
|
|
22
|
-
|
|
23
|
-
The `notify project` is a server-side component designed to handle API requests for saving user push tokens. It uses the Fastify framework and JWT-based security for authentication.
|
|
24
|
-
|
|
25
|
-
### Or set for local dev: `import.meta.env.VITE_LOCALHOST`
|
|
26
|
-
|
|
27
|
-
### Set the name of your app: `import.meta.env.VITE_APP`
|
|
28
|
-
|
|
29
17
|
## usage the library
|
|
30
18
|
|
|
31
|
-
### To use this package, you should add this
|
|
19
|
+
### To use this package, you should add this env to your project where you want to provide push notifications
|
|
32
20
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
})
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
### This code will initialize firebase
|
|
21
|
+
`VITE_APP=test`
|
|
22
|
+
`VITE_PROJECT_ID=test`
|
|
23
|
+
`VITE_VAPID_KEY=test`
|
|
24
|
+
`VITE_API_KEY=test`
|
|
25
|
+
`VITE_AUTH_DOMAIN=test`
|
|
26
|
+
`VITE_STORAGE_BUCKET=test`
|
|
27
|
+
`VITE_MESSAGING_SENDER_ID=test`
|
|
28
|
+
`VITE_APP_ID=test`
|
|
45
29
|
|
|
46
30
|
## example in node
|
|
47
31
|
|
|
@@ -49,7 +33,7 @@ initializeApp({
|
|
|
49
33
|
|
|
50
34
|
```jsx
|
|
51
35
|
<template>
|
|
52
|
-
<n-code
|
|
36
|
+
<n-code :on-token-checked="saveToken" />
|
|
53
37
|
</template>
|
|
54
38
|
|
|
55
39
|
<script setup>
|
|
@@ -119,6 +103,17 @@ function env(props) {
|
|
|
119
103
|
}
|
|
120
104
|
```
|
|
121
105
|
|
|
106
|
+
# For local test you can add this code
|
|
107
|
+
if (process.env.npm_lifecycle_event === 'start-remote-dev') {
|
|
108
|
+
proxy['^/n-push/.*'] = ''
|
|
109
|
+
} else {
|
|
110
|
+
proxy['^/n-push/.*'] = '<http://0.0.0.0:8090>'
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/n-push/ - url of the notify project
|
|
114
|
+
|
|
115
|
+
The `notify project` is a server-side component designed to handle API requests for saving user push tokens. It uses the Fastify framework and JWT-based security for authentication.
|
|
116
|
+
|
|
122
117
|
### Install the plugin in the project directory
|
|
123
118
|
|
|
124
119
|
```typescript
|
package/save-token/index.js
CHANGED
|
@@ -24,7 +24,7 @@ export async function saveToken() {
|
|
|
24
24
|
appId: import.meta.env.VITE_APP_ID
|
|
25
25
|
})
|
|
26
26
|
|
|
27
|
-
if (!Capacitor.isPluginAvailable('FirebaseMessaging')) {
|
|
27
|
+
if (Capacitor.isNativePlatform() && !Capacitor.isPluginAvailable('FirebaseMessaging')) {
|
|
28
28
|
console.error('FirebaseMessaging plugin is not available')
|
|
29
29
|
|
|
30
30
|
return
|