Dynamic Hyperlinks :
Flutter dynamic hyperlinks, now we have already seen the implementation of dynamic hyperlinks in our earlier tutorial and on this a part of the tutorial we might be coping with referral system implementation.
Referral system is a very powerful a part of the favored e-commerce apps and we might be seeing how we will design this in our flutter app.
On this tutorial we try to ship few parameters included by a hyperlink so right here is the hyperlink which i’ve created https://onesignalpush.web page.hyperlink/amplifyabhii
Â
Dynamic Hyperlinks Video Tutorial :
On this a part of the tutorial i might be offering the detailed implementation and rationalization by this tutorial.
Â
pubspec.yaml :
Add firebase core and firebase dynamic hyperlinks to your venture and replace to the most recent model.
flutter:
sdk: flutter
firebase_core: ^2.22.0
firebase_dynamic_links: ^5.4.4
Â
fundamental.dart :
I’ve supplied the entire code for the referral system implementation.
import ‘bundle:flutter/materials.dart’;
import ‘bundle:firebase_core/firebase_core.dart’;
import ‘bundle:firebase_dynamic_links/firebase_dynamic_links.dart’;
void fundamental() async{
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
var initialLink = await FirebaseDynamicLinks.occasion.getInitialLink();
handleLink(initialLink);
FirebaseDynamicLinks.occasion.onLink.hear((occasion) async {
handleLink(occasion);
});
runApp(MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({tremendous.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget construct(BuildContext context) {
return MaterialApp(
house: Scaffold(
appBar: AppBar(title: Textual content(“Firebase Referral”),),
physique: Middle(
baby: Column(
mainAxisAlignment: MainAxisAlignment.heart,
kids: [
Text(“Welcome”, style: TextStyle(fontSize: 20),),
Text(“”)
],
),
),
),
);
}
}
void handleLink(PendingDynamicLinkData? information){
if(information != null){
Uri? uri = information.hyperlink;
print(information);
print(uri);
if(uri != null){
Map<String, String>? utmParameters = information.utmParameters?.forged<String, String>();
print(“UTM Supply :${utmParameters?[“utm_source”]}”);
print(“UTM Medium :${utmParameters?[“utm_medium”]}”);
print(“UTM Marketing campaign :${utmParameters?[“utm_campaign”]}”);
}
}
}
Â
Â
Extra :
Additionally undergo the detailed playlist tutorial.
Â
Â