urlynk_flutter 1.0.0
urlynk_flutter: ^1.0.0 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. Add JitPack to build.gradle
PATH: android > build.gradle.kts or android > settings.gradle.kts
In your project-level build.gradle.kts or settings.gradle.kts, add:
allprojects {
repositories {
google()
mavenCentral()
maven { url = uri("https://jitpack.io") } // Add this line
}
}
2. Update AndroidManifest.xml
PATH: android > app > src > main > AndroidManifest.xml
Add the following inside your .MainActivity <activity> tag to enable link capturing:
<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.
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(appId: 'YOUR_APP_ID', apiKey: 'YOUR_API_KEY');
2. Listen for deep link data #
urlynk.onLinkData.listen((data) {
log('Received link data: $data');
});
3. Create a deep link #
final deepLink = await urlynk.createDeepLink("your-data");
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 #
final shortLink = await urlynk.createShortLink("https://example.com/very-long-url");
Testing #
Android Testing #
- Run your app on an emulator or device.
- Create a deep link using the SDK.
- Execute the following command:
adb shell am start -a android.intent.action.VIEW -d "<created_deep_link>" <your.application.id>
- If successful, the app will launch and
onLinkDatawill receive the deep link data.
iOS Testing #
- Run the app on a simulator
- Create a deep link using the SDK
- Open the generated link in the simulator’s Safari browser
- Restart the app
onLinkDatashould receive the payload
NOTE: Created links won’t auto-launch the app in development. This only works when a app version is live on the App Store.