Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dsa28s
Copy link

@dsa28s dsa28s commented Oct 24, 2024

Airbridge SDK Integration

This PR integrates Airbridge SDK and migrates deeplink handling from Firebase Dynamic Links to Airbridge Deeplinks.

Changes

  • Added Airbridge SDK dependency and repository
  • Initialized Airbridge SDK in DuckeeApplication
  • Created DeeplinkHandler class for handling Airbridge deeplinks
  • Updated MainActivity to use DeeplinkHandler
  • Removed Firebase Dynamic Links dependency
  • Updated AndroidManifest.xml with Airbridge intent filters

Deeplink Format Changes

The deeplink format has changed from Firebase to Airbridge:

  • Old: https://duckee.page.link/xxxx
  • New:
    • Scheme URL: duckee://path
    • Web URL: 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 screen

Testing Instructions

  1. Build and run the app
  2. Test both scheme URLs and web URLs:
    • duckee://recipe/123
    • https://duckee.airbridge.io/recipe/123

Note

Please update all marketing materials and documentation to use the new Airbridge deeplink format.

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")
}
}
}
Copy link
Author

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.

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>
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant