-
Notifications
You must be signed in to change notification settings - Fork 0
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: Integrate Airbridge SDK and migrate from Firebase Dynamic Links #4
base: main
Are you sure you want to change the base?
Conversation
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") | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
<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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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/xxxx
duckee://path
https://duckee.airbridge.io/path
Supported 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/123
https://duckee.airbridge.io/recipe/123
Note
Please update all marketing materials and documentation to use the new Airbridge deeplink format.