Start a new topic

Problem with Back Button into Wikitude AR IOS

 Good, I have a problem with the IOS navigation bar, I am calling the component using a "PushModalAsync", but it does not load the navigation bar, if I call it using "PushAsync" it does not load the complemen until I hit the " Back "of the application, then I do not have a way to return when I enter the component in IOS, in Android everything works perfectly because I use the" Back "of the hardware of the device.

Thank you


Good morning Sergio,



I'm not quite sure what you are trying to do exactly. Do you have some code for me to look at maybe?



- Daniel

Good morning, of course I enclose a bit of the code for your greater understanding.

The following code refers to the call of the augmented reality component of Wikitude, which calls "ARPageRenderer" of IOS

 

async void VerRealidadAsync()
        {
            botonHabilitado = false;
            OnPropertyChanged("BotonHabilitado");
            IsBusy = true;
            await Task.Delay(1000);
            ARPage arPage = new ARPage("Realidad Aumentada");
            if (arPage.worldId == "Realidad Aumentada")
            {
                arPage.worldId = "AR";
            }
            
            switch (Device.RuntimePlatform)
            {
                case Device.iOS:
                    await Application.Current.MainPage.Navigation.PushModalAsync(arPage);
                    IsBusy = false;
                    botonHabilitado = true;
                    OnPropertyChanged("BotonHabilitado");
                    return;
                case Device.Android:
                    await Application.Current.MainPage.Navigation.PushAsync(arPage);
                    await Application.Current.MainPage.Navigation.PopAsync();
                    await Application.Current.MainPage.Navigation.PushModalAsync(new DondeEstamosSimbologia());
                    IsBusy = false;
                    botonHabilitado = true;
                    OnPropertyChanged("BotonHabilitado");
                    return;
                default:
                    return;
            }
            
        }

 The problem happens as it is being called by "Pushmodalasync" then it does not load "navigation back button", as you can see in the following image

image

So we do not know how to create a navigation bar, that the only thing we occupy is a way to return to the previous page (before calling the component)



The problem with using "PushAsync" is that the component in IOS does not run until one presses the back button of the current screen, at which point the component is called. For "PushAsync" if that navigation bar is created, but it has that problem, then at the moment there is no way to return the component in IOS.

For Android that works well.

 

Any help?

 

Do they need some other code or something else? It is the only bug we still have, the license was purchased at the end of the year and we are soon to publish the application so we urgently need to fix that please.

 

Good morning,



my apologies for neglecting your request for such a long time. I'm afraid between the recent Beta release and my lack of organisational skills this post somehow fell through the cracks.


I think the quickest way to proceed from here would be for you to reproduce the issue you presented in the sample app of the Wikitude component and send it to me so I can have a look at what's going on.


Since I'm neither very experienced with Xamarin nor C#, I'd prefer you to reproduce it to make sure we're dealing with your exact issue.



- Daniel


Good, no problem, now we want to be able to solve this, as soon as possible because we are very behind, so we appreciate all the help that is possible.


For reasons of confidentiality (the application is banking) I can not provide the complete code, but some fragments can be seen below.


To summarize the problem: "When the component is called in IOS with (pushAsync) it simply does not show it unless you tap the back button, then there it appears.


If it is sent to call with (PushModalAsync) if the component is shown but without the top bar that has the back then when entering the component there is no way to exit or return to the previous page.


If this code is not enough we can organize a video call to solve this as soon as possible, since it really urges us.


Thank you very much and greetings.

 

  

        async void VerRealidadAsync()
        {
            try
            {
                botonHabilitado = false;
                OnPropertyChanged("BotonHabilitado");
                IsBusy = true;
                await Task.Delay(1000);
                ARPage arPage = new ARPage("Realidad Aumentada");
                if (arPage.worldId == "Realidad Aumentada")
                {
                    arPage.worldId = "AR";
                }

                switch (Device.RuntimePlatform)
                {
                    case Device.iOS:
                        await Application.Current.MainPage.Navigation.PushAsync(arPage);
                        await Task.Delay(1000);
                        IsBusy = false;
                        botonHabilitado = true;
                        OnPropertyChanged("BotonHabilitado");
                        break;
                    case Device.Android:
                        await Application.Current.MainPage.Navigation.PushAsync(arPage);
                        await Application.Current.MainPage.Navigation.PopToRootAsync();
                        await Application.Current.MainPage.Navigation.PushModalAsync(new DondeEstamosSimbologia());
                        await Task.Delay(1000);
                        IsBusy = false;
                        botonHabilitado = true;
                        OnPropertyChanged("BotonHabilitado");
                        return;
                    default:
                        return;
                }
            }
            catch (System.Exception e)
            {

                await Application.Current.MainPage.Navigation.PushAsync(new BNMasCercaSinConexion(string.Empty));
            }
           
            
        }

  ARPageRenderer

  

using System;
using Foundation;
using UIKit;
using Wikitude.Architect;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
using BNMasCercaCore;
[assembly: ExportRenderer(typeof(ARPage), typeof(XamarinExample.iOS.ARPageRenderer))]
namespace XamarinExample.iOS
{
	public class ARPageRenderer : PageRenderer
	{
		string worldId;
		WTArchitectView architectView;
		WTNavigation navigation;
		ExampleArchitectViewDelegate architectViewDelegate = new ExampleArchitectViewDelegate();

		protected override void OnElementChanged(VisualElementChangedEventArgs e)
		{
			base.OnElementChanged(e);
			var page = e.NewElement as ARPage;
            worldId = page.worldId;
			this.Title = worldId;
		}

		public override void ViewDidLoad()
		{
			base.ViewDidLoad();

			this.architectView = new WTArchitectView();
			this.architectView.Delegate = architectViewDelegate;
			this.View.AddSubview(this.architectView);
			this.architectView.TranslatesAutoresizingMaskIntoConstraints = false;
			NSDictionary views = new NSDictionary(new NSString("architectView"), architectView);


            this.View.AddConstraints(NSLayoutConstraint.FromVisualFormat("|[architectView]|", 0, null, views));
			this.View.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|[architectView]|", 0, null, views));

            architectView.SetLicenseKey("KEY");

			NSNotificationCenter.DefaultCenter.AddObserver(UIApplication.DidBecomeActiveNotification, (notification) =>
			{
				if (navigation.Interrupted)
				{
					architectView.reloadArchitectWorld();
				}
				StartAR();
			});

			NSNotificationCenter.DefaultCenter.AddObserver(UIApplication.WillResignActiveNotification, (notification) =>
			{
				StopAR();
			});

            var path = NSBundle.MainBundle.BundleUrl.AbsoluteString + "Wikitude/" + worldId + "/index.html";
            //var path = "Wikitude/" + worldId + "/index.html";
            navigation = architectView.LoadArchitectWorldFromURL(NSUrl.FromString(path), WTFeatures.Geo);
		}

		public override void ViewWillAppear(bool animated)
		{
			base.ViewWillAppear(animated);
			StartAR();
		}

		public override void ViewDidDisappear(bool animated)
		{
			base.ViewDidDisappear(animated);
			StopAR();
		}

		public void StartAR()
		{
			if (!architectView.IsRunning)
			{
				architectView.Start((startupConfiguration) =>
			   {
				   // use startupConfiguration.CaptureDevicePosition = AVFoundation.AVCaptureDevicePosition.Front; to start the Wikitude SDK with an active front cam
				   startupConfiguration.CaptureDevicePosition = AVFoundation.AVCaptureDevicePosition.Back;
			   }, (isRunning, error) =>
			   {
				   if (isRunning)
				   {
					   Console.WriteLine("Wikitude SDK version " + WTArchitectView.SDKVersion + " is running.");
				   }
				   else
				   {
					   Console.WriteLine("Unable to start Wikitude SDK. Error: " + error.LocalizedDescription);
				   }
			   });
			}
		}

		public void StopAR()
		{
			if (architectView.IsRunning)
			{
				architectView.Stop();
			}
		}

		#region Rotation

		public override void WillRotate(UIInterfaceOrientation toInterfaceOrientation, double duration)
		{
			base.WillRotate(toInterfaceOrientation, duration);

			architectView.SetShouldRotateToInterfaceOrientation(true, toInterfaceOrientation);
		}

		public override bool ShouldAutorotate()
		{
			return true;
		}

		#endregion
	}
} 

  

 

Hi Sergio,



I think I have a better picture now of what's happening here. You are using Xamarin.Forms which we do not yet have support for. We support, as our sample application demonstrates, Xamarin.iOS and Xamarin.Android.


A quick Google search led me to a GitHub repository demonstrating the use of Wikitude in combination with Xamarin.Forms, which I believe it what you based your app on. Unfortunately, this is a third party project that is not affiliated with Wikitude in any way.


Since we do not have support for Xamarin.Forms, I'm afraid I cannot provide support for it. I recommend taking up this issue with the maintainers of the aforementioned repository. The last commit was made yesterday, so it seem the project is very actively developed.


I'm sorry I can't provide any actual assistance with your issue.



- Daniel


Good Daniel I hope you are very well.


Regarding your answer, first thank for looking for the repository, precisely that is what I need to be able to do the application.


Now, on the part of us it does not seem very bad to us the attitude of the company of not offering the support that requires that the purchase of the license has been acquired and that it is very expensive for the same, that is considered looking for a solution and not Discard everything as it was done.


On the other hand we do not understand when it says that they do not support Xamarin forms, because in NO side they indicate that it is exclusive for Xamarin Android and Xamarin IOS, it only indicates that it is a component for Xamarin.


We can see it in the following images.

image


image




However, the moment I say goodbye, I appreciate the help given months ago and I comment that in the end if we manage to correct the problem and everything works perfect in Xamarin ways.


Greetings.

Good morning Sergio,



you are correct; the documentation does not explicitly state that Xamarin.Forms is not supported. That is something we should fix. The reason for this shortcoming is historical. The Wikitude Xamarin component was release in 2014, when Xamarin Forms was not yet available. For subsequent releases we just updated the version of the Wikitude SDK used internally.


I would like to point out, however, that the sample applications contained in the Xamarin component, demonstrating how the component is to be used, are Xamarin.iOS and Xamarin.Android only. But I do agree that we should be more explicit about Xamarin.Forms not being supported.


Allow me to apologise again for not being able to be of any help, but investigating Xamarin.Forms and supporting it officially is something, I believe, that requires an investigation that exceeds the timeframe allotted for a support request.


Still, I'm hoping you will be able to find a solution for the problem you are having.



- Daniel

Login or Signup to post a comment