I need to call some native function of Objective-C from ArchitectWorld Javascript file. There is a method from JS or I have to use callJavascript: method from iOS? Thanks
A
Andreas Schacherbauer
said
over 9 years ago
Hi Luca, You can use the ObjC method -callJavaScript: to evaluate JS in the context of the current ARchitect World. When you need to call from JS to ObjC, you can use our custom URL scheme 'architectsdk://'. Simply call 'document.location = architectsdk://theObjCMethodToCall?parameter1=foo¶meter2=bar'. You can append any parameter that you want. To receive those calls in your native application, set your WTArchitectView Delegate and impl. the method '-architectView:invokedURL:'. You get the complete URL and can then parse it to get the method name out of it. Afterwards simply do a if/else or something else to invoke the ObjC method you want.
Hope this helps
Best regards
Andreas
L
Luca
said
over 9 years ago
It's great, thank you :)
L
Luca
said
over 9 years ago
OK, for example, I want to load in Javascript a drawable when I'm near a GeoLocation. OK!
Now three buttons (in jQuery Mobile) will appear and these three buttons are linked to Objective-C using invokedURL method. iOS opens a view. When I will close the view, I want to see the ARchitect World without reload it. Is it possible? Maybe I can show the view over the architecView?
A
Andreas Schacherbauer
said
over 9 years ago
Hi, as long as you don't load the architect view again, the WTArchitectView will still be in the same state after a -stop / -start method call (presumed that you don't destroy all js object on stopping the architect view).
So don't call -loadArchitectWorldFromUrl in the -viewWillAppear / -viewDidAppear method of your view controller who manages the architect view.
Best regards
Andreas
L
Luca
said
over 9 years ago
Ok, it's perfect!
Last question: app seems reload, each time, 3D model. So document and data of the app will increase, that's why? Have I to destroy all ARObject before closing the app?
EDIT:
I modified the JS file inserting the document.location.
I set the architectView object as delegate of WTArchitetcView, but it is not entering in invokedURL method...
Luca