If you find any errors, typos or have general feedback, select the text and click CTRL+ALT+ENTER.

What are we going to build?

In this tutorial, you’ll learn how to build a mobile app that sends/retrieves push notifications.

Before you begin

  • Tutorial level: beginner; your first mobile app.
  • Prerequisites: an Appery.io account.

Creating a new app

From the Apps page in the builder, click Create new app, enter an app name, and click Create.

Configuring push

1. Open the Push Notifications tab from the Projects menu.

2. Check the Enable push notifications check box.

3. In the Push Settings section, check all the three items:

  1. Push sound.
  2. Show alert.
  3. Badge.

This means that all of the above will occur when a new push notification arrives. For example, checking the Push sound option will make a sound, and Badge will show the number of unread notifications.

Configuring the device

Depending on your device and OS, you’ll have to initialize Android settings, iOS settings, or both.

Android

The next steps show you how to use the Google Developers Console.

1. Go to https://code.google.com/apis/console/ and sign in.

2. Click Create Project.

3. Enter project name. For instance, ApperyIOPush:

4. Click Create; the project will now be listed:

5. Click on the project name to open its details:

6. Copy the Project Number to Sender ID in the push notifications Settings tab of your app:

7. To get the API key, on the left-hand side menu, click Products  & services and select API Manager:

8. You will see a long list of APIs. Find Google Cloud Messaging and click Enable. You will get the following message:

9. Click Go to Credentials.

10. In a window, that opens, click the API key link to open another window. CreateaNewKey

11. Click Server key, then click Create again to generate the API Key:

12. Copy the API key to the  API key field in the push notifications Settings tab of the app:

That’s it for Android configuration.

iOS

To enable push notifications for an iOS app, you must have a Development Certificate if your app is registered in Development mode, and a Production Certificate if your app is registered in Distribution mode.

  1. Open Pages > startScreen and open the Push tab. Check Production, if the application is in the Distribute stage, otherwise leave it unchecked.
  2. Upload a Push Certification file in Apple Developer portal.
  3. For generating a Push Notification Certificate, you need to open the App Ids page, find the desired App ID, click Configure, and check the Enable for Apple Push Notification service checkbox. Then, click Configure (select either Development or Production stage):
  4. Fill the Certificate password that was specified during p12 certificate creation.

That’s it for iOS configuration.

  • The Bundle ID shouldn’t have a wild card character, otherwise you can’t configure push notification properties.
  • After you have defined the push settings, save the project and check whether the push data was saved correctly.

Linking to the database

1. From the app builder, click Push:
Database

A new page will open; you’ll see your project (or a list of projects, if you have more than one push app):
Statistics

2. You’ll be given the ability to link your app to the database:
SelectDatabase

Information about the devices on which the app is installed will be saved in the Devices collection of the selected database, as soon as the device is running the app. If you don’t have a database, create one (see Databases to learn how) and then link the app to it. You only need to link your app with the database once. As soon as they’re linked, the app will open upon clicking Open.

3. If your database is empty, you’ll see a warning message:

Once the database obtains the registered devices’ data, you can send push notifications.

To learn more about how to register devices, please see this section.

Sending push notifications

To send the notification to the channel:

1. On the Push Notifications tab, choose Settings. Click Reset to generate the Push API key:
ResetPushAPI

2. Go to the Send push notification tab, set the Expiration date for your push (if necessary) and select the devices. You can select all devices, or use a query string or query builder (for more information read push overview).

3. Specify the Sound file to be sent with the push (read here for how to set a custom sound alert), define the Badge and Title for your push (Badge – the number shown with app icon, only in iOS. These are optional parameters; for example, if the Badge field is empty, the badge will not be changed on a device).

4. Lastly, enter some Message:

5. Click Send.

5. Switch to the Scheduled and history view. You’ll find information about the delivered/undelivered and planned-for messages:

If everything was configured properly, and the device where the app was installed is connected to internet, the push notification will be delivered:
app_view

You can find detailed documentation about push notifications here.