flux_dynamic_link 1.1.1
flux_dynamic_link: ^1.1.1 copied to clipboard
Flutter plugin for Flux Dynamic Link
Flux Dynamic Link Flutter Plugin
The Flux Dynamic Link Flutter plugin simplifies the management of deep links and dynamic links in your Flutter applications. With its seamless integration, the plugin provides robust functionality to handle incoming deep links, generate dynamic links, and create shortened URLs for sharing.
Key Features: #
- Deep Link Handling: Easily capture and process incoming deep links to navigate users to specific app screens.
- Dynamic Link Creation: Generate dynamic links for flexible content sharing across platforms.
- Shortened URL Generation: Create compact and shareable URLs for marketing campaigns and improved user experience.
- Custom Parameters: Add custom data to your links to provide personalized experiences for your users.
- Cross-Platform Support: Works on both iOS and Android with minimal setup.
Use Cases: #
- Share app-specific content with dynamic or shortened links.
- Deeply integrate external referrals or promotions into your app.
- Simplify link generation for social media campaigns or email marketing.
This plugin is designed to streamline link management in Flutter apps, making it an essential tool for developers aiming to enhance user engagement and sharing functionality.
Installation and Initialization of Flux Dynamic Link Flutter Plugin #
Follow these steps to install and initialize the Flux Dynamic Link plugin for Flutter:
Step 1: Create the project #
Create your project at FluxBuilder app (download https://fluxbuilder.com/download). Note your project Id, Project prefix and Project Key generated. Save the project key securely for later use.
Step 2: Install the plugin #
- Add the following line to your
pubspec.yaml
file:dependencies: flux_dynamic_link: latest
- Run
flutter pub get
to install the plugin.
Step 3: Configure Platforms #
For Android:
- Update the AndroidManifest.xml file to handle deep links:
<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:scheme="fluxlink-{projectId}" android:host="deeplink.fluxbuilder.com" /> </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:scheme="https" android:host="deeplink.fluxbuilder.com" /> </intent-filter>
- Add Assets Link to your project in Admin Panel, see how to generate here
For iOS:
- Open the
ios/Runner/Info.plist
file and add:<key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleURLName</key> <string>{bundleId}</string> <key>CFBundleURLSchemes</key> <array> <string>fluxlink-{projectId}</string> </array> </dict> </array> <key>NSUserActivityTypes</key> <array> <string>NSUserActivityTypeBrowsingWeb</string> </array> <key>LSApplicationQueriesSchemes</key> <array> <string>fluxlink-{projectId}</string> </array> <key>CFBundleAssociatedDomains</key> <array> <string>applinks:deeplink.fluxbuilder.com</string> </array> <key>FlutterDeepLinkingEnabled</key> <false/>
- Add ios apple association site to your project in Admin Panel, see how to generate here
Step 3: Initialize the Plugin #
In your main.dart
file, initialize the Flux Dynamic Link plugin in the main
function:
import 'package:flux_dynamic_link/flux_dynamic_link.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// Initialize Flux Dynamic Link
await FluxDynamicLink.initialize(
projectId: '{projectId}',
publicKey: '{publicKey}',
);
runApp(MyApp());
}
Features of the Flux Dynamic Link Flutter Plugin #
1. Handle Incoming Deep Links
Automatically capture and handle deep links to navigate users to specific screens within the app.
- Example:
FluxDynamicLink.instance.dynamicLinkStream.listen((String? url) { if (url != null) { print("Received deep link: $url"); // Navigate based on the path or parameters in the URI } });
2. Generate Dynamic Links
Create flexible dynamic links with optional custom parameters to direct users to specific app content.
- Example:
final linkDetails = await FluxDynamicLink.instance.createShortenedLink( CreateFluxDynamicLinkForm( slug: "product-123", iosDeeplink: "fluxstore://product/123", androidDeeplink: "fluxstore://product/123", androidPackage: "com.inspireui.fluxstore", appstoreUrl: "https://apps.apple.com/app/id1234567890", playstoreUrl: "https://play.google.com/store/apps/details?id=com.inspireui.fluxstore", webFallbackUrl: "https://fluxstore.app/product/123", metadata: LinkMetadata( title: "FluxStore Product 123", description: "Check out this amazing product from FluxStore", image: "https://fluxstore.app/images/product-123.jpg", ), expiresAt: DateTime.now().add(Duration(days: 30)), ), ); // Get the full shortened URL final fluxLink = FluxDynamicLink.instance.getFullUrl(linkDetails); print("FluxLink Link: $fluxLink"); print("Link ID: ${linkDetails.id}"); print("Status: ${linkDetails.status}");
3. Custom Domain Setup (Optional)
FluxStore supports custom domains so your customers can use their own branded domains (e.g., links.customer.com
) instead of the default FluxStore domain.
For App Developers (Your Customers):
-
Configure Custom Domain in App:
await FluxDynamicLink.initialize( publicKey: 'your-api-key', projectId: 'your-project-id', customDomain: 'links.yourdomain.com', // Your custom domain );
-
Update Mobile App Configuration:
Android (AndroidManifest.xml):
<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" /> <!-- Use your custom domain --> <data android:scheme="https" android:host="links.yourdomain.com" /> </intent-filter>
iOS (Info.plist):
<key>CFBundleAssociatedDomains</key> <array> <!-- Use your custom domain --> <string>applinks:links.yourdomain.com</string> </array>
-
DNS Setup: Add a CNAME record pointing to FluxStore's service:
links.yourdomain.com CNAME deeplink.fluxbuilder.com
-
Request Domain Activation: Contact FluxStore support to activate your custom domain, or use the automated API (see below).
Automated Subdomain Setup API:
FluxStore provides an API to automatically configure custom subdomains (no Enterprise plan required):
# Add custom subdomain via API
curl -X POST "https://deeplink.fluxbuilder.com/api/subdomains" \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
--data '{
"subdomain": "mystore",
"tenant_name": "My Store"
}'
This creates: mystore.deeplink.fluxbuilder.com
Alternative: Custom Domain via CNAME (Simple)
For full custom domains, customers can use CNAME without Enterprise features:
# Customer's DNS setup
links.customer.com CNAME deeplink.fluxbuilder.com
Then configure the custom domain in the app:
await FluxDynamicLink.initialize(
publicKey: 'your-api-key',
projectId: 'your-project-id',
customDomain: 'links.customer.com',
);
Response:
{
"success": true,
"domain": {
"hostname": "links.yourdomain.com",
"status": "pending_validation",
"ssl_status": "pending",
"verification_record": {
"type": "TXT",
"name": "_cf-custom-hostname.links.yourdomain.com",
"value": "abc123def456..."
}
}
}
Domain Verification:
- Add the TXT record to your DNS
- Check verification status:
curl "https://deeplink.fluxbuilder.com/api/domains/links.yourdomain.com" \ -H "Authorization: Bearer your-api-key"
Testing Custom Hostnames (Direct Cloudflare API):
Test if your Cloudflare setup is working:
# Test with API Token
curl -X POST "https://api.cloudflare.com/client/v4/zones/YOUR_ZONE_ID/custom_hostnames" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
--data '{
"hostname": "test.yourdomain.com",
"ssl": {"method": "http", "type": "dv"}
}'
# Test with Global API Key (alternative)
curl -X POST "https://api.cloudflare.com/client/v4/zones/YOUR_ZONE_ID/custom_hostnames" \
-H "X-Auth-Email: your-email@domain.com" \
-H "X-Auth-Key: YOUR_GLOBAL_API_KEY" \
-H "Content-Type: application/json" \
--data '{
"hostname": "test.yourdomain.com",
"ssl": {"method": "http", "type": "dv"}
}'
4. How to test
- Test the Play Store Install Referrer API: Follow the steps in the medium article to test the Play Store Install Referrer API.
Use Cases #
- Deep Linking: Navigate to app screens based on incoming links.
- Content Sharing: Easily share content with dynamic or shortened URLs.
- Custom Campaigns: Track campaigns using custom parameters in links.
This setup ensures your app is fully equipped to handle deep and dyna links, improving user engagement and marketing outreach.