Tutorials

Easy to understand tutorials made for you, by us.

SIGN UP FOR FREE

How to send push notifications

With the Silverstreet Push API you can send push notifications to the installed versions of your mobile app. For sending the push notifications our platform uses Google Firebase currently. In this step-by-step guide we will explain you what to do to integrate our API.

Before you can use our Push API to send push notifications, please check our tutorial ‘How to configure a Firebase supplier for the Push API‘.

How does it work?

When you develop a mobile app, you have to register each app with Firebase. Check this article how to do that. For each installed app you will have a firebase id. This is the push id you can use to send push notifications via our Push API.

  1. A user installs your app.
  2. The app registers with Firebase Cloud Messaging.
  3. Firebase returns a registration token.
  4. The registration token is the push id you have to use to send push messages via our Push API.

When you have the Firebase id of the installed app, store it in our Address Book API. Please note that it is best practice to do this from a backend and not directly from the mobile app. Reason is that you would need to configure the Address Book API key in your mobile app. And hackers will be able to retrieve it from there and use your key to get your contacts. Also when you have to update the API key, all users who installed your app have to update to a new version of the app. See also our article ‘API key best practices‘.

The data you have to send as push notification depends on your app and what kind of push notifications you want to send. Find out more on what data you want to send here.

To send a push notification via our Push API:


<?php
$pushId = ''; //push id returned by Firebase generated during installation
$data = array(
//set your application data here
'text' => 'Hello world'
);
$push = array(
'to' => $pushId,
'notification' => [
'title' => 'Your app name' ,
'body' => 'Your notification text',
'sound'=> 'default'
],
'priority' => 'normal',
'ttl' => 60,
'data' => $data,
);
$push = $client->createPush($push);
?>