urlynk_flutter 1.1.1
urlynk_flutter: ^1.1.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 your App ID
- Generate your 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_idrefers to the App ID generated in your URLynk account. It is not your AndroidapplicationId.
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.ktsorandroid > settings.gradle.ktsmaven { 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.xcworkspacefile in Xcode. - Select the top-level
Runnerproject 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 #
NOTE: This method must be called before using any other methods.
final urlynk = UrlynkFlutter();
await urlynk.configure(apiKey: 'YOUR_API_KEY');
2. Listen for deep link data #
urlynk.onLinkData.listen((data) {
if (res.error != null) {
log('Received Data Error: ${res.error}');
} else {
log('Received Data: [${res.link}] ${res.data}');
}
});
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 ?? '');
}
NOTE: 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.cn/search?q=urlynk'),
);
if (shortLink != null) log('Short link created: $shortLink');
} on PlatformException catch (e) {
log(e.message ?? '');
}
5. Dispose the plugin 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 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 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 - Wait at least 5 minutes to allow the Digital Asset Links JSON to propagate.
- Verify deep link setup in Play Console:
Play Console → Grow users → Deep linksYou should see the status All links working and yourintent-filterdata listed under App configuration web links. - Share and accept the tester opt-in link on the device/account you plan to test with.
- Ensure app is not installed in 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 -
onLinkDatashould 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 your app directly. Direct open is only possible when the app is live on the App Store (not just in Testflight).
- 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 users 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) and display it according to your setup (toast or UI output).
Important #
After publishing your app to the Stores, update the App Signing key certificate (SHA-256 key), Team ID, App Store URL in your URLynk app settings. This is essential for enabling direct app openings and proper store redirecting via deep links.