Can I use Volt AND PhoneGap?

I have to use PhoneGap as I need Bluetooth. PhoneGap deployment is working fine, But how can I use the Volt features with my PhoneGap app? (or indeed also have it hosted by Volt for easier access by my clients?). The 2 features I see as most necessary on Volt for me are AppStorage and ServerStorage. Thanks!

Yes, this should work fine. You’ll probably need to whitelist the Volt site in your app.

Hi, thanks, but how? The App has to be made on PhoneGap. How do I get it to Volt or point it to Volt?

In Project Properties, there is one called Volt Domain. Set that to your Volt domain - it will then run as if you started it on Volt.

For example, set it to

HelloWorld.hums.softly

Thanks! Just the 3rd level TLD then. (I had tried https://HelloWorld.hums.softly.volt.live … it’s a good job I didn’t try to debug that as I guess that would not work).

Also, I’ve already deployed it to Volt so I guess that sets up volt to accept it. I’ll try and figure out how to whitelist the Volt site on my app.

And that’s all there is to it? Wow… I’ll let you know how I get on…

Nope. That does not work I am afraid to say. It only works if you are running the app from Volt. If you run it from PhoneGap or desktop, it just says “Uncaught ReferenceError: appStorage is not defined.”

Setting Dashboard Access = True does not work either. I have also tried all combinations of Volt Domain.

Please help…

Let me set up a test here. Hopefully, I’ll have a result by tomorrow.

That would be great. Thank you very much. Incidentally, even running the app from Volt, one must set the domain to helloworld.hums.softly.volt.live … Ie: it must include the “.volt.live” and exclude the “https://”. As yet I am getting “Unauthorised” but I’m sure I will figure that out.

It worked for me, but I needed to one extra step. I wrote it up in a blog post:

http://blog.nsbasic.com/2017/08/accessing-volt-from-a-phonegap-app/

Give it a try and let me know if it works for you!

What can I say… Wow! Great blog. I will give it a try on Sunday. Thanks!

Alfie

may i know do u manage to using phonegap bluetooth api in nsbasic/app? i want to use bluetooth to print

thanks
Teo

This is a different topic. Can you open a new question for this one?

Update: This is not the best recommendation – see amended below
@Leader, Yes, that worked OK. Only slight pedantry ref your blog…

In Project Properties, add the path of the Volt library to extraheaders. For example:
<script src=‘https://storage-introduces-owlishly.volt.live/api/client/volt.js>

At the end use /> instead of >, else it won’t compile under phonegap

  • For others: This refers to Project Explorer // Project Properties & Global Code (top of tree) // PhoneGap (subsection) // config.xml (property) , and I inserted the above line just before <!-- Icons -->.

(Reminder to others: Replace storage-introduces-owlishly with whatever your app’s domain name is. )

Actually, I was referring to Project Explorer // Project Properties & Global Code (top of tree) // extraheaders.

Did you have to modify configxml as well to get it to work? I did not need to.

Oops, that would be the FAR more logical place to put it. Thanks, I have done that now (and removed my mistake) as I want to keep things as standard as possible.

This is better as it tries to work (albeit with a network error) even on “start in desktop browser”.

In that case <script src='https://storage-introduces-owlishly.volt.live/api/client/volt.js' > should be appended with </script> (without which the desktop deployment throws up errors).

Ps: No, I didn’t need to modify config.xml … that just modified itself when I deployed to PhoneGap :slight_smile: .

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.