Start a new topic

InvokedURL is not always invoked

Hi,


I have a Xamarin forms project and I have implemented wikitude for iOS.


I have a view renderer that show some items with wikitude.


My problem is that when I mark any element, invokeurl is not always called. I don't know why sometimes works but others no.

  

My iOS code is the following:

 

public void Start()
{
CMMotionManager motion = new CMMotionManager();
                motion.DeviceMotionUpdateInterval = 20;

                this.architectView = new WTArchitectView(new CGRect(0, 0, this.Element.WidthRequest, this.Element.HeightRequest), motion);
                this.architectView.SetLicenseKey(Likwid.iOS.Logic.Drops.Constants.WIKITUDE_SDK_KEY);

                ArchitectViewDelegate architectViewDelegate = new ArchitectViewDelegate(this);
                this.architectView.Delegate = architectViewDelegate;

                //Load the AR View
                string absoluteWorldUrl = NSBundle.MainBundle.BundleUrl.AbsoluteString + "ArchitectWorld" + "/index.html";
                NSUrl absoluteNSurl = new NSUrl(absoluteWorldUrl);
                this.architectView.LoadArchitectWorldFromURL(absoluteNSurl, requiredFeatures);

                this.SetNativeControl(this.architectView);
                this.architectView.Start(this.StartArchitechView, this.OnStartedArchitechView);

}

private void StartArchitechView(WTStartupConfiguration configuration)
        {
            configuration.CaptureDevicePosition = AVCaptureDevicePosition.Back;
            configuration.UseSystemDeviceSensorCalibrationDisplay = false;
        }

        private void OnStartedArchitechView(bool isRunning, NSError error)
        {
            if (isRunning)
            {
                this.SetupAR();
                Console.WriteLine("Wikitude SDK version " + WTArchitectView.SDKVersion + " is running.");
            }
            else
            {
                Console.WriteLine("Unable to start Wikitude SDK. Error: " + error.LocalizedDescription);
            }
        }

        private async Task SetupAR()
        {
            var setup = new JsonObject();
            // screen Scale
            var screenScale = new JsonObject();
            screenScale.Add("width", App.ScreenWidth);
            screenScale.Add("height", App.ScreenHeight);
            setup.Add("screenScale", screenScale);

            IEnumerable<Eyetime.Models.Channels.Drop> drops = await ((DropViewModel)this.Element.BindingContext).GetNearbyDrops();
            string dataAsString = JsonConvert.SerializeObject(drops);

            string js = string.Format("World.loadPoisFromJsonData({0},{1})", setup, dataAsString);
            this.architectView.CallJavaScript(js);
        }

   

And in JS is:


 

Marker.prototype.getOnClickTrigger = function (marker) 
{
    /*
        The setSelected and setDeselected functions are prototype Marker functions. 
        Both functions perform the same steps but inverted.
    */
    return function () 
    {
        try 
        {
            World.onMarkerSelected(marker);
        }
        catch(Err)
        {}
            
        return true;
    };
};

onMarkerSelected: function onMarkerSelectedFn(marker) {
        World.currentMarker = marker;

        var architectSdkUrl = "architectsdk://markerselected?id=" + encodeURIComponent(marker.poiData.id) + "&type=" + encodeURIComponent(marker.poiData.type);

        alert(architectSdkUrl);

        document.location = architectSdkUrl;
    },

 The js always display the alert.



Hello Darío,



I have tried to reproduce your issue with the Wikitude Xamarin sample app, but could not.


I simply attached the following function to the onclick event of an HTML button. 



imageontarget.js:

myClickFunction: function() {
    document.location = "architectsdk://mybuttonclicked?action=hellonativefromjs";
    alert("myClickFunction");
}

 

index.html:

<button onclick="World.myClickFunction();" style="position:absolute;top:500px;left:500px;">click me!</button>

 


All of my clicks generated both the alert dialog as well as a call to the InvokedURL function on the C# side.


Could you try to do the same and report back to me whether it works or not?


Starting from the unaltered Wikitude Xamarin sample app, you would just need to add the two snippets I posted previously in the imageontarget.js file and the index.html file respectively. The unaltered sample app already logs calls to the InvokedURL function by default.


I also attached both these files with the required alterations for your convenience.


Kind regards

Daniel

html
(635 Bytes)
js

Hello,


I cannot run the iOS sample project.


I create a new solution, download Wikitude component and run. I try changing the default serial to my serial but the project still not working.


I have attached the project.


Thank you!

zip

Good morning,


I ran the code you provided with the latest build of our Xamarin component and found the InvokedURL function to be invoked correctly. I also had no trouble running the code. What issues are you facing? Could you provide the error logs for me to have a look at?


Also, which version of our component are you using?


Kind regards

Daniel

Hello,


Sorry, the code crash because missing in info.plist the Camera Usage Description.


I run the project and always invoke url is called.


How can show you what is happening in my project?



Hi,


you could send your project to me, if you are comfortable with that, so I can have a look and maybe figure out why you are having this issue.


Kind regards

Daniel

Login or Signup to post a comment