Launching Server Code With Jobs Scheduler

Have you ever needed to perform operations in a certain time interval? For example – have you ever needed to check database records, and then based on specific conditions, send an appropriate push notification?

server-code 

Some parts of this can be done via client-side code, but there is no guarantee that the user’s device will be online at the right time. The solution to this lies in one of Appery.io’s great backend features, Server Code.  If you aren’t familiar with it yet, here is a quick tip: Server Code enables custom and scalable business logic in the Appery.io cloud without the need to build and maintain server infrastructure. And one of the server code features is the jobs scheduler.

All of the scheduling logic can be found in a separate Jobs tab:

jobs

You will see schedule builder if you open it:

schedule_builder

The basics of working with the jobs scheduler is simple – you choose the script that should be executed at a certain time or time interval. Then you should specify that time or interval. This can be done in two ways: by using the schedule builder or by using the Schedule expression:

schedule_expression

Unlike the schedule builder where you simply need to select the needed parameters by choosing them from comboboxes, the Schedule expression retrieves values based on Quartz. Note one important thing – the Appery.io job scheduler doesn’t use a seconds parameter in Cron expressions. So, if you use an expression such as 0 0/5 * * * ? you’ll get an error. Remove the first number (zero in this case) and the expression will be correct – 0/5 * * * ? .

The minimum interval between script invocation is based on your plan. See our pricing to learn more.

All of your scheduled scripts are displayed at the bottom of the page:

scheduled_jobs

If you no longer need to execute some of your scripts, turn them off by toggling the on/off button or delete it by clicking the cross icon.

Generally, that’s all you need to start scheduling your scripts. Simple, isn’t it? Here is detailed documentation about the Server Code jobs scheduler in case you’re stuck somewhere. Or get touch with us via forum or email to get our help. Happy coding!

 

New Mapping

Update (May 27): links were unlinked as this content not currently available.

Appery.io developers: we just upgraded the mapping feature in Appery.io! It’s now a lot more powerful and flexible.  This post is a quick overview of what has changed. The two links (Mapping, Model and Storage) provide more details on the new features. Read this post and then visit the links to learn more.

  • Mapping
  • Model and Storage

Old mapping

This is how the old mapping looked. This shows a data source (service) has been added to the page:

Screen Shot 2014-05-24 at 10.50.02 PM

Clicking on Edit Mapping, would open the service request mapping:

Screen Shot 2014-05-24 at 10.54.00 PM

and this is service response mapping:

Screen Shot 2014-05-24 at 10.54.17 PM

New service events and mapping

The new mapping is a lot more flexible and greatly simplifies building mobile apps in Appery.io. When you switch to Data view, a data source will now be shown like this. Make sure to click the expand arrow on the left to see the data source events:

Screen Shot 2014-05-24 at 10.57.04 PM

The mapping in Before send event and in Success event – that’s the exact the same old mapping Appery.io had before and the one you are used to. When a service was invoked, the request mapping would happen on Before send event and response mapping would happen on Success event.

As you can see what we have now is a lot more flexible. In addition to doing mapping, you can now also run any other action (click +Add button to see the actions), plus Run JavaScript which allows you to run any custom script. Plus, you can invoke any action on Error and Complete events. You can even run the new Mapping action on those events!

New Mapping action

The new Mapping action allows you to invoke mapping on any event, not just on service invocation (last in the list):

Screen Shot 2014-05-24 at 11.08.13 PM

The new Mapping action can also be invoked from the UI:

Screen Shot 2014-05-24 at 11.22.07 PM

For example, on button click, you can move data from page to storage, or from storage to page:

Screen Shot 2014-05-24 at 11.24.24 PM

Mapping: page, service, storage

The mapping is no longer limited to service-page mapping. You can now map data between page, service and storage. This is where the new Mapping actions comes into play. Before you could only map between page and service. Now you can map between page and storage (local storage, session storage). In other words, you can map data from page into storage, or move map data from storage to page. Here is how the new mapping looks:

Screen Shot 2014-05-24 at 11.18.17 PM

Notice that on the left side there are: Page and Storage. On the right side there are: Page, Storage, and Service Request. With the new mapping, we have simplified mapping between Page, Storage and Service.

Documentation

Please read the following pages that explain in more detail the new features:

  • Mapping
  • Model and Storage

 

 

App Owners Can Now Manage App Data and Send Push Notifications from User-Friendly Customer Console [Video]

This video shows how to build a mobile app and enable the Customer Console. The Customer Console allows an app owner who, (for example) owns a restaurant, or some other business, to:

  • Modify app data
  • Send push notifications to all app users
  • No need to ask or involve the app developer
  • Deploy the console to appery.io URL or a custom domain such as http://mybusinessname.com

Read more about the Customer Console.

Using Google Maps API in Appery.io App

Google Maps is probably the most popular map widget used in the mobile apps today. Working with Google Maps in Appery.io app builder is very easy but as the same time is not very different than using other dev. tools. To add a Map component, simply drag and drop it from the palette onto the page:

google_maps_api

Rename the Map component to google_map. This is done so it’s simpler to reference the component from code.

Next you can create your own JavaScript class and define map variable as following:

var map;
function initialize() {
    map = Apperyio("google_map").gmap;
    if (!map)
    {
        setDelay();
    }
    else
    {
        directionsDisplay = new google.maps.DirectionsRenderer();
    }
}

function setDelay()
{
    setTimeout(initialize, 50);
}

Google Maps is usually loaded asynchronously, so the approach with delay (as mentioned in code above) can be handy. This will ensure the map is completely loaded before you try to use it.

Generally that’s all you need to use Google Maps JavaScript API. All the actions you want to do next you can make based on Google Maps JavaScript API. Lets say you want to show direction from point A to point B. Place the button on the page and run following JavaScript by clicking on it:

var directionsDisplay = new google.maps.DirectionsRenderer();
var directionsService = new google.maps.DirectionsService();

var request = {
origin: 'Los Angeles',
destination: 'San Francisco',
travelMode: google.maps.DirectionsTravelMode.DRIVING
};
directionsService.route(request, function(response, status) {
directionsDisplay.setMap(map);
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
}
else
{
alert("Directions query unsuccessful. Response status: " + status);
}
});

The directions will be shown on the map:

google_map_directions

To place the marker on the map you should provide latitude and longitude values of a certain point. Try to run following JavaScript code and you’ll see how the marker drop on the map:

var markerLatLng = new google.maps.LatLng(37.913597,-122.066059);

var marker = new google.maps.Marker({
    position: markerLatLng,
    map: map,
    title: "Walnut Creek, CA",
    animation: google.maps.Animation.DROP
});

added_marker

You can also place markers based on geographical names, not latitude and longitude. In this case you should use Google Geocoding services, to convert user-friendly names to latitude and longitude values. Create a REST service in the app builder with the following URL:

https://maps.googleapis.com/maps/api/geocode/json

You’ll get a coordinates (latitude/longitude) as a response of this service, and you of course can use them to add markers.

Any layers provided by Google Maps can be added too. Here is an example for Traffic layer, just run this code by clicking on the button:

var trafficLayer = new google.maps.TrafficLayer();
trafficLayer.setMap(map);

Traffic layer in action:
traffic_layer

As you can see using Google Maps and its API is very straightforward in Appery.io app builder. Check out our Google Maps section for more detailed tutorials.

Building a GPS tracking app with Appery.io

Many mobile apps use GPS sensors to track a user’s current location. For example, it could be a ride sharing app, fitness app, or a delivery app. This post shows how to build such an app in Appery.io. The app tracks your current location via  the device’s GPS sensor and stores the location into a database.

This is the app UI:

gps_app_view

 

The GPS location is determined every 15 seconds (you can change the interval). The location is shown in the app and also saved into a cloud database. Because this is a native app (with PhoneGap), the app will continue tracking the location even if in the background or with the phone screen locked.

To try this app, download the app backup and create a new app from it. Keep in mind that you do need to build a binary file and install it on the device for testing.

Now you just need to configure the settings service with the correct database ID. This app uses a pretty simple database; it contains one collection with name Locations. This collection contains one column location with type of Geo point:

gps_app_collection_structure

Open the GPSLocationTracking_settings file and change the database_id to your own.

Once the database ID is changed in the settings file, the application is ready to go.

Let’s take a quick look how the app works:

1. The GPS service starts initially after the Device ready event and runs every 15 seconds.

Here is the JavaScript code:

gps_app_device_ready

2. You can also change how often the GPS will run. To apply a new interval, first stop tracking, and then start it again:

gps_app_new_interval

3. In the case that the GPS fails to determine the location, an error message will be shown:

gps_app_save_failed

4. Every time a new GPS location is retrieved, the location is saved into a cloud database:

gps_app_store_location

This is a starter app that uses the GPS sensor to track your current location. It’s very easy to add more features. For instance, you can add Google Reverse Geocoding service to get the address of a place. Or, you could also show all locations on a map.

If you want more practice, try the Building a mobile app with Google Maps and Geolocation tutorial.

Quickly send push notifications with Appery.io backend services

Push notifications. It is a great way to inform app users about cool offers, important events or any updates. It’s an important feature for enterprise mobile apps. For instance, a sales manager can be instantly notified when an existing customer upgrades his/her plan.  Push notifications are a powerful tool to ensure your message is received and read by the user, even when they are not using your app.

push_notification

Appery.io provides fast and easy way to send the push notifications for both platforms – iOS and Android. Sending can be done in just a few steps:

  1. Enable push notifications in the application settings.
  2. Register the application with Apple or Google services.
  3. Install the app on the device. When it’s done, device information will be automatically added to your predefined devices collection.
  4. Send notifications from the console. That it!

You can send these alerts:

  1. Instantly
  2. Schedule
  3. Deliver in device’s time zone

The first two options, all the users will receive the message simultaneously. For instance, for some users it could be 8 AM, and for other users it could be 1 PM.

In the third case of the device time zone sending, users will receive the notifications in a different time – someone later and someone sooner.

Having all three options — is what makes Appery.io push easy to use, yet very powerful, and customizable.

You are not limited to sending push notifications from the push console. With push REST API, you can enable sending messages from any app.

Want to learn more? Head to our push docs or try the quick start push tutorial.

Test Your Mobile Apps Faster With Appery.io Tester for iOS (and Android)

One of the best ways to test your mobile app is on the device. This is a must if your app uses native (PhoneGap) API such as the Camera or the Barcode scanner. Installing the app on the device after every small update is very time consuming. That’s exactly why we built the Appery.io Tester app. It’s a very simple app that allows you to launch your native app and test any native APIs without needing to install it each time. We had the Android version for some time now and now we have also launched the iOS version.

Install the app on your device:

Install the iOS version.
Install the Android version

Once the app is installed, sign in with the same credentials as you use for https://appery.io and you will see a list of all your apps. Simply select the app you want to launch and start testing! This allows you quicly to test any native APIs used in the app. If you make any changes to the app (in Appery.io builder), simply relaunch the app to get the latest version. It’s that simple.

Appery_io_tester_ios

 

For more information about testing your app, please visit Testing your app in documentation.

Appery.io Adds Salesforce Integration and Much More – Check Out the Details

The latest Appery.io update packs some really awesome updates and features. Check them out here.

Fast

Everything now runs much faster. You will see major speed improvements when you open pages, services or any other editors in the app builder. It’s simply much faster. And, we are not done. We have plans to make the platform a lot more faster. Read the rest of this entry »

Appery.io Upgrades with Custom Server Code, Source Editing in the Cloud, App Versiong and New Salesforce API Plug-ins

We just released a number of really awesome features. Check them out!

Server Code

The new Server Code is being added to Appery.io integrated backend services that already includes a cloud Database and Push Notifications. The Server Code allows to write any custom app business logic using JavaScript without the need to build and maintain server infrastructure. The custom code is instantly exposed via REST API and can be quickly invoked from the app.

Selection_015

Source Code Editing

Ever since we launched Appery.io our users have been asking if the generated app source can be edited without leaving the platform. Now the answer is yes. Any app files can be edited in the cloud without leaving the platform. Simple switch to the Source tab to start using this new features. We are planning to add more features to source editing. For now, once you start editing the source files, the changes will not be reflected in the visual view yet.

Visual editor:

Selection_012

Source code editor for the same page:

Selection_013

App Versioning

Selection_011

Did you ever want to save a particular app version or roll back to a previous working version?? Now you can. We have introduced a new version feature. At any point you can quickly create an app version and continue development. At any point you can quickly roll back to any previous version of your app.

Salesforce API Plug-ins

Selection_016

We made it very simple to build mobile apps with Salesforce API with two new plug-ins:

  • Salesforce Contacts API Sample App
  • Salesforce oAuth API

Both plug-ins take care of connecting to Salesforce via oAuth2 so you can start using the API immediately. . The Contacts API Sample plug-in includes a ready-to-run app that allows viewing, and editing Salesforce contacts. Use the plug-ins to learn how to use Salesforce API or a starting point for your mobile app. View detailed documentation on how to import  and use the plug-ins.

Instant HTML5 Mobile App Hosting with Appery.io

If you are building a mobile web app in Appery.io, you can instantly host the app (give it a URL). Here is how. When you create an app, the default type is Mobile App (hybrid app with Apache Cordova). To host the app, first switch its type to Mobile Web by clicking on Hosting tab:

Selection_212

Click Change project type to mobile web button. You will now be able to use an Appery.io domain (app_name.app.appery.io) or a custom domain that you already registered.

Selection_213

Click Publish and your app will be published on the URL specified in 2-4 minutes. It’s that simple.