Interests

Beams uses a Publish/Subscribe model for a feature called Interests to decide which devices should get which messages.

These subscriptions allow you to filter and control which people receive your push notifications. You subscribe your devices to interests and your servers can then publish push notifications to those interests. Only the devices subscribed to one of the specified interests will receive the notification.

Subscribing

If you want a device to receive a push notification sent to a particular interest you can call the subscribe method in the SDK, passing in the interest name.

iOS

1
2
3
4
5
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
  self.pushNotifications.registerDeviceToken(deviceToken) {
    try? self.pushNotifications.subscribe(interest: "hello")
  }
}

Android

1
2
PushNotifications.start(this, "YOUR_INSTANCE_ID_HERE");
PushNotifications.subscribe("hello");

This device has now subscribed to that interest and will receive push notifications published to that interest via the Publish API.

A device can be subscribed to a maximum of 5000 interests.

Interest names are limited to 164 characters and can only contain ASCII upper/lower-case letters, numbers or one of _-=@,.;.

Publishing

Once you have devices subscribed to various interests you can send push notifications to them via the Publish API either directly or by using one of our server SDKs.

Each publish requires at least one interest, up to a maximum of 100.

  • PHP
  • HTTP
  • Go
  • Node.js
  • Python
  • Java
  • Kotlin
  • Ruby
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php
include 'src/PushNotifications.php';
$publishResponse = $pushNotifications->publish(
  array("hello", "donuts"),
  array(
    "fcm" => array(
      "notification" => array(
        "title" => "Hi!",
        "body" => "This is my first Push Notification!"
      )
    ),
    "apns" => array("aps" => array(
      "alert" => array(
        "title" => "Hi!",
        "body" => "This is my first Push Notification!"
      )
    ))
));

Did you find this document useful?

We are always striving to create the most accurate and informative docs as possible. If there is something especially wrong (or right) here then please let us know.