Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(push): push notifications plugin #2066

Draft
wants to merge 3 commits into
base: v2
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions plugins/push-notifications/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/.vs
.DS_Store
.Thumbs.db
*.sublime*
.idea/
debug.log
package-lock.json
.vscode/settings.json
yarn.lock

/.tauri
/target
Cargo.lock
node_modules/

dist-js
dist
39 changes: 39 additions & 0 deletions plugins/push-notifications/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[package]
name = "tauri-plugin-push-notifications"
version = "0.1.0"
description = "Enable push notifications in your Tauri app."
edition = { workspace = true }
authors = { workspace = true }
license = { workspace = true }
rust-version = { workspace = true }
repository = { workspace = true }
exclude = ["/examples", "/webview-dist", "/webview-src", "/node_modules"]
links = "tauri-plugin-push-notifications"

[package.metadata.docs.rs]
rustc-args = ["--cfg", "docsrs"]
rustdoc-args = ["--cfg", "docsrs"]

[package.metadata.platforms.support]
linux = { level = "none", notes = "No push functionality available" }
windows = { level = "partial", notes = "Experimental" }
macos = { level = "full", notes = "" }
android = { level = "full", notes = "" }
ios = { level = "full", notes = "" }

[dependencies]
tauri = { workspace = true, features = ["push-notifications"] }
serde = { workspace = true }
serde_json = { workspace = true }
thiserror = { workspace = true }
base64 = "^0"

[build-dependencies]
tauri-plugin = { version = "^2", features = ["build"] }
schemars = { workspace = true }
serde = { workspace = true }

[patch.crates-io]
tauri = { path = "/workspace/tauri/crates/tauri" }
tauri-plugin = { path = "/workspace/tauri/crates/tauri-plugin" }
tao = { path = "/workspace/tao" }
4 changes: 4 additions & 0 deletions plugins/push-notifications/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Tauri Plugin push-notifications

Coming soon.

8 changes: 8 additions & 0 deletions plugins/push-notifications/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const COMMANDS: &[&str] = &["push_token"];

fn main() {
tauri_plugin::Builder::new(COMMANDS)
.android_path("android")
.ios_path("ios")
.build();
}
12 changes: 12 additions & 0 deletions plugins/push-notifications/guest-js/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { invoke } from "@tauri-apps/api/core"

export type PushTokenResponse = {
value?: string;
}

export async function pushToken(): Promise<string | null> {
return await invoke<{value?: string}>('plugin:push-notifications|push_token', {
payload: {},
}).then((r: PushTokenResponse) => (r.value ? r.value : null));
}

33 changes: 33 additions & 0 deletions plugins/push-notifications/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "tauri-plugin-push-notifications",
"version": "0.1.0",
"author": "Sam Gammon <[email protected]>",
"description": "Tauri plugin for push notifications (APNS, FCM, etc)",
"type": "module",
"types": "./dist-js/index.d.ts",
"main": "./dist-js/index.cjs",
"module": "./dist-js/index.js",
"exports": {
"types": "./dist-js/index.d.ts",
"import": "./dist-js/index.js",
"require": "./dist-js/index.cjs"
},
"files": [
"dist-js",
"README.md"
],
"scripts": {
"build": "rollup -c",
"prepublishOnly": "pnpm build",
"pretest": "pnpm build"
},
"dependencies": {
"@tauri-apps/api": ">=2.0.0-beta.6"
},
"devDependencies": {
"@rollup/plugin-typescript": "^11.1.6",
"rollup": "^4.9.6",
"typescript": "^5.3.3",
"tslib": "^2.6.2"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Automatically generated - DO NOT EDIT!

"$schema" = "../../schemas/schema.json"

[[permission]]
identifier = "allow-push-token"
description = "Enables the push_token command without any pre-configured scope."
commands.allow = ["push_token"]

[[permission]]
identifier = "deny-push-token"
description = "Denies the push_token command without any pre-configured scope."
commands.deny = ["push_token"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
## Default Permission

Default permissions for the plugin

- `allow-push-token`

## Permission Table

<table>
<tr>
<th>Identifier</th>
<th>Description</th>
</tr>


<tr>
<td>

`push-notifications:allow-push-token`

</td>
<td>

Enables the push_token command without any pre-configured scope.

</td>
</tr>

<tr>
<td>

`push-notifications:deny-push-token`

</td>
<td>

Denies the push_token command without any pre-configured scope.

</td>
</tr>
</table>
3 changes: 3 additions & 0 deletions plugins/push-notifications/permissions/default.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[default]
description = "Default permissions for the plugin"
permissions = ["allow-push-token"]
Loading