{"id":15136616,"url":"https://github.com/appwrite/dynamic-links","last_synced_at":"2025-06-27T05:33:45.419Z","repository":{"id":181266808,"uuid":"666422718","full_name":"appwrite/dynamic-links","owner":"appwrite","description":"Implement Dynamic Links with Appwrite Functions!","archived":false,"fork":false,"pushed_at":"2023-07-17T08:49:42.000Z","size":41,"stargazers_count":99,"open_issues_count":2,"forks_count":13,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-06-22T01:12:18.755Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/appwrite.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-07-14T13:30:49.000Z","updated_at":"2025-06-10T09:59:40.000Z","dependencies_parsed_at":"2023-07-14T18:38:43.898Z","dependency_job_id":null,"html_url":"https://github.com/appwrite/dynamic-links","commit_stats":null,"previous_names":["appwrite/dynamic-links"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/appwrite/dynamic-links","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appwrite%2Fdynamic-links","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appwrite%2Fdynamic-links/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appwrite%2Fdynamic-links/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appwrite%2Fdynamic-links/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/appwrite","download_url":"https://codeload.github.com/appwrite/dynamic-links/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appwrite%2Fdynamic-links/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262198674,"owners_count":23273893,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-26T06:40:17.697Z","updated_at":"2025-06-27T05:33:45.397Z","avatar_url":"https://github.com/appwrite.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dynamic Link Handler\n\n![Join Discord](https://img.shields.io/discord/564160730845151244)\n\n## **Pre-release Notice**\n\nThis function dependent on Appwrite 1.4. Please note, as of the writing of this document, this version of Appwrite is not publicly available.\n\n## Overview\n\nDynamic links are links that redirect users to different locations based on their device, operating system, or other factors. For example, a link to a mobile app can redirect users to the Google Play Store or Apple App Store depending on their device. Dynamic links can also be used to redirect users to Deep Links - a specific page within a Mobile app, such as a user profile page.\n\n### Web\nhttps://github.com/appwrite/dynamic-links/assets/29069505/209bc34e-6a43-476c-b2f0-697bab2c54de\n\n### iOS\nhttps://github.com/appwrite/dynamic-links/assets/29069505/7cac33ad-acc0-406f-9dae-c1d0359dd356\n\n\n### Android\nhttps://github.com/appwrite/dynamic-links/assets/29069505/72af1583-9e8c-4798-bbd6-40706ab8d40e\n\n\n## Configuration\n\nThe service can be configured through the `CONFIG` environment variable in a JSON string format. Each object in the `CONFIG` array is expected to have a `path` and `targets`.\n\nTo illustrate, here are example settings for the `CONFIG` environment variable with respective use cases:\n\n### 1. Mobile vs. Desktop Redirection\n\n```json\n[\n  {\n    \"path\": \"/test\",\n    \"targets\": {\n      \"mobile\": \"https://m.example.com/test\",\n      \"desktop\": \"https://www.example.com/test\",\n      \"default\": \"https://www.example.com/test\"\n    }\n  }\n]\n```\nIn this example, requests to the `/test` path will redirect mobile users to `https://m.example.com/test`, while desktop users are redirected to `https://www.example.com/test`. Users with unrecognized or non-classified user-agents will be directed to the default URL `https://www.example.com/test`.\n\n### 2. Operating System-Specific Redirection\n\n```json\n[\n  {\n    \"path\": \"/app\",\n    \"targets\": {\n      \"android\": \"https://play.google.com/store/apps/details?id=com.example\",\n      \"ios\": \"https://apps.apple.com/app/example/id123456\",\n      \"default\": \"https://www.example.com/app\"\n    }\n  }\n]\n```\nIn this scenario, requests to the `/app` path will redirect Android users to the Google Play store and iOS users to the Apple App Store, while all other users are directed to the general application page.\n\n### 3. Deep Link Redirection with Fallback Option\n\n```json\n[\n  {\n    \"path\": \"/deeplink\",\n    \"targets\": {\n      \"android\": {\n        \"appName\": \"twitter\",\n        \"appPackage\": \"com.twitter.android\",\n        \"appPath\": \"user?screen_name=appwrite\",\n        \"fallback\": \"https://play.google.com/store/apps/details?id=com.twitter.android\"\n      },\n      \"ios\": {\n        \"appName\": \"twitter\",\n        \"appPath\": \"user?screen_name=appwrite\",\n        \"fallback\": \"https://apps.apple.com/us/app/twitter/id333903271\"\n      },\n      \"default\": \"https://twitter.com/appwrite\"\n    }\n  }\n]\n```\nIn this case, requests to the `/deeplink` path will redirect Android and iOS users to a specific part of an app, if installed. If the app is not installed (the deep link fails), they will be directed to their respective app stores. All other users will be redirected to a webpage containing similar information.\n\n## Setting Up Deep Links\n\n### Android\n\nFor Android, add the following to your `AndroidManifest.xml`:\n\n```xml\n\u003cactivity\n    android:name=\"com.example.MainActivity\"\n    android:label=\"@string/app_name\"\n    android:launchMode=\"singleTask\"\n    android:theme=\"@style/AppTheme.NoActionBar\"\u003e\n    \u003cintent-filter android:label=\"@string/app_name\"\u003e\n        \u003caction android:name=\"android.intent.action.VIEW\" /\u003e\n        \u003ccategory android:name=\"android.intent.category.DEFAULT\" /\u003e\n        \u003ccategory android:name=\"android.intent.category.BROWSABLE\" /\u003e\n\n        \u003c!-- Accepts URIs that begin with YOUR_SCHEME://YOUR_HOST --\u003e\n        \u003cdata\n            android:host=\"YOUR_HOST\"\n            android:scheme=\"YOUR_SCHEME\" /\u003e\n    \u003c/intent-filter\u003e\n\u003c/activity\u003e\n```\n\nAlso, add the following to your `MainActivity.java`:\n\n```java\n@Override\nprotected void onCreate(Bundle savedInstanceState) {\n    super.onCreate(savedInstanceState);\n    setContentView(R.layout.activity_main);\n\n    // Get the intent that started this activity\n    Intent intent = getIntent();\n    Uri data = intent.getData();\n\n    // Verify that the intent has the correct action and data\n    if (Intent.ACTION_VIEW.equals(intent.getAction()) \u0026\u0026 data != null) {\n        String path = data.getPath();\n        String query = data.getQuery();\n        String screenName = query.substring(query.indexOf(\"=\") + 1);\n        String url = \"https://twitter.com/\" + screenName;\n\n        // Redirect to the correct screen\n        Intent redirect = new Intent(Intent.ACTION_VIEW, Uri.parse(url));\n        startActivity(redirect);\n    }\n}\n```\n\nMore information on deep linking for Android can be found [on the Android Developers website](https://developer.android.com/training/app-links/deep-linking).\n\n### iOS\n\nFor iOS, add the following to your `Info.plist` file:\n\n```xml\n\u003carray\u003e\n    \u003cdict\u003e\n        \u003ckey\u003eCFBundleURLSchemes\u003c/key\u003e\n        \u003carray\u003e\n            \u003cstring\u003eYOUR_SCHEME\u003c/string\u003e\n        \u003c/array\u003e\n        \u003ckey\u003eCFBundleURLName\u003c/key\u003e\n        \u003cstring\u003eYOUR_HOST\u003c/string\u003e\n    \u003c/dict\u003e\n\u003c/array\u003e\n```\n\nAlso, in your `AppDelegate.swift` file, add the following to handle deep links:\n\n```swift\nfunc application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -\u003e Void) -\u003e Bool {\n    guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,\n        let url = userActivity.webpageURL,\n        let components = NSURLComponents(url: url, resolvingAgainstBaseURL: true) else {\n        return false\n    }\n\n    let path = components.path,\n    let query = components.query,\n    let screenName = query.substring(from: query.index(query.startIndex, offsetBy: query.index(of: \"=\")! + 1))\n    let url = \"https://twitter.com/\\(screenName)\"\n\n    // Redirect to the correct screen\n    if let url = URL(string: url) {\n        let svc = SFSafariViewController(url: url)\n        self.window?.rootViewController?.present(svc, animated: true, completion: nil)\n    }\n    return true\n}\n```\n\nFor further details on deep linking in iOS, refer to [Apple's official documentation](https://developer.apple.com/documentation/uikit/inter-process_communication/allowing_apps_and_websites_to_link_to_your_content).\n\n## License\n\nThis project is licensed under The MIT License (MIT). For more information, visit [http://www.opensource.org/licenses/mit-license.php](http://www.opensource.org/licenses/mit-license.php).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappwrite%2Fdynamic-links","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fappwrite%2Fdynamic-links","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappwrite%2Fdynamic-links/lists"}