Repository navigation
fix(unity): register the Android OAuth callback at build time - #2089
Merged
Merged
Conversation
The package shipped Plugins/Android/AndroidManifest.xml with the literal scheme appwrite-callback-<YOUR_PROJECT_ID>. A package installed from a git URL is read-only, so the scheme could never be filled in and OAuth on Android never returned to the app; the manifest also redeclared the launcher activity, competing with the project's own main manifest. An Editor IPostGenerateGradleAndroidProject processor now adds the intent filter to the Unity activity of the generated Gradle project, using the project ID of each AppwriteConfig asset, which works with Unity's manifest merging and needs no edits to package files. The README documents the custom main manifest route for clients created in code. The setup window's Documentation button opened sdk.url (the generator's homepage URL) and its Discord button a fixed invite; they now open the SDK README and sdk.discordUrl.
🟢 Tier S · Ready to mergeThis change replaces the packaged Android manifest with a generated Unity Editor build processor that adds OAuth callback schemes from configuration assets, and documents the custom-manifest option for code-created clients. It also updates the setup window’s documentation and Discord links and adds Unity generation tests.
📂 Walkthrough · 6
🔇 Filtered out · 1Findings Hansi considered but did not post.
Reviewed |
3 tasks
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this PR do?
The Unity package shipped
Runtime/Core/Plugins/Android/AndroidManifest.xmlwith the literal schemeappwrite-callback-<YOUR_PROJECT_ID>. A package installed from a git URL is read-only, so the placeholder could never be filled in and OAuth on Android never returned to the app. The manifest also redeclaredUnityPlayerActivitywith the launcher intent filter, which competes with the project's own main manifest (and with the GameActivity entry point on Unity 2023+).This PR removes that manifest and adds an Editor build processor (
AppwriteAndroidManifestProcessor, anIPostGenerateGradleAndroidProject). When an Android Gradle project is generated, it reads theprojectIdof everyAppwriteConfigasset and appends aVIEW/DEFAULT/BROWSABLEintent filter forappwrite-callback-<projectId>to the Unity activity inunityLibrary/src/main/AndroidManifest.xml(found by itsunityplayer.UnityActivitymeta-data or launcher category), skipping schemes that are already declared. I picked this over a package manifest with placeholders because it needs no edits to package files, it uses Unity's own merged manifest instead of competing with it, the API is available from Unity 2021.3 through Unity 6, and it does not need the Android module unless the build target is Android (the file is guarded byUNITY_ANDROID). The config is read throughSerializedObject, so the Editor assembly takes no compile-time dependency on the runtime assembly, matching how the setup window already calls into it.When no config with a project ID exists (clients created in code), the processor logs how to add the filter, and the README gains an "OAuth on Android" section describing the custom main manifest route.
The Unity setup window's Documentation button opened
sdk.url(the generator's homepage URL,https://example.comin generated examples) and the Discord button a hardcoded invite. Documentation now opens the SDK README on GitHub (appwrite.io has no Unity quick start;/docs/quick-starts/unityfalls back to the overview page), and Discord usessdk.discordUrl, hidden when unset.Client.Fromdefaulting to{{ spec | endpoint }}is unchanged: every client SDK (Web, Node, React Native, Dart, Flutter, Swift, Apple, Kotlin, Android, .NET, Go, Python, Ruby, PHP, Rust) defaults its endpoint to the same spec server URL.Test Plan
GenerationTestcases: the Unity tree contains noAndroidManifest.xml, no non-docs file carries a<YOUR_PROJECT_ID>placeholder, the build processor registers the sameappwrite-callback-prefix thatWebAuthComponentwaits for, and the setup window opens the README and no fixed Discord invite. Both fail onmainand pass here.vendor/bin/phpunit --testsuite Generation: 112 tests pass.UNITY_ANDROIDdefined against Unity 6000.4'sUnityEditor.CoreModule/UnityEngine.CoreModule, and ran its XML transform on a sample Unity library manifest: the intent filter lands onUnityPlayerActivitywith theandroid:prefix.php example.php unity clientthendotnet format whitespace --folder --verify-no-changesinexamples/unity,composer lint-twig,composer refactor:check,composer lint, and the 1200-character Twig line check all pass.Related PRs and Issues
None.
Closes #2092