This tutorial will show you how you can retrieve a list of push messages from the AppMachine API and display them in a "GET" webservice block.
Displaying the push messages in a custom List block will allow you to further customize the look and feel of your app, as the default Push Message block does not allow much customization.
Note: This method does not take the push message categories into account. The list retrieves all push messages unless you send along the category ID in the input parameters of the webservice call.
Gathering the required data from your "Developer Access" screen
- The first step you'll need to take is copying the Application and Client keys from your Developer Access screen and paste them somewhere in a notepad app of your choosing:
- Then, you'll want to scroll down on the same page and click on the "PushNotification" section of the AppMachine API screen:
- Click on the first option, "GET" /v1/pushnotification - which will allow you to perform a test call to the AppMachine push API:
- Scrolling down will reveal a couple of fields that you can now fill in to perform the test call. Fill in all the fields with your Client and App Keys and select the following values in the dropdown fields:
- Scroll down a bit, and perform the test call by hitting the "Try it out!" button. This should present you with a list of all the previously sent push messages, as well as the planned messages:
- Now that you know the call is working, copy the "Request URL" from the results as well. You'll need this to create the "GET" webservice block.
Creating the "GET" webservice block
- The next step is to add a Webservice block. Click the "+ Block" button, choose "Pro", select the "Webservice" block and hit "Add block".
- Choose "Custom webservice":
- In the URL field you can fill in the URL that you've retrieved from the test call results. It'll automatically fill in the correct "Query" parameters, but we're not done here so don't continue to the next screen just yet:
- The next step is to click on the "Headers" tab on the same screen. Fill in the following fields and paste your Client and App Keys in the correct fields:
- Click on the "GO" Button, and finish up the creation of your "GET" webservice block. You'll be able to give your webservice a name, and the block as well.
- As extra step you can add the following filter expression to the advanced settings of your List block to make sure the block only shows the messages that were delivered: isDelivered = "True"
This will leave out the planned messages.
Designing your List
You'll be able to make all sorts of changes to the look and feel of the List block you've just created. You can disable the Screen (Info) block, as it doesn't really serve a function, unless you want to keep the items from the list clickable.
For tips and tricks regarding designing your blocks with the layout editor, you can check out other tutorials like:
1. Design your screen with the Layout Editor - For a general explanation on how to use the Layout Editor.
2. Layout Editor Tips & Tricks - For a more in-depth look at some more advanced features of the Layout Editor.
3. Manipulate data presentation - Tips on how to change the date/time format shown in data retrieved from an external datasource such as webservices and Excel files.
Questions can be sent to email@example.com