avioli / uni_links

Flutter plugin for accepting incoming links.
BSD 2-Clause "Simplified" License
563 stars 303 forks source link

Facing issue Deep Link working fine but issue is #123

Open marslannasr7koncepts opened 3 years ago

marslannasr7koncepts commented 3 years ago

I am using Link on Home Page where I am calling a function in initState and it working fine issue is when I move to new Page and back to page again where deep function call it call again to move to Deep link page again I want to control this and want to know how i can manage this.

Code that I am using is.

@override void initState() { super.initState(); initUniLinks(); }

Future initUniLinks() async { // Platform messages may fail, so we use a try/catch PlatformException. try { String? initialLink = await getInitialLink();

  //String aapLink = "https://beta.bopnhop.com?event=34&status=1";

  if (initialLink != null) {
    print('Link is:' + initialLink);

    //Uri uri = Uri.dataFromString(initialLink);
    print(Uri.parse(initialLink).queryParameters['']);

    String? status = Uri.parse(initialLink).queryParameters['status'];
    String? id = Uri.parse(initialLink).queryParameters['id'];

    if (status == "1") {
      print('status is: ${status}');
      print('id is: ${id}');

      Navigator.push(
        context,
        MaterialPageRoute(
          builder: (context) => PostHomeCommentsDetailScreen(
            articleId: int.parse(id!),
          ),
        ),
      );
    }
  }
} on PlatformException {
  // Handle exception by warning the user their action did not succeed
  print('Deep Link issue!');
}

}