urlynk_flutter 1.3.1
urlynk_flutter: ^1.3.1 copied to clipboard
A Flutter plugin that provides complete solution for deferred deep linking and URL shortening.
urlynk_flutter #
URLynk (formerly DeepLynks) is a Flutter plugin that provides a complete solution for deep linking and URL shortening. It supports deferred deep linking—opening the app directly if installed, or redirecting users to the appropriate app store if not, while preserving the original link context across installation.
Features #
- Quick Integration: Minimal setup required to get started.
- Platform Support: Supports Android App Links and iOS Universal Links.
- Branded Domain: Use your own branded domain to enhance visibility and user trust.
- Deferred Linking: Seamlessly redirect users to the store for downloads and preserve link even after installation.
- Free Tier: Generous free tier that covers most developers’ needs, including all essential features for deep linking.
Getting Started #
- Visit URLynk
- Create a free account
- Register your app and receive unique App ID
- Generate an API Key
Installation #
Add this plugin to your pubspec.yaml
:
flutter pub add urlynk_flutter
Platform Setup #
Android #
Requirements: minSdk >= 21
1. Update AndroidManifest.xml
PATH: android > app > src > main > AndroidManifest.xml
Add Internet permission
<uses-permission android:name="android.permission.INTERNET"/>
Add the following inside your .MainActivity
<activity>
tag.
<activity android:name=".MainActivity">
<!-- Add the following lines below: START -->
<meta-data android:name="flutter_deeplinking_enabled" android:value="true" />
<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:scheme="http" android:host="urlynk.in" android:pathPrefix="/<app_id>/" />
<data android:scheme="https" android:host="urlynk.in" android:pathPrefix="/<app_id>/" />
<!-- Optional branded domain support -->
<!-- <data android:scheme="https" android:host="your.domain.com" android:pathPrefix="/<app_id>/" /> -->
</intent-filter>
<!-- END -->
</activity>
Note: app_id
refers to the App ID generated in your URLynk account. It is not your Android applicationId
.
Cleanup (Optional)
You no longer need to add JitPack, as URLynk is now available on Maven Central. If you are upgrading from version 1.0.0, remove JitPack from
build.gradle
(if it was only added for URLynk): PATH:android > build.gradle.kts
orandroid > settings.gradle.kts
maven { url = uri("https://jitpack.io") } // Remove this
iOS #
Requirements: iOS >= 12.0
and Swift >= 5.0
1. Allow static pods in your Podfile
PATH: ios > Podfile
target 'Runner' do
use_frameworks! :linkage => :static # Update this line
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
2. Update AppDelegate.swift
PATH: ios > Runner > AppDelegate.swift
import Flutter
import UIKit
import URLynk // Add this line
@main
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
// Add the following method below.
override func application(
_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void
) -> Bool {
if userActivity.activityType == NSUserActivityTypeBrowsingWeb, let url = userActivity.webpageURL {
try? URLynk.shared.handleDeepLink(url: url)
}
return true
}
}
3. Add Associated Domains Capability
- Open the
Runner.xcworkspace
in Xcode. - Select the top-level
Runner
project in the Navigator. - Go to the Signing & Capabilities tab.
- Click the + Capability button.
- Select Associated Domains.
- In the Associated Domains section, click the + button.
- Add this domain:
applinks:urlynk.in
- (Optional) If you're using a branded domain, be sure to add it as well:
applinks:your.branded.domain
Usage #
1. Configure URLynk Service #
This method must be called before using any other methods.
final urlynk = UrlynkFlutter();
await urlynk.configure(appId: 'YOUR_APP_ID', apiKey: 'YOUR_API_KEY');
2. Listen for deep link data #
urlynk.onLinkData.listen((res) {
if (res.error != null) {
log('Received Data Error: ${res.error}');
} else {
log('Received Data: [${res.link}] ${res.data}');
}
});
NOTE: Deep link handling is only supported on Android and iOS.
On Web, macOS, Windows, and Linux, theonLinkData
will have no effect.
3. Create a deep link #
try {
final deepLink = await urlynk.createDeepLink("any data in string format");
if (deepLink != null) log('Deep link created: $deepLink');
} on PlatformException catch (e) {
log(e.message ?? '');
}
You can use any stringified data—such as absolute URLs, relative paths, query parameters, or JSON objects — to generate a deep link and retrieve this data when the link is opened.
4. Create short link for a long URL #
Note: Short links are for URL shortening only. They do not open the app, redirect to app stores, or capture clicks on app launch like deep links do.
try {
final shortLink = await urlynk.createShortLink(
LinkModel(url: 'https://www.google.com/search?q=urlynk'),
);
if (shortLink != null) log('Short link created: $shortLink');
} on PlatformException catch (e) {
log(e.message ?? '');
}
5. Dispose the resources #
urlynk.dispose();
Android Testing #
Android Deep Link Testing #
- Run the app on an emulator or physical device.
- Generate a deep link from the app.
- Execute the following command in your terminal while the app is running:
adb shell am start -a android.intent.action.VIEW -d "GENERATED_DEEP_LINK" YOUR_APPLICATION_ID_[NOT_APP_ID]
If successful:
- The app should launch (if it was in the background).
onLinkData
should receive the payload within a few seconds (depending on network stability).
Android Deferred Link Testing #
- Run the app on a physical device (not reliable on emulator).
- Generate a deep link from the app.
- Open the generated link in the device’s browser while the app is running.
- Ignore the redirect - in production, app will launch if installed, else users will be redirected to the Play Store; in development, this won’t work.
- Restart the app —
onLinkData
should receive the payload within a few seconds (depending on network stability).
NOTE: For direct app opening from browser, the app must be published on the Play Store or installed via a Play Store testing track.
Play Store Testing #
- Publish a test build to the Play Console testing track like Internal Testing.
- Add App Signing key certificate (SHA-256 fingerprint) in the URLynk app settings.
Path: Play Console → Test and release → App Integrity → Play app signing → Settings → App Signing key certificate → SHA-256 fingerprint
- Wait at least 5 minutes to allow the Digital Asset Links JSON to propagate.
- Verify deep link setup in Play Console:
Grow users → Deep links
You should see the status All links working and yourintent-filter
data listed under App configuration web links. - Share and accept the tester opt-in link on the device/account you plan to test with.
- Uninstall any existing build of the app from this device.
- Open a generated deep link in the browser - it should redirect to your Play Store listing for the test build.
- Install the test build from the Play Store.
- Open the app after installation -
onLinkData
should receive the payload attached to the original link within a few seconds (depending on network stability). - Copy your deep link into a text editor on your device, then tap it directly. This should open the app directly.
NOTE: When testing from the Play Store’s testing track, deep links may sometimes redirect to the Play Store page instead of opening the installed app.
Use text editor method (step 10) for development.
(Rest assured, once your app is live, links will also open directly from the browser.)
iOS Testing #
NOTE: During development, deep links will not open the app directly. Direct open only works once the app has a live version on the App Store (not just TestFlight) — even if that live version is not configured for universal links (deep links).
- Run the app on a simulator or physical device.
- Generate a deep link from the app.
- Open the generated link in the device’s browser while the app is running.
- Ignore the redirect - in production, app will launch if installed, else user will be redirected to the App Store; in development, this won’t work.
- Restart the app —
onLinkData
should receive the payload within a few seconds (depending on network stability).
Important #
After publishing your app to the Stores, update the App Signing key certificate (SHA-256 key), Team ID, and App Store URL in the URLynk app settings.
This is essential for enabling direct app openings and proper store redirection via deep links.