Start a new topic

Call C# method from JavaScript AR world

Hi everyone,

I am trying to call C# method from JavaScript code when button is pressed. I saw that I have to use following architectsdk protocol to call the c# method. 

document.location = ""architectsdk://"classandmethodnamehere"?param1=" + encodeURIComponent(param1);

However I don't have clue on how to identify the C# method with its class and how to receive the call from JavaScript in c#.The propose of this call to C# is that I want to get an photo from the camera when button is clicked from wikitude. Any help regarding this issue would be highly appreciated since I have been stuck on this issue for more than 7 hours.  


the corresponding C# function of document.location is invokedURL. Within invokedURL you need to parse the url you're given and act based on that.

invokedURL (iOS)

invokedURL (Android)

There is, however, another and arguably easier way of communicating with C# from JavaScript. Instead of document.location and invokedURL you can use AR.platform.sendJSONObject and receivedJSONObject.

sendJSONObject (JS)

receivedJSONObject (iOS)

receivedJSONObject (Android)

- Daniel

Hi Daniel,

I Managed to call JavaScript to native code using  AR.platform.sendJSONObject method, However now I am stuck on how to take snapshot from camera using native code. So I am wondering if there is any method in native code that I can used for taking a snapshot?

Good morning,

will this be sufficient?



- Daniel

Hey Daniel,

Kind of .I am wondering is there anyway to get a snapshot using code like following code with C# Xamarin.Android from WikitudeActivity class of the image on target example ? 


SampleCamActivity.this.architectView.captureScreen(ArchitectView.CaptureScreenCallback.CAPTURE_MODE_CAM_AND_WEBVIEW, new CaptureScreenCallback() {
						public void onScreenCaptured(final Bitmap screenCapture) {
							if ( ContextCompat.checkSelfPermission(SampleCamActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED ) {
                                SampleCamActivity.this.screenCapture = screenCapture;
                                ActivityCompat.requestPermissions(SampleCamActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, WIKITUDE_PERMISSIONS_REQUEST_EXTERNAL_STORAGE);
                            } else {


Thank you.

Good morning,

I believe it should work pretty much exactly like the snippet you have posted, you'd just need to translate it into C#.

The ArchitectView for Xamarin.Android should have a method called captureScreen with the exact parameters indicated by your snippet and the documentation I linked previously.


The Xamarin component, at least to my understanding, ist just a C# wrapper for the Objective C and Java functions of the Wikitude SDK, which is why the regular Android and iOS documentation thereof applies.

- Daniel

Login or Signup to post a comment