Exemplo n.º 1
0
        public override Uri MapUri(Uri uri)
        {
            var url = uri.ToString();

            // If it's not a special case where we were launched from externally, just return the uri with no mapping changes
            if (!url.StartsWith(EXT_LAUNCH_URI))
                return uri;

            // Get the encodedLaunchUri Query parameter which is actually the url we are interested in
            var launchUrl = System.Net.HttpUtility.UrlDecode(url.Substring(url.IndexOf(EXT_LAUNCH_URI) + EXT_LAUNCH_URI.Length));

            // Build the AppLinkUrl from this url passed in
            var apUrl = new Rivets.AppLinkUrl(launchUrl);

            // See if the url fits some deep linking rules for our app
            if (apUrl.InputUrl.Scheme.StartsWith("example") && apUrl.InputUrl.Host.Contains("product"))
            {
                // Get the id parameter
                var id = string.Empty;
                if (apUrl.InputQueryParameters.ContainsKey("id"))
                    id = apUrl.InputQueryParameters["id"];

                // Finally, navigate to the product page (deep link)
                return new Uri("/Product.xaml?id=" + id, UriKind.Relative);
            }

            return uri;
        }
Exemplo n.º 2
0
        public override Uri MapUri(Uri uri)
        {
            var url = uri.ToString();

            // If it's not a special case where we were launched from externally, just return the uri with no mapping changes
            if (!url.StartsWith(EXT_LAUNCH_URI))
            {
                return(uri);
            }

            // Get the encodedLaunchUri Query parameter which is actually the url we are interested in
            var launchUrl = System.Net.HttpUtility.UrlDecode(url.Substring(url.IndexOf(EXT_LAUNCH_URI) + EXT_LAUNCH_URI.Length));

            // Build the AppLinkUrl from this url passed in
            var apUrl = new Rivets.AppLinkUrl(launchUrl);

            // See if the url fits some deep linking rules for our app
            if (apUrl.InputUrl.Scheme.StartsWith("example") && apUrl.InputUrl.Host.Contains("product"))
            {
                // Get the id parameter
                var id = string.Empty;
                if (apUrl.InputQueryParameters.ContainsKey("id"))
                {
                    id = apUrl.InputQueryParameters["id"];
                }

                // Finally, navigate to the product page (deep link)
                return(new Uri("/Product.xaml?id=" + id, UriKind.Relative));
            }

            return(uri);
        }
Exemplo n.º 3
0
        public override bool OpenUrl(UIApplication application, NSUrl url, string sourceApplication, NSObject annotation)
        {
            var rurl = new Rivets.AppLinkUrl(url.ToString());
            var id   = string.Empty;

            if (rurl.InputQueryParameters.ContainsKey("id"))
            {
                id = rurl.InputQueryParameters["id"];
            }

            if (rurl.InputUrl.Host.Equals("transactions") && !string.IsNullOrEmpty(id))
            {
                var transactionDetailViewController = GetViewController(MainStoryboard, "DashboardController") as DashboardViewController;
                transactionDetailViewController.SelectedTransactionId = Convert.ToInt32(id);
                var frontNavigationController = new UINavigationController(transactionDetailViewController);

                var rearViewController   = GetViewController(MainStoryboard, "MenuController") as MenuViewController;
                var mainRevealController = new SWRevealViewController();

                mainRevealController.RearViewController  = rearViewController;
                mainRevealController.FrontViewController = frontNavigationController;
                Window.RootViewController = mainRevealController;
                Window.MakeKeyAndVisible();

                return(true);
            }

            NavController.PopToRootViewController(true);
            return(true);
        }
Exemplo n.º 4
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.ProductLayout);

            var id = string.Empty;

            // See if the activity was opened from an internal Intent
            // which would have the product id in the Extras
            if (Intent.HasExtra("PRODUCT_ID"))
            {
                id = Intent.GetStringExtra("PRODUCT_ID");
            }
            else
            {
                var appLinkData = Intent.GetStringExtra("al_applink_data");

                // Otherwise, check and see if we were launched from an AppLink
                // and if so, Parse the url from the Intent Data
                var alUrl = new Rivets.AppLinkUrl(Intent.Data.ToString(), appLinkData);

                // InputQueryParameters will contain our product id
                if (alUrl != null && alUrl.InputQueryParameters.ContainsKey("id"))
                {
                    id = alUrl.InputQueryParameters ["id"];
                }
            }

            FindViewById <TextView> (Resource.Id.textViewProductId).Text = id;
        }
Exemplo n.º 5
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            SetContentView (Resource.Layout.ProductLayout);

            var id = string.Empty;

            // See if the activity was opened from an internal Intent
            // which would have the product id in the Extras
            if (Intent.HasExtra ("PRODUCT_ID")) {
                id = Intent.GetStringExtra ("PRODUCT_ID");
            } else {

                var appLinkData = Intent.GetStringExtra ("al_applink_data");

                // Otherwise, check and see if we were launched from an AppLink
                // and if so, Parse the url from the Intent Data
                var alUrl = new Rivets.AppLinkUrl (Intent.Data.ToString (), appLinkData);

                // InputQueryParameters will contain our product id
                if (alUrl != null && alUrl.InputQueryParameters.ContainsKey ("id")) {
                    id = alUrl.InputQueryParameters ["id"];
                }
            }

            FindViewById<TextView> (Resource.Id.textViewProductId).Text = id;
        }
Exemplo n.º 6
0
        static void ExtractAppLinkData(NSUrl url)
        {
            var result = new List <Data>();
            var rurl   = new Rivets.AppLinkUrl(url.ToString());

            if (rurl != null)
            {
                foreach (var param in rurl.InputQueryParameters)
                {
                    result.Add(new Data(param.Key, param.Value));
                }
            }

            OnAppLinkReceived?.Raise(result);
        }
Exemplo n.º 7
0
        public override bool OpenUrl(UIApplication app, NSUrl url, string sourceApp, NSObject annotation)
        {
            var rurl = new Rivets.AppLinkUrl (url.ToString ());

            var id = string.Empty;

            if (rurl.InputQueryParameters.ContainsKey("id"))
                id = rurl.InputQueryParameters ["id"];

            if (rurl.InputUrl.Host.Equals ("products") && !string.IsNullOrEmpty (id)) {
                var c = new ProductViewController (id);
                navController.PushViewController (c, true);
                return true;
            } else {
                navController.PopToRootViewController (true);
                return true;
            }
        }
Exemplo n.º 8
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            SetContentView (Resource.Layout.ProductLayout);

            var id = "No Product ID Found";

            if (Intent.HasExtra ("al_applink_data")) {

                var appLinkData = Intent.GetStringExtra ("al_applink_data");

                var alUrl = new Rivets.AppLinkUrl (Intent.Data.ToString (), appLinkData);

                // InputQueryParameters will contain our product id
                if (alUrl != null && alUrl.InputQueryParameters.ContainsKey ("id"))
                    id = alUrl.InputQueryParameters ["id"];
            }

            FindViewById<TextView> (Resource.Id.textViewProductId).Text = id;
        }
Exemplo n.º 9
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.ProductLayout);

            var id = "No Product ID Found";

            if (Intent.HasExtra("al_applink_data"))
            {
                var appLinkData = Intent.GetStringExtra("al_applink_data");

                var alUrl = new Rivets.AppLinkUrl(Intent.Data.ToString(), appLinkData);

                // InputQueryParameters will contain our product id
                if (alUrl != null && alUrl.InputQueryParameters.ContainsKey("id"))
                {
                    id = alUrl.InputQueryParameters ["id"];
                }
            }

            FindViewById <TextView> (Resource.Id.textViewProductId).Text = id;
        }
Exemplo n.º 10
0
        static void ExtractAppLinkData(Android.Content.Intent intent)
        {
            var result = new List <Data>();

            if (intent.HasExtra("al_applink_data"))
            {
                var appLinkData = intent.GetStringExtra("al_applink_data");
                var appLinkUrl  = new Rivets.AppLinkUrl(intent.Data.ToString(), appLinkData);

                if (appLinkUrl != null)
                {
                    foreach (var param in appLinkUrl.InputQueryParameters)
                    {
                        result.Add(new Data(param.Key, param.Value));
                    }
                }
            }
            else if (Uri.TryCreate(intent.DataString, UriKind.Absolute, out Uri uri))
            {
                result.AddRange(UriToData(uri));
            }
            OnAppLinkReceived?.Raise(result);
        }
Exemplo n.º 11
0
        public override bool OpenUrl(UIApplication app, NSUrl url, string sourceApp, NSObject annotation)
        {
            var rurl = new Rivets.AppLinkUrl(url.ToString());

            var id = string.Empty;

            if (rurl.InputQueryParameters.ContainsKey("id"))
            {
                id = rurl.InputQueryParameters ["id"];
            }

            if (rurl.InputUrl.Host.Equals("products") && !string.IsNullOrEmpty(id))
            {
                var c = new ProductViewController(id);
                navController.PushViewController(c, true);
                return(true);
            }
            else
            {
                navController.PopToRootViewController(true);
                return(true);
            }
        }