-
-
Notifications
You must be signed in to change notification settings - Fork 5
Added UnifiedPush support #123
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
Open
TastelessVoid
wants to merge
25
commits into
Choochmeque:main
Choose a base branch
from
TastelessVoid:unified-push-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
988ee33
Added UnifiedPush support
TastelessVoid f26e0fa
Move to UnifiedPush v3
TastelessVoid 15d3536
Minor fixes
TastelessVoid 3fdf3e7
Update src/mobile.rs
TastelessVoid 7bd435d
Update android/src/main/java/app/tauri/notification/NotificationPlugi…
TastelessVoid aa3db73
Update android/src/main/java/app/tauri/notification/TauriUnifiedPushM…
TastelessVoid c9710f3
Update android/src/main/java/app/tauri/notification/TauriUnifiedPushM…
TastelessVoid 237ea4e
Added tests and locked UnifiedPush to Android
TastelessVoid 2753478
Added tests and locked UnifiedPush to Android
TastelessVoid 4044ab7
Merge remote-tracking branch 'origin/unified-push-support' into unifi…
TastelessVoid 21a1b0c
Fixed compiling errors
TastelessVoid 61a4d83
Do not import UnifiedPush unconditionally or the CI/Unit test fail
TastelessVoid 3d55514
Implement review suggestions
TastelessVoid b745963
Added UnifiedPush related terms to cspell.json
TastelessVoid 17ecb04
Implement review suggestions from Copilot
TastelessVoid cd69721
Add support for UnifiedPush temporary unavailability and VAPID key ha…
TastelessVoid 9c0c1e0
Added MessageStyling and other features that were TODO that I need fo…
TastelessVoid bcfe750
Added MessageStyling and other features that were TODO that I need fo…
TastelessVoid 59fe15c
Add support for avatar images and authentication in messaging style n…
TastelessVoid 150e5b6
Add avatar image downloading on a background thread and update notifi…
TastelessVoid e48ecc5
Fixed prettier issues
TastelessVoid ea3f3d8
Refactor unified push permission handling and improve avatar image do…
TastelessVoid daa413d
Adjust codestyle to follow prettier to make CI happy
TastelessVoid c77ca0e
Add logging for past scheduled notification time checks
TastelessVoid 90e5d49
Refactor avatar image downloading to prefetch avatars in parallel and…
TastelessVoid File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,6 @@ dependencyResolutionManagement { | |
| repositories { | ||
| mavenCentral() | ||
| google() | ||
|
|
||
| } | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
android/src/main/java/app/tauri/notification/JSObjectUtils.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| package app.tauri.notification | ||
|
|
||
| import app.tauri.plugin.JSArray | ||
| import app.tauri.plugin.JSObject | ||
| import org.json.JSONArray | ||
| import org.json.JSONObject | ||
|
|
||
| /** | ||
| * Shared helpers for recursively converting native Kotlin values (Maps, Lists, primitives) | ||
| * into [JSObject] / [JSArray] structures understood by the Tauri plugin bridge. | ||
| * | ||
| * Both [NotificationPlugin] and [TauriUnifiedPushMessagingService] need to convert | ||
| * the push-data maps they receive into JS-bridge types; keeping the logic in one | ||
| * place prevents the two copies from drifting apart. | ||
| */ | ||
| internal object JSObjectUtils { | ||
|
|
||
| /** | ||
| * Recursively put [value] into [target] under [key]. | ||
| * Handles String, Int, Long, Double, Boolean, Map, and List types. | ||
| */ | ||
| fun putValueToJSObject(target: JSObject, key: String, value: Any) { | ||
| when (value) { | ||
| is String -> target.put(key, value) | ||
| is Int -> target.put(key, value) | ||
| is Long -> target.put(key, value) | ||
| is Double -> target.put(key, value) | ||
| is Boolean -> target.put(key, value) | ||
| is Map<*, *> -> { | ||
| val nestedObj = JSObject() | ||
| @Suppress("UNCHECKED_CAST") | ||
| val map = value as Map<String, Any> | ||
| for ((k, v) in map) { | ||
| putValueToJSObject(nestedObj, k, v) | ||
| } | ||
| target.put(key, nestedObj) | ||
| } | ||
| is List<*> -> target.put(key, convertListToJSArray(value)) | ||
| else -> target.put(key, value.toString()) | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Recursively convert a [List] into a [JSArray], handling nested maps, lists, and primitives. | ||
| */ | ||
| fun convertListToJSArray(list: List<*>): JSArray { | ||
| val arr = JSArray() | ||
| for (item in list) { | ||
| when (item) { | ||
| is String -> arr.put(item) | ||
| is Int -> arr.put(item) | ||
| is Long -> arr.put(item) | ||
| is Double -> arr.put(item) | ||
| is Boolean -> arr.put(item) | ||
| is Map<*, *> -> { | ||
| val nestedObj = JSObject() | ||
| @Suppress("UNCHECKED_CAST") | ||
| val map = item as Map<String, Any> | ||
| for ((k, v) in map) { | ||
| putValueToJSObject(nestedObj, k, v) | ||
| } | ||
| arr.put(nestedObj) | ||
| } | ||
| is List<*> -> arr.put(convertListToJSArray(item)) | ||
| null -> arr.put(JSONObject.NULL) | ||
| else -> arr.put(item.toString()) | ||
| } | ||
| } | ||
| return arr | ||
| } | ||
|
|
||
| /** | ||
| * Recursively convert a raw [JSONObject] value into a native Kotlin type | ||
| * (Map for objects, List for arrays, or the primitive itself). | ||
| */ | ||
| fun jsonValueToNative(value: Any): Any { | ||
| return when (value) { | ||
| is JSONObject -> { | ||
| val map = mutableMapOf<String, Any>() | ||
| for (key in value.keys()) { | ||
| map[key] = jsonValueToNative(value.get(key)) | ||
| } | ||
| map | ||
| } | ||
| is JSONArray -> { | ||
| val list = mutableListOf<Any>() | ||
| for (i in 0 until value.length()) { | ||
| list.add(jsonValueToNative(value.get(i))) | ||
| } | ||
| list | ||
| } | ||
| else -> value | ||
| } | ||
| } | ||
| } | ||
|
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.