Start a new topic

Several Issues with Phonegap Plugin

Several Issues with Phonegap Plugin


Hi,

I'm having some problems with the Wikitude plugin in a phonegap application.

1. Back button in the AR view will occassionally close out of the entire app. I have implemented the backbutton event listener in the code as follows:

index.js

        document.addEventListener("backbutton", onBackKeyDown, false);

        function onBackKeyDown() {

            app.wikitudePlugin.hide();

            app.isLoaded = true;

            return false;

        }

index.html (script)


        document.addEventListener("backbutton", onBackKeyDown, false);

        function onBackKeyDown() {

            document.location = 'architectsdk://action=closeWikitudePlugin';

            return false;

        }

 


Also I have referred to this link: https://support.wikitude.com/support/search/topics?term=Android+Backbutton+behavior and haven't had any success with it.

 

2. The webview flickers occassionally while loading. That is to say the, HTML portions (buttons, slider, etc) will flicker occassionally and look like they are being redrawn. Would definitely appreciate some feedback on how to avoid this as I do not experience this in the plugin samples.

3. Keep screen on without automatically turning off. Would it be possible to get a way to keep the screen away as long as they are in the AR screen? I cannot find this in the documentation.

The application is open source and the repo is at: https://github.com/DataAnalyticsinStudentHands/publicartapp

Overall the the plugin is working great, but looking to refine configuration to enhance performance and user experience.

Thanks for the help!

Hi Carl,
1) Why did you implement the back button functionality twice? You need the back button handling either in your (PhoneGap) .js code OR in your (PhoneGap) .html.

2) As it does not appear in the sample application, try to remove all your application functionality until the flickering is gone to isolate the critical components. As this might be a .html/.css/.js issue please refer to some web development forums/blogs.

3) Currently the Wikitude SDK does not prevent the screen from going into sleep mode. You would need to use another 3rd party plugin to do so or implement the functionality in Java/ObjC yourself.

 

Best regards

Andreas

Hi Andreas,

Thank you for the reply.

1. Implementation in the phonegap .js did not fix the problem, so I went ahead and tried to add it in the AR world's HTML.

With both of the approaches it only works for the first time that the physical "back" button is clicked, second time that AR mode is activiated, the application exits upon the user hitting the back button.

Upon investigating into the plugin sample application, I am unable to find any backbutton handling, but it seems to work without problems. How is that possible?

2. The HTML/CSS that is being loaded into the AR view has no problem when run standalone as a Phonegap application. Looks like it could be something bigger.

3. I will look into this and evaluating several plugins to see which one best suits our needs.

Thanks!

After taking the backbutton event out of the world's JS and leaving it in only the index.js which is on the phonegap side of the app, I think it is not being called at all.

Pressing the back button causes the AR mode to "close" and I am trying to get it to "hide"

Debugging shows me that my backbutton callback is not being called at all.

Hi Andreas,

I want to go ahead and another issue I have had with Wikitude since we are in different timezones.

This regarding the AR.ImageDrawable and accompanying Label. I am trying to add a AR.Label to the ImageDrawable for the indicator (blue arrow at edges of screen). However, the distance from the arrow (AR.Label.offsetY) is not constant between portrait and landscape it seems, so I am ending up with the marker being different distances away from the indicator ImageDrawable based on the orientation of the device.

My marker.js is available at this link: https://github.com/DataAnalyticsinStudentHands/PublicArtApp/blob/master/www/ar_world/js/marker.js

Any help on this and the previous issues would be much appreciated.

Thank You,

Carl

The Wikitude Plugin provides a 'hide' and 'close' function. Depending on your needs you can communicate between the ARchitect World and the PhoneGap application and trigger the corresponding action.

I'm not sure how I can help you otherwise regarding the back button behaviour. The Wikitude Plugin provides functions you might be interested in and the PhoneGap app provides lifecycle events. You might only need to connect them for your needs. Again, you might be interested how we impl. our PhoneGap sample application which is available on GitHub.

 

Regarding the direction indicator: You could forward rotation events into the ARchitect World and then dynamically adjust the offset to a new value. You can adjust any properties of a drawable at any time.

Best regards

Andreas

Regarding the hide and close, this is exactly what I am trying to do and it works perfectly on an iOS device without a back button. However, in the Android environment when a user clicks the physical back button, the user is either exited from the entire application or it looks like the "close" function of the plugin is automatically called rather than my "onBackButton" function which I have defined and added an event listener for.

I have gone through the sample and the only "document.addEventListener" I can find is for deviceready (index.js), not backbutton. Currently, I am trying to call the Wikitude "hide" function when the backbutton is pressed via Phonegap, however, it looks like the Wikitude intercepter for the event is getting caught before my function. Any suggestions on this?

Thanks for the input on the direction indicator, I will try to do what you have suggested.

Also, we ran into an issue where I am unable to "face" any POIs occassionally on some devices (Google Nexus 6, Samsung Galaxy 3 or 4, and Sony Xperia Z1C). Here is a youtube video with an example of how that looks. https://www.youtube.com/watch?v=D4Zlsc70L7s I think this may be due to a lack of accurate GPS coordinates that Wikitude is able to gather.

Why does Wikitude not offer a callback/detection method for weak/inaccurate GPS data?

Thank You,

Carl Steven

Regarding the 'hide': when you press the back button inside an AR world, the event is processed inside the webview which is displaying the AR content. So, if you want to intercept the event, you should handle it inside the webview (in the HTML source of your AR world), you can then send an event using the "architectsdk://" url scheme.

Regarding the other problem, it's probably a compass issue: I see from your video that you are testing near some big metallic objects. Could you check with a compass application  (there are many in the play store) if the device orientation is reported correctly?

Hi,

Thank you for the reply. I am trying to put the callback for the backbutton in the ARView now, instead. So here's what it looks like:

index.html (in ARView)

        function closeWikitudePlugin() {

            document.location = 'architectsdk://action=closeWikitudePlugin';

        }

        document.addEventListener("backbutton", closeWikitudePlugin, false);

index.js


       onURLInvoked: function (url) {

       if (url.indexOf('closeWikitudePlugin') > -1) {

            app.wikitudePlugin.hide();

       } else ...>

 

Again this is not being called at all. I am putting a breakpoint on the "closeWikitudePlugin()" function and it is never called when I press the back button on my phone. I would appreciate feedback on what I am doing wrong here.

 

Regarding the other issue, it is intermittent in both location and time, so not reliably reproduceable even the same location. I am wondering if there is any way in the Wikitude API to detect a "weak" GPS (i.e. not enough satellites, etc)? Upon trying with a GPS/compass app in the same location, I am not detecting any interferences in magnetic fields.

 

However, I've noticed that the POIs can spin around inaccurately in some conditions, but unable to isolate the cause for that to happen. I will update again with a video of this in action in non-metallic areas from field testing the app.

This backbutton is something that I would like to fix as soon as possible in order to move forward with this app.

I'd appreciate your help as it has been almost two weeks since your last reply.

Thanks,

Carl

Back button

I'm sorry but I don't know how to rephrase my previous answers.

very simplified:

somewhere in your ARchitect world:
...
document.location = architectsdk://closeARView;
...

somewhere in your PhoneGap app:
...
app.wikitudePlugin.setOnUrlInvokeCallback(app.onUrlInvoke);
...

...
onURLInvoked: function (url) {

 app.wikitudePlugin.hide(); // or app.wikitudePlugin.close(); // whatever floats your boat/needs

}

...

 

Regrading your GPS question:

 


onLocationChanged
 


 



The function will be called as soon as


the location is fetched the first time, or

the location of the user changes.


The trigger is null by default, and will thus result in no action executed when the trigger fires. A developer can add custom functionality by assigning a custom function to onLocationChanged.



Event Payload:


latitude Number


the current latitude of the user, based on WGS84



longitude Number


the current longitude of the user, based on WGS84



altitude Number


the current altitude of the user, based on WGS84



accuracy Number


The accuracy of the reported location, see AR.CONST.LOCATION_ACCURACY for details






 

Sensor accuracy:

Sensor AR is tested best outside becaue metal or other disturbing fields confuse the device sensor.

 

I hope you can use these information to finish your implementation


Best regards

Andreas
Login or Signup to post a comment