Install Airbridge SDK and Migrate from Firebase Dynamic Links#3
Install Airbridge SDK and Migrate from Firebase Dynamic Links#3
Conversation
| <!-- Airbridge deeplinks --> | ||
| <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.abr.ge" | ||
| android:scheme="https" /> | ||
| </intent-filter> | ||
| <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:host="duckee.airbridge.io" | ||
| android:scheme="https" /> | ||
| </intent-filter> | ||
| <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:scheme="duckee" /> | ||
| </intent-filter> |
There was a problem hiding this comment.
Updated the AndroidManifest.xml to include Airbridge deeplink schemes and hosts. This configuration is crucial for the app to intercept and handle Airbridge deeplinks correctly. Without these intent filters, the app won't be able to respond to Airbridge deeplinks.
| private fun handleAirbridgeDeeplink() { | ||
| Airbridge.handleDeeplink(intent) { deeplink -> | ||
| handleDeeplink(deeplink) | ||
| } | ||
|
|
||
| Airbridge.handleDeferredDeeplink { deeplink -> | ||
| deeplink?.let { handleDeeplink(it) } | ||
| } | ||
| } |
There was a problem hiding this comment.
Implemented Airbridge deeplink handling logic. This code is called when the app is launched or resumed via a deeplink, and navigates the user to the appropriate screen. The navigation controller is used to move to the screen corresponding to the deeplink URL.
| private fun handleDeeplink(deeplink: Uri) { | ||
| val path = deeplink.path ?: return | ||
| when { | ||
| path.startsWith("/recipe/") -> { | ||
| val recipePattern = "/recipe/(\\d+)".toRegex() | ||
| val matchResult = recipePattern.find(path) | ||
| matchResult?.let { result -> | ||
| val recipeId = result.groupValues[1] | ||
| navigationController?.navigateToRecipeScreen(recipeId) | ||
| } | ||
| } | ||
|
|
||
| path.startsWith("/detail/") -> { | ||
| val detailPattern = "/detail/([\\w-]+)".toRegex() | ||
| val matchResult = detailPattern.find(path) | ||
| matchResult?.let { result -> | ||
| val detailId = result.groupValues[1] | ||
| navigationController?.navigateToDetailScreen(detailId) | ||
| } | ||
| } | ||
| .addOnFailureListener(this) { e -> | ||
| Timber.tag("[DuckeeMainActivity]").w(e, "getDynamicLink:onFailure") | ||
|
|
||
| path == "/explore" -> { | ||
| navigationController?.navigateToExploreTab() | ||
| } | ||
|
|
||
| path == "/collection" -> { | ||
| navigationController?.navigateToCollectionTab() | ||
| } | ||
|
|
||
| path == "/signin" -> { | ||
| navigationController?.navigateToSignInScreen() | ||
| } | ||
|
|
||
| else -> { | ||
| Timber.tag("[DuckeeMainActivity]").w("Unhandled deep link path: $path") | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Refactored the deeplink handling logic to support both Airbridge deeplinks and deferred deeplinks. This change ensures that the app can handle various types of deeplinks, including those that might be triggered after the app is installed.
Install Airbridge SDK and Migrate from Firebase Dynamic Links
This PR installs the Airbridge SDK and migrates the app from using Firebase Dynamic Links to Airbridge Deeplinks.
Changes
DuckeeApplicationMainActivityAndroidManifest.xmlto support Airbridge DeeplinksImportant Notes
https://duckee.page.link/...duckee://...duckee://recipe/123duckee://detail/abc-def-ghiduckee://exploreduckee://collectionduckee://signinAction Required
Testing
Please test the following scenarios:
If you encounter any issues or have any questions, please don't hesitate to comment on this PR.