This repository was archived by the owner on Feb 27, 2025. It is now read-only.
feat: Integrate Airbridge SDK and migrate from Firebase Dynamic Links#4
Open
feat: Integrate Airbridge SDK and migrate from Firebase Dynamic Links#4
Conversation
dsa28s
commented
Oct 24, 2024
Comment on lines
+14
to
+66
| class DeeplinkHandler(private val navController: NavController?) { | ||
|
|
||
| fun handleDeeplink(intent: Intent) { | ||
| Airbridge.handleDeeplink(intent) { uri -> | ||
| handleDeeplinkUri(uri) | ||
| } | ||
| } | ||
|
|
||
| fun handleDeferredDeeplink() { | ||
| Airbridge.handleDeferredDeeplink { uri -> | ||
| uri?.let { handleDeeplinkUri(it) } | ||
| } | ||
| } | ||
|
|
||
| private fun handleDeeplinkUri(uri: Uri) { | ||
| val path = uri.path ?: return | ||
|
|
||
| when { | ||
| path.startsWith("/recipe/") -> { | ||
| val recipePattern = "/recipe/(\\d+)".toRegex() | ||
| val matchResult = recipePattern.find(path) | ||
| matchResult?.let { result -> | ||
| val recipeId = result.groupValues[1] | ||
| navController?.navigateToRecipeScreen(recipeId) | ||
| } | ||
| } | ||
|
|
||
| path.startsWith("/detail/") -> { | ||
| val detailPattern = "/detail/([\\w-]+)".toRegex() | ||
| val matchResult = detailPattern.find(path) | ||
| matchResult?.let { result -> | ||
| val detailId = result.groupValues[1] | ||
| navController?.navigateToDetailScreen(detailId) | ||
| } | ||
| } | ||
|
|
||
| path == "/explore" -> { | ||
| navController?.navigateToExploreTab() | ||
| } | ||
|
|
||
| path == "/collection" -> { | ||
| navController?.navigateToCollectionTab() | ||
| } | ||
|
|
||
| path == "/signin" -> { | ||
| navController?.navigateToSignInScreen() | ||
| } | ||
|
|
||
| else -> { | ||
| Timber.tag("[DeeplinkHandler]").w("Unhandled deep link path: $path") | ||
| } | ||
| } | ||
| } |
Author
There was a problem hiding this comment.
This new DeeplinkHandler class encapsulates all deeplink handling logic, supporting both immediate and deferred deeplinks. The regex patterns for path matching are crucial for correctly parsing recipe IDs and detail IDs from the deeplink URLs. The handler uses a NavController to perform the actual navigation, making it a critical component for the app's navigation flow.
dsa28s
commented
Oct 24, 2024
Comment on lines
39
to
50
| <intent-filter> | ||
| <action android:name="android.intent.action.VIEW" /> | ||
|
|
||
| <category android:name="android.intent.category.DEFAULT" /> | ||
| <category android:name="android.intent.category.BROWSABLE" /> | ||
|
|
||
| <data | ||
| android:host="duckee.page.link" | ||
| android:scheme="https" /> | ||
| <data android:scheme="duckee" /> | ||
| </intent-filter> | ||
| <intent-filter android:autoVerify="true"> | ||
| <action android:name="android.intent.action.VIEW" /> | ||
| <category android:name="android.intent.category.DEFAULT" /> | ||
| <category android:name="android.intent.category.BROWSABLE" /> | ||
| <data android:host="duckee.airbridge.io" android:scheme="https" /> | ||
| </intent-filter> |
Author
There was a problem hiding this comment.
Added intent filters for both Airbridge scheme deeplinks (duckee://) and app links (https://duckee.airbridge.io). The android:autoVerify="true" attribute is crucial for App Links verification on Android 6.0 and above. Make sure to verify the domain ownership through Digital Asset Links.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Airbridge SDK Integration
This PR integrates Airbridge SDK and migrates deeplink handling from Firebase Dynamic Links to Airbridge Deeplinks.
Changes
Deeplink Format Changes
The deeplink format has changed from Firebase to Airbridge:
https://duckee.page.link/xxxxduckee://pathhttps://duckee.airbridge.io/pathSupported Deeplink Paths
/recipe/{id}- Opens recipe screen/detail/{id}- Opens detail screen/explore- Opens explore tab/collection- Opens collection tab/signin- Opens sign in screenTesting Instructions
duckee://recipe/123https://duckee.airbridge.io/recipe/123Note
Please update all marketing materials and documentation to use the new Airbridge deeplink format.