Suggestions for a better approach to app template(s)

  • 1
  • Idea
  • Updated 5 years ago
  • Under Consideration
I might sound a bit sarcastic, but that's to get the points across. I'm usually rather nice (my cat says so), and I like PhoneGap and PhoneGap Build very much.

Photo of Anders Borg

Anders Borg

  • 329 Posts
  • 12 Reply Likes

Posted 6 years ago

  • 1
Photo of Anders Borg

Anders Borg

  • 329 Posts
  • 12 Reply Likes
Interestingly PGB creates images despite there being only icon and splash, but they are all completely blank yet with the right dimensions. I suspected that icon.png was somehow broken, but it wasn't.

Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Yes, that has been reported and explained here several times. You will find a dozen or so threads on this topic. Search for "blank icons".
Photo of Anders Borg

Anders Borg

  • 329 Posts
  • 12 Reply Likes
I intend to host the tutorial where it's at now, so if you ever need to refer to it, you can assume http://abiro.com/tutorials/phonegap/ will stick.

I'll have a "draft free" version ready tomorrow.
Photo of Anders Borg

Anders Borg

  • 329 Posts
  • 12 Reply Likes
I've published a cleaned up tutorial. I'll update the template tomorrow, exactly mirroring the tutorial.
Photo of Anders Borg

Anders Borg

  • 329 Posts
  • 12 Reply Likes
I'm releasing the tutorial now as an ~1.0, and will handle comments over time.

I've gong through the text and the template and they are in sync. The template clearly "works".

Anders
Photo of Anders Borg

Anders Borg

  • 329 Posts
  • 12 Reply Likes
Do you have any last word on this?

Does it make sense?

Is it coherent?

Any other place I could/should plug this at?

Regards,
Anders
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
It's a really good start. I recommended the document in recent threads a couple of times, but there has been no feedback on it so far.
Let's just see what other developers say when they see it.
Photo of Anders Borg

Anders Borg

  • 329 Posts
  • 12 Reply Likes
Same here: No feedback so far.

Do you know of a recommended way of handling an app's end-user preferences, except via brute force?

Regards,
Anders
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
I'm not sure what you mean by "handling an app's end-user preferences". Something like "an end user has GPS and Internet connection switched off, so my app doesn't do what it is supposed to do" or "the device doesn't have a camera, so the user can't participate in the shoot-a-windmill-contest"?

If so:
1st option: detect those preferences and don't offer these app functions in the first place
2nd option: if function is invoked anyway, use the error callback to display a proper message.

I prefer the first option, but that's in no way a "general recommendation"
Photo of Anders Borg

Anders Borg

  • 329 Posts
  • 12 Reply Likes
No, in-app user preferences (not permissions, not PG preferences etc).

Didn't find a library to efficiently handle forms filled with preferences: save and restore preferences, build preferences form, retrieve changes etc.

What I guess I'm asking for is a forms manager for the purpose of managing user preferences, without jQuery and other bloat.

Right now I use my own rather static implementation, but it's not really scalable to let's say more than 10 settings.
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Since processes behind such preferences can vary over a great range, I don't believe you could standardize these easily.
For instance: does your app have user preferences for the app, for the user or for the device? What happens if the same user uses another device? What if two users use the same device? What happens to your preferences when you delete the app and later redownload and reinstall the same app?

The answers to these questions will be different for each type of app. A game and a banking app require very different preference architectures, where the question "do I store them locally or remotely" is just one aspect.

And then there are preferences which are dependent on the role of the user within a business app, and thus from all kinds of data and processes on a central business server application. Such apps are used - for instance - for traveling salesmen, who need to access product databases, client databases, logstic routing data and order uploads.
In several of my business apps, the part that handles user/role preferences (which configure parts of the workflows in the app) is a complex application in itself.
A recommendation for such processes would probably go way beyond a "starting tutorial for PGB".
Photo of Anders Borg

Anders Borg

  • 329 Posts
  • 12 Reply Likes
When talking preferences to control an app installation and not a user account (but it could easily support that as well) it's pretty much the same every time.

I've now written a generic option handler that's based on a data structure for handling different types of fields and creating the said fields, storing the data persistently etc. Just 100ish lines of code. Generic. Easy to use. It can be done :).

Here's the data that defines the preferences in my currently developed app:


var preferences = {
AuthorizationAlways:
{
title: "Authorization always",
type: "checkbox",
initial: false,
value: false
},
AllowDirect:
{
title: "Allow direct action",
type: "checkbox",
initial: true,
value: false
},
HistoryStorage:
{
title: "History storage",
type: "select",
options: ["none", "runtime", "persistent"],
initial: "runtime",
value: ""
},
HistoryPlace:
{
title: "History place",
type: "select",
options: ["top", "stay"],
initial: "top",
value: ""
}
};
Photo of Anders Borg

Anders Borg

  • 329 Posts
  • 12 Reply Likes
Proof is in the pudding. < 100 effective lines after cleaning up, without any static data except the above structure, handling persistent storage, dynamic update of settings, display of current value, defaults, easy access to values from logic etc. Time for coffee...

Photo of Anders Borg

Anders Borg

  • 329 Posts
  • 12 Reply Likes
It helps having developed CMSes :).
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Ah, OK. We obviously pictured quite different sets of preference structures.
Yes, this would certainly do for unconditional, one-dimensional preference options. Can easily be extended to server-side storage with account management, sync processes, etc.

Business apps will, however, probably require structures that go way beyond these. I would not include templates or even recommendations in a PGB tutorial.
Photo of Anders Borg

Anders Borg

  • 329 Posts
  • 12 Reply Likes
I know, but I often encounter that I need some options as users want it different ways. Very easy to set up this way. It supports checkboxes, selects/lists and text fields as of now.

Adding conditions (as in settings affecting visibility of other settings etc) would be easy.

E.g. I'm meeting with a potential reseller (not for this app specifically but for my overall offerings) that wants to make an evaluation using direct action and no history, in a very cramped demo room, while a real life case that we might be dealing with a few days later (best case) wouldn't work well with direct action (the user would be startled) and needs history, as that environment would have several overlapping beacons with different content, different proximity triggers etc.

Clearly I don't want to make any forks at this early stage. I want to be able to adjust behavior when I'm at the site.

The app is a small part of a content management system for mobile marketing.

On the other hand, e.g. my barcode reader has no settings at all. It just does what it does (arguably in an effective way), and I use it many times a day, so at least it's not completely off.
Photo of Anders Borg

Anders Borg

  • 329 Posts
  • 12 Reply Likes
Actually my barcode reader is the best I've found for specifically QR Codes, which might be slightly objective :).
Photo of Anders Borg

Anders Borg

  • 329 Posts
  • 12 Reply Likes
For your info (I'm not selling on a Sunday).

Photo of Anders Borg

Anders Borg

  • 329 Posts
  • 12 Reply Likes
So I understand: As you don't use remote build: Do you upload a ZIP every time you need to build?

Cheers,
Anders
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Correct.
In the ZIP file, I replace code files (html, css, js, png) that have changed. Then I upload the zip to the web portal and get my new builds, which I download by clicking the blue .apk and .ipa buttons.

That said, I don't need to build too often, because I test my html/js/css in a browser, first. Most new builds are therefore right-first-time and can be tested (in a test environment with a test backend and test database).
Then they need to be rebuilt with live certificates and a code variable set, so the app knows to get to the live database (web service), now.
[Oh, I would love to be able to read from within the app whether it's been signed with a test cert or a live cert. In that case, I wouldn't need to manually set a code variable and replace code files in the zip before rebuilding]
Photo of Anders Borg

Anders Borg

  • 329 Posts
  • 12 Reply Likes
We use PGB in very different ways, but I understand why you don't need to build so much.

As I always use phone functionality (right now finalizing my beacon app) testing in a browser doesn't work, and neither is the UI the complex part. Rather the beacon functionality that involves lots of filtering, timers, arrays of beacons, arrays of associations, arrays of beacon manufacturers etc. All logic, very little HTML etc, even though of course that's there as well. HTML I handle dynamically via innerHTML, so it's almost pure code and very little static markup.

phonegap remote build and installing directly in the phone via the PGB link therefore saves me lots of time.

Your point about switching between development and production environment would be eased with a Javascript file containing controlling constants. I always use that for the thing you mention, but also any other constants.

Also, you could handle this by using the version number in config.xml to control what server/database should be accessed. Just use a syntax like x.x.x for a dev version, x.x for a production version. Install e.g. net.bgta.phonegap.plugin.appversion and check the version in the app. At least you then only need to change config.xml, which you should do anyway.

Would that help?

Anders
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
I use Javascript constants now, yes. But the version scheme is interesting. I'll think it over. Thanks.
Photo of Anders Borg

Anders Borg

  • 329 Posts
  • 12 Reply Likes
What's your experience of getting apps approved by Apple when they are not using any phone features, or maybe don't even look like iOS8 apps?
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
No such experience, sorry. I have currently about twenty apps, and they all use geolocation, inappbrowser, camera and file upload, sometimes compass and contacts.

They all get approved immediately (well, 'immediately' to Apple's standards, which means at least 5 days), no problem. Just rejected once, when I mistakenly had the word "Android" in an Appstore description text. So, I only updated that meta information and everything was fine.