How to Integrate Push and Local Notification
Before integrating push and local notifications the first question is what is the difference between the two?
Local notifications are the ones that a user sets up in-app for e.g. they set up a reminder. These notifications are stored in the app itself, in the SQLite database.
Push notifications lets your application notify a user of new messages or events even when the user is not actively using your application.
In configure.it there are two different types of database- one is the MySQL database, and the second is the SQLite database. MySQL database is the remote database that is stored on the server and the SQLite database is stored on the device within the app. To use local notifications, we have to use SQLite database.
To set up notifications, the fundamentals of setting up tables and APIs are the same, you only have to go to a different part of the backend.
To set up local notifications, fill in the necessary fields. The format of the notification is important because you will to have to supply this format to the actual API, so that it knows how to parse out the different data.
In case you have to set for two formats, you can copy the selected format so that it’s already set up when you start creating the API.
Next, create a table and fill in the fields as created in the app and then head to create an API. Add a new API and name it, then fill in the parameters, click next and configure the API flow. Then, you make an insert query and select a query block. Select the field and select the parameters, change the query block name if needed, and then click save.
To check if the query did insert the data, add a condition block then select the flow and insert reminder which should equal success. Insert to the right, a local notification and once the query has returned successful then you can go ahead and do a local notification. Configure the same in the variable section where you can pass additional variables along with the alert and hit save. Then, add your finish blocks and close off condition box.
Refresh and test your API by clicking on ‘debug’ and you should have a success. You can verify this by having a look at the table and on hitting refresh, you will see the record. You can then add this data source to your app. Go back to the layout and add data source, then choose the API and assign the values and click save.
To fire your datasource, click on action and then on API, then select the local datasource and click on save.
To enable user interactions, click on notification and select ‘add notifications’, then select local notification and user and click save. To add an event, click on ‘add event’ and select the push notification view where you can provide a sort of action from the list for the user, click save.
To provide a way for the user to stop the notification, add an additional API, call it for e.g. ‘delete reminder’, select next and add local notification block and under ‘type’ select ‘delete’. Select the parameters and click ‘same’. After that, add a finish block and success, then, add a message block and save. Add it to your app, close the notification and add data source, choose the API ‘delete reminder’ and click save, then add another button, clone it and click ok. The action will change from ‘add’ to ‘delete reminder’. To provide some sort of confirmation, add an event to the data source and click on data source loaded, and then define the action. This alert will be a response with a message according to the condition.
Download the project to the preview app and see if the local alert notification is working.
To configure API for a push notification, add API and fill in the required fields and the input parameters. To retrieve product information select query block, rename it and hit next. Choose the field you want to return to and save. Now choose the product info and save. Click on push notification and fill in the details, message and variables along with adding a finish block and type in a message. Once you have your push notification configured test it out, put in a device token and select ‘debug’ and you should receive a successful message sent.
For configurations in the admin panel, click over to the admin panel, and the first configuration needed to add is ‘Push notification PEM file’. A PEM file is a unique file created by Apple that is unique to each application. To create a PEM file you can visit www.apptuitions.com/generate-pem-file-for-puch-notification/ Once the PEM file is created, load it to configure.it.
For android you will need a GCM key which is a Google Cloud Messager key, which you will have to fill in the listed field. To generate GCM key go to www.developers.google.com/cloud-messaging/gcm
Once you have the keys and PEM file installed- click on send mode, one is for sandbox one is for live. Keys will be different for each mode. Fill in the Push notification send mode, ‘type’ and ‘limit’ and then hit save.
On Configure.it, integration of push and local notifications have been made as simple as possible for the user. The entire process has been explained step by step through a video tutorial for your ease.