Using the PhoneGap CLI

iconTo date, we’ve encouraged our users to use PhoneGap Build to make their native apps. It’s quick, easy to use and meets the needs of most users. PhoneGap Build is a wrapper built on top of the open source Cordova engine. PhoneGap CLI lets you work directly with Cordova, which has a few advantages:

  • Build takes place on your local machine – no uploading to a service
  • Free – PhoneGap CLI is open source.
  • No limit on number of projects
  • Use the latest plugins: Sometime developers have newer versions of their plugin that are not in PhoneGap Build yet.
  • Use PlugIns which are not in PhoneGap Build at all.
  • Use custom PlugIns you have developed yourself.

But there are a few downsides too:
Continue reading “Using the PhoneGap CLI”

Using serverStorage to save your data

ServerStorage is an easy new way to save data in your AppStudio App. It works just like localStorage, but instead of saving the data locally on your device, it saves to the server.

This opens up many new possibilities: Companies could upload and download data, teachers could publish information for students, games could share scores or moves. It could even be used as a backup in the cloud.
Continue reading “Using serverStorage to save your data”

AppStudio 4.2.5 Released!

AppStudio 4.2.5 is ready. This release has an easy way to save data on the server, PhoneGap CLI support, and introduces Google Glass as a platform.

  1. Language: New serverStorage object: makes it easy to store data on the server.
  2. Deploy: PhoneGap CLI support added.
  3. Deploy: Google Glass support added.
  4. Code Window: Disable block comments in free form blocks.
  5. Controls: Error hiding Panel fixed.
  6. Deploy: Fix extraheaders line ending. Existing apps need to open property and hit OK.
  7. Deploy: versionCode added to default PhoneGap configxml.
  8. Design Screen: Fix non numeric left and top.
  9. Design Screen: Vertical drag now sets horizontal % correctly.
  10. IDE: Better message for Other files without an external file.
  11. Library: jQuery Mobile: Upgraded to 1.4.5. Fixes for iOS 8.
  12. Library: Updated iScroll to 1.5.3 and minified.
  13. Preferences: Moved PhoneGap options to a new tab.
  14. Runtime: Change close character to %times; in dialogs.
  15. Runtime: isEmpty() function improved. (Thanks, Tomas!)
  16. Runtime: PlaySound now fails gracefully in IE11.
  17. Runtime: Set NSBCurrentForm before global code executes.
  18. Samples: Dropbox samples updated.
  19. Samples: New serverStorage and StudentsServerStorage samples added.
  20. Samples: Google Glass sample added.

AppStudio 4.2.4 released!

AppStudio 4.2.4 is ready. This release has support for iPhone 6 and 6 Plus splash screens, plus a number of updates and fixes.

  1. Code Window: K no longer quotes text on some German systems.
  2. Controls: Panel.close function added.
  3. Controls: Panel auto sizes form when opened.
  4. Controls: Panel.previousForm adds reference to calling form.
  5. Deploy: Obsolete demos cannot use nsbapp.com.
  6. Deploy: Splashscreens for iPhone 6, iPhone 6 Plus added.
  7. Design Screen: Grid overlay is no longer wiped out by background color.
  8. Documentation: Localization and wiki files updated.
  9. PhoneGap: remove obsolete reference to feature properties.
  10. Runtime: PlaySound incompatibility with Safari fixed.
  11. Samples: New PhoneGapVidCap sampled added. (Thanks, Julio!)

Videos!

We now have a set of YouTube videos available. They’re short – just a minute or two each – but help with how to get started with AppStudio.

They are:

  • A Short Tour of AppStudio
  • Your first AppStudio App: Hello World!
  • Run your AppStudio App on iOS
  • Run your AppStudio App on Android
  • Use PhoneGap to make an AppStudio App native

English: https://www.youtube.com/channel/UC3NpfXo8K7xoYZENHvhShYw

Arabic: https://www.youtube.com/channel/UC5g_DTUUJnTthlF6-5pPR7Q

Parameters: an easier way to make SQLite commands

Ever had to code a messy statement like this?

    sqlList[j]="INSERT INTO customerData (name, age, sales) VALUES _
        ( " & "'cust" & j & "', " & j & ", " & j*10 & ");"

Here’s a more elegant want to do the same thing. Load your values into an array, then put a question mark in your query string where you want them to be substituted:

    args=[cust, j, j*10]
    sqlList[j]=["INSERT INTO customerData (name, age, sales) VALUES _
        (?,?,?);", args]

Notice that we also had to put the query string into an array, with the first element being the query string and the second our array of arguments.

(This is only for SQLite strings. If you would like to do something similar to your other strings, check out the Format function.)

Using the NSBApp Debugger

The NSBApp Debugger (AppStudio 4.2.2+) is based in the Weinre (“WEb INspector REmote”) app. It looks like a subset of the Chrome Debugger. That’s no surprise: both are based on the same Web Inspector software. This debugger does not have the ability to view code or set checkpoints, but otherwise is quite functional.

It’s a great way to debug your app when it running on an actual device.

Use it in the following cases:
Continue reading “Using the NSBApp Debugger”

AppStudio 4.2.3 released!

AppStudio 4.2.3 is ready. This release has a nice new Panel control, how to Videos and a number of updates and fixes.

  1. Controls: New jQM Panel control. (Thanks, Erkan!)
  2. Controls: The height property of Form object can now be set if fullscreen is false.
  3. Controls: jQM RadioButton square corners fixed.
  4. Controls: HeaderBar – background on notext buttons is gone.
  5. Code Window: go to function works properly in JavaScript
  6. Code Window: JavaScript functions created from Properties Window correctly.
  7. Deploy: iOS 8 no longer supports minimal-ui, so default is now off.
  8. Deploy: Security certificate handlers updated.
  9. Language: SQL now supports Using_SQLite#Parameters|parameters.
  10. Language: Bug in Yosemite’s handling of Arabic worked around.
  11. Language: Serbian added (Thanks, Elvir!)
  12. Help: Link to English and Arabic AppStudio Videos added.
  13. Libraries: DropBox upgraded to 1.2.
  14. Samples: New Panel sample.
  15. Samples: All use .appcache as the cache file name suffix.
  16. Samples: Updated to use SQLite Parameters.

Advanced control of the Camera using PhoneGap

(Guest post from Mike Burgher – thanks!)

I’ll share my experience using the Android camera; hope this doesn’t cause confusion. I wrote an NSBasic app that uses the camera to do motion detection on the area. It does time-lapse, auto-shoot the camera, and compares portions of the images over time. You use it, for example, if you are in a sketchy hotel room and you want some peace of mind. While you sleep, it will detect if the door starts to open, and alarms loudly and summons help.

It’s all NSBasic except the “getpicture” camera operation, which is a custom PhoneGap plugin. I know of no way to do this whole thing from JavaScript. The Android camera API sequence is non-trivial, but there is good documentation and code examples.

In a plugin, it’s fairly easy to select which camera, set the parameters, shoot the picture when the camera is ready, and save it.

The camera preview is more of an issue. The Android API sequence requires you to display a preview on the screen before the camera is ready to take a picture. For many applications, you don’t want to see that preview; you want to see your app. There are several approaches to hiding that preview, from making it ultra small (1px by 1px) to making it transparent on >= Android 4.0. But there is no single solution that works on all Android cameras. And there are various undocumented limitations on cameras, dictated by the manufacturer.

And it’s hard to debug a camera app! Things will work on the device, that won’t work in the Android emulator, and vice versa.

I started with an existing custom PhoneGap plugin called Foreground Camera, who’s purpose was to keep your app from going to the background and getting killed off by Android when you called the standard “getpicture”. It was modified to select the camera, hide the preview, and take the picture without user intervention.

Unfortunately, I’ve been living in an ancient PhoneGap 2.5 world for a long time. I suddenly have to bring all my stuff up to the current PhoneGap level. But I’d be happy to share my mods to this plugin. It’s not 100% stable yet, and I’d welcome any improvements.

— Mike