Using krpano in a Cordova App

  • We've been embedding krpano in our apps using Cordova for a while now, and never had any issues with it. However, we're now struggling to get VR working on Android.

    If we upload the content to web, it's correctly detecting the device. However, as soon as it's in the app it's failing and reporting an unknown device.

    I can't find much documentation about how the device detection feature works, other than a mention that it works off user agent on Android. I've done some testing and the user agent is slightly different. Not by much, but perhaps enough to fool whatever check is in place? (There's an extra "; wv" in the build and and extra "Version/4.0").

    Code
    Chrome browser:
    Mozilla/5.0 (Linux; Android 7.0; SM-G920F Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.84 Mobile Safari/537.36
    Chrome in Cordova:
    Mozilla/5.0 (Linux; Android 7.0; SM-G920F Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/62.0.3202.84 Mobile Safari/537.36

    And I'm not sure if it counts, but krpano also returns a different screen size depending on the method used:

    Screen Size

    • Krpano running in browser: 5.1
    • Krpano running in app: 5
    • Cordova screen detection plugin: 5.06

    I'm guessing this is a complicated question that's outside the scope of what you'd usually deal with here, but any suggestions as to how we might be able to make this work (possibly by fooling the device detection?) would be greatly appreciated.

    Edited 3 times, last by Dan Robinson (November 14, 2017 at 1:53 PM).

  • Hi,

    yes, the Android device detection is by parsing the user-agent string (btw - there is no other way there).

    There is no standard how a user-agent should be written, but typically the last entry in the first brackets is the name of the device - and that's what the WebVR plugin is using on Android.

    For the next release I will add an exception for that 'wv' entry to ignore/skip that.

    Best regards,
    Klaus

  • Hi Klaus,

    Thanks for replying. Good to know that it'll be addressed in the next version, really appreciate you taking the time to adjust things for something that's so far outside krpano's normal usage!

    Edit - Cordova lets you forcibly set the user agent, so thanks to your help I've been able to get it to work by simply stripping out the '; wv' bit and manually pushing the user agent back to the browser. It's a bit messy but it works, so thanks again!

  • Hi Klaus,

    Thanks for replying. Good to know that it'll be addressed in the next version, really appreciate you taking the time to adjust things for something that's so far outside krpano's normal usage!

    Edit - Cordova lets you forcibly set the user agent, so thanks to your help I've been able to get it to work by simply stripping out the '; wv' bit and manually pushing the user agent back to the browser. It's a bit messy but it works, so thanks again!

    I know it's 2019, but now I'm having the same problem, and find it difficult to implement your instructions; in which file in Cordova do you set the user agent, and how do you push user agent back to the browser?

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!