PRE-REQUISITES

For the following code examples to work, you will need to add the fliplet-notifications library to your app. To add it follow these steps:

  1. When in Fliplet Studio’s Edit screen, open the Developer Options from the right hand menu
  2. With the Developer Options open, click the Libraries button in the top right corner
  3. In the search field, type in ‘fliplet-notifications’
  4. Click it to add it to the list
  5. Click Save

If you’re sending a notification using Fliplet Studio then it will appear in a recipient’s notification inbox component automatically. However, if you’re sending a notification via code you’ll need to add the following code.

First you need to add the Fliplet Notifications API.

var instance = Fliplet.Notifications.init({});

You can then use the ‘instance’ to send a message to the inbox to all users registered to receive them.

instance.insert({
  status: 'published',
  data: {
    title: 'Fliplet notifications',
    message: 'Hi Everyone!',
    navigate: {
      action: 'screen',
      page: 12345,
      transition: 'fade'
    }
  }
});

You may also send a notification to specific group of users (or a single user) by specifying their email (the same that is used when they log in to the app):

instance.insert({
  status: 'published',
  data: {
    title: 'Fliplet notifications',
    message: 'Hi John!'
  },
  scope: {
    email: {
      $in: ["john@example.org", "jane@example.org"]
    }
  }
});

For more examples and options refer to this article.

Was this article helpful?
YesNo