Start a new topic

Strange behavior when using WikitudePlugin.setOnUrlInvokeCallback() [iOS]

I am seeing very strange behavior in iOS when using the setOnUrlInvokeCallback function in my Ionic based app. In the AR scene when invoking the callback via: 


document.location.href = 'architectsdk://button?action=someAction'

The callback will to do one of three things:
- Receive the correct string and behave as expected
- Receive the string that was last set to document.location.href
- The callback is never called

For example, using this code (Typescript - Ionic):


WikitudePlugin.setOnUrlInvokeCallback((url: string) => {
    console.log('url is', string);
    switch(true) {
        case (url.indexOf('action1') > -1):  this.action1(); break;
        case (url.indexOf('action2') > -1):  this.action2(); break;
        case (url.indexOf('action3') > -1):  this.action3(); break;
       default: console.log('Unknown action'); break;

 and (Typescript - AR Scene)


class ARScene {
    action1(): void {
        document.location.href = 'architectsdk://button?action=action1';
        console.log('Action 1 called');

     action2(): void {
        document.location.href = 'architectsdk://button?action=action2;
        console.log('Action 2 called');

     action3(): void {
        document.location.href = 'architectsdk://button?action=action3';
        console.log('Action 3 called');

I will see behavior similar to this:

- call action1();
- Wikitude console:
    Action 1 called
- Ionic console:
    // Nothing happens

- call action2();
- Wikitude console:
    Action 2 called
- Ionic console: 
    url is architectsdk://button?action=action1

- call action3();
- Wikitude console: 
    Action 3 called
- Ionic console: 
    url is acrchitectsdk://button?action=action2

- call action1(); 
- Wikitude console:
    Action 1 called
- Ionic console:
    url is acrchitectsdk://button?action=action3

Sometimes it appears that it will 'catch up' and do the correct action until an action happens and the urlCallback is not called. At which point, this behavior seems to start again. 

Any help would be appreciated, I am using SDK7. 
This behavior does not seem to happen on Android. 

Hi Jacob,

We recently replaced `setOnUrlInvokeCallback` & `document.location = architectsdk://` approach with a new one. The new JS API is called `AR.platform.sendJSONObject`. There is a function in our Cordova plugin that behaves similar to the already known `setOnUrlInvokeCallback` named `setJSONObjectReceivedCallback`.

Having sad that we know that there are some issues with Ionic based applications (Please note that we don't officially support Ionic at the moment) which are originating from WKWebView. If you can switch to UIWebView, you shouldn't experience those though.

Best regards,


Hi Andreas! Thanks for the info. The new JS API that you noted is working great!

Login or Signup to post a comment