Receiving SMS messages into your app (Android)

You can now receive incoming SMS messages (text messages) on Android devices, using the sms-receive plugin.

It does not intercept them – the messages still go to the Messages app. It only works if your app is compiled under PhoneGap.

Your app doesn’t have to be in the foreground – it will received the messages so long as it has been started. The received message is available as variable in your app – so you can use it to update databases, inform the user or all kinds of things.

Full details are in this Tech Note:

Using the Safari View Controller with PhoneGap

To be approved in the iTunes Store, Apple may require that your app open web pages inside your app, instead of opening Safari externally in another app window. It provides a better experience to the user.

When you open Safari in a new app window, it’s difficult to get back to your app. By using the Safari View Controller inside your app, switching to Safari is seamless – there is even a Done button to return to your app. Your users will thank you.

Title bar of a Safari View Controller. Note the Done button and the customized color.

There’s a handy PhoneGap plugin which makes this easy. Here’s how to use it:
Continue reading “Using the Safari View Controller with PhoneGap”

PhoneGap: Don’t overwrite the iOS Status Bar

If you’ve created a PhoneGap version of your project, the top of your screen might look like this on iOS:
Screen Shot 2016-04-26 at 11.36.57 AM

See how the title of the screen (“Volt”) is crowded into the status bar?

It’s easy to fix this. Add the following lines into configxml in Project Properties (PhoneGap section):

<plugin name="cordova-plugin-statusbar" source="npm" />
  <preference name="StatusBarOverlaysWebView" value="false" />
  <preference name="StatusBarBackgroundColor" value="#000000" />
  <preference name="StatusBarStyle" value="lightcontent" />

Your app will now look like this:
Screen Shot 2016-04-26 at 11.36.37 AM

With the StatusBar plugin installed, you have a bunch of additional options for managing the status bar. See the full documentation here.

PhoneGap: Getting rid of the Content-Security-Policy warning

I was messing around with a PhoneGap app using the Chrome Debugger’s Inspect feature, which lets me examine a running PhoneGap app for error messages, source code, elements, etc. I noticed an error message in the console I hadn’t seen before:

No Content-Security-Policy meta tag found. Please add one 
when using the cordova-plugin-whitelist plugin.

Continue reading “PhoneGap: Getting rid of the Content-Security-Policy warning”

PhoneGap: Change to configxml for SplashScreens

(This blog posted was updated with additional information on Oct 23, 2015, Thanks, Vagner!)

The recent updates to PhoneGap have resulted in another change being needed to your configxml.

In Project Properties, add these lines anywhere in the middle of PhoneGap configxml:

<gap:plugin name="cordova-plugin-splashscreen" source="npm" />
<preference name="AutoHideSplashScreen" value="true" />

Without this, your splashscreens will not appear.

PhoneGap: Important change to configxml WhiteList

If your PhoneGap app accesses external websites, there is an important change you need to make to your configxml Project Property.

Make the the following lines are in your configxml:

<gap:plugin name="cordova-plugin-whitelist" source="npm" />
<allow-navigation href="*" />
<access origin="*" />

The change seems to be a result of PhoneGap switching to npm to store its plugins. Be sure to read this blog post for more information on the change.

Edited 05/18/2016: Added allow-navigation line. It’s recommended that the href argument be as specific as possible. More information here:

PhoneGap Build: iOS 9 support delayed

The PhoneGap team posted the following to their blog yesterday:

iOS 9 is not officially supported yet, and there are some known issues. The Cordova open-source project team is hard at work on Cordova iOS 4.0, which will include iOS 9 support. For loads of helpful Cordova iOS news, keep an eye on Shazron’s blog, as well as the Apache Cordova blog.

Some of the problems notes by users on the PhoneGap Build Support forum are:

  • Scaling is wrong – elements are the wrong size.
  • System bars are wrong size.
  • In app browser issues

In the meantime, PhoneGap advises using the latest version (if you don’t specify “phonegap-version” configxml, the latest version will always be used) and to use the npm plugins (see this blog post!)

PhoneGap Build: npm plugins

PhoneGap Build is changing how they organize their plugins. You will need to make some changes to configxml in Project Properties as a result.

For each PhoneGap plugin you use, you need to add a line to configxml which declares the name of the plugin. PhoneGap Build can then add it to your app. These used to be saved in a folder on PhoneGap’s servers: they are now stored in an npm repository.
Continue reading “PhoneGap Build: npm plugins”

Google Play Store notice for PhoneGap apps

Recently, a number of users with AppStudio apps in the Google Play Store got this notification:

This is a notification that your {name of app), is built on a version of Apache Cordova that contains security vulnerabilities. This includes a high severity cross-application scripting (XAS) vulnerability. Under certain circumstances, vulnerable apps could be remotely exploited to steal sensitive information, such as user login credentials.

You should upgrade to Apache Cordova 3.5.1 or higher as soon as possible. For more information about the vulnerabilities, and for guidance on upgrading Apache Cordova, please see announcements/2014/08/04/android-351.html.

Please note, applications with vulnerabilities that expose users to risk of compromise may be considered “dangerous products” and subject to removal from Google Play.

To fix this, you have to update your project to use the current version of PhoneGap. Go into your Project Properties and edit ‘PhoneGap config.xml’. It will have a line like this – edit it to use Version 3.6.3 (or later – use the current version).

  "<preference name=\"phonegap-version\" value=\"3.6.3\" />",

You will then need to resubmit your app to PhoneGap Build. Use the resulting build to update your app in the Google Play Store.

Add cool stuff to AppStudio!

AppStudio comes with a lot of stuff built into it. But people are always inventing more: when we designed AppStudio, we made it extensible. Here is a general guide for adding cool features into AppStudio:

  1. JavaScript API: Look for a JavaScript API or library. If there is one, it will be fairly easy to use from AppStudio.
  2. PhoneGap is used when the needed functionality is only in native code. Check first if there is an official PhoneGap plugin that does what you need. It’s good news if there is – you can use the relatively easy PhoneGap Build service from AppStudio’s Run menu.
  3. Third party PhoneGap Plugin: These will work from AppStudio, but you will need to compile your app using the PhoneGap SDK. That means downloading and configuring the SDK for iOS and Android. Here are a couple of tech notes to get you started:
  4. Write your own PhoneGap Plugin: If the above solutions don’t help, you’ll need to write your own plug in. You will need to use Java and the Android SDK for Android, Objective C and XCode for iOS.

Let us know if you find something cool that works with AppStudio!

PS. If you need help developing a PhoneGap plugin, let us know. We can create plugins on a contract basis.