npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

adonis-fcm-notification-channel

v1.3.0

Published

The Adonis Firebase Notification Channel.

Downloads

13

Readme

Adonis Firebase Notification Channel

Build Status Coverage Status

Firebase Notification Channel for adonis-notifications.

Installation

  1. Add package:
$ npm i adonis-fcm-notification-channel --save

or

$ yarn add adonis-fcm-notification-channel
  1. Register providers inside the your start/app.js file.
const providers = [
  ...
  'adonis-fcm-notification-channel/providers/FcmNotificationChannelProvider',
  ...
]
  1. Add configuration to config/services.js file.
...
fcm: {
  apiKey: <YOUR API KEY>,
  // optional
  requestOptions: {
    proxy: 'http://127.0.0.1:8888',
    timeout: 5000
  }
}
...

See node-gcm for more information.

Usage example

// app/Model/User.js
'use strict'

const Lucid = use('Lucid')

class User extends Lucid {
  static get traits () {
    return [
      '@provider:Morphable',
      '@provider:HasDatabaseNotifications',
      '@provider:Notifiable'
    ]
  }

  // array, promise or generator
  routeNotificationForFcm () {
    return ['token1', 'token2', ... ]
  }
}

module.exports = User
// app/Notifications/FcmNotification.js
'use strict'

const FcmMessage = use('FcmMessage')

class MyNotification {
  via () {
    return ['fcm']
  }

  toFcm () {
    // from object
    const message = new FcmMessage({
      collapse_key: 'demo',
      priority: 'high',
      content_available: true,
      delay_while_idle: true,
      time_to_live: 3,
      restricted_package_name: 'somePackageName',
      dry_run: true,
      data: {
        key1: 'message1',
        key2: 'message2'
      },
      notification: {
        title: 'Hello, World',
        icon: 'ic_launcher',
        body: 'This is a notification that will be displayed if your app is in the background.',
        sound: 'test_sound',
        badge: 'test_badge',
        tag: 'test_tag',
        color: 'test_color',
        click_action: 'test_click_action',
        body_loc_key: 'test_body_loc_key',
        body_loc_args: '["body0","body1"]',
        title_loc_key: 'test_title_loc_key',
        title_loc_args: '["title0","title1"]'
      }
    })
    // using fluent api
    message
      .setCollapseKey('demo')
      .setPriority('high')
      .setContentAvailable(true)
      .setDelayWhileIdle(true)
      .setTimeToLive(3)
      .setRestrictedPackageName('somePackageName')
      .setDryRun(true)
      .setData({
        key1: 'message1',
        key2: 'message2'
      })
      .setTitle('Hello, World')
      .setIcon('ic_launcher')
      .setBody('This is a notification that will be displayed if your app is in the background.')
      .setSound('test_sound')
      .setBadge('test_badge')
      .setTag('test_tag')
      .setColor('test_color')
      .setClickAction('test_click_action')
      .setBodyLocKey('test_body_loc_key')
      .setBodyLocArgs(['body0', 'body1'])
      .setTitleLocKey('test_title_loc_key')
      .setTitleLocArgs(['title0', 'title1'])
    // using setters
    message.collapseKey = 'demo'
    message.priority = 'high'
    message.contentAvailable = true
    message.delayWhileIdle = true
    message.timeToLive = 3
    message.restrictedPackageName = 'somePackageName'
    message.dryRun = true
    message.data = {
      key1: 'message1',
      key2: 'message2'
    }
    message.title = 'Hello, World'
    message.icon = 'ic_launcher'
    message.body = 'This is a notification that will be displayed if your app is in the background.'
    message.sound = 'test_sound'
    message.badge = 'test_badge'
    message.tag = 'test_tag'
    message.color = 'test_color'
    message.clickAction = 'test_click_action'
    message.bodyLocKey = 'test_body_loc_key'
    message.bodyLocArgs = ['body0', 'body1']
    message.titleLocKey = 'test_title_loc_key'
    message.titleLocArgs = ['title0', 'title1']
    // you can set up configuration for current notification
    // using configure method
    message.configure({
      apiKey: '<YOUR API KEY>,
      // optional
      requestOptions: {
        proxy: 'http://127.0.0.1:8888',
        timeout: 5000
      }
    })
    // or setters
    message
      .setApiKey('<YOUR API KEY>')
      .setRequestOptions({
        proxy: 'http://127.0.0.1:8888',
        timeout: 5000
      })
    message.apiKey = '<YOUR API KEY>'
    message.requestOptions = {
      proxy: 'http://127.0.0.1:8888',
      timeout: 5000
    }
    return message
  }
}

module.exports = MyNotification

or

// app/Notifications/FcmNotification.js
'use strict'

class MyNotification {
  via () {
    return ['fcm']
  }

  toJSON () {
    return {
      collapse_key: 'demo',
      priority: 'high',
      content_available: true,
      delay_while_idle: true,
      time_to_live: 3,
      restricted_package_name: 'somePackageName',
      dry_run: true,
      data: {
        key1: 'message1',
        key2: 'message2'
      },
      notification: {
        title: 'Hello, World',
        icon: 'ic_launcher',
        body: 'This is a notification that will be displayed if your app is in the background.',
        sound: 'test_sound',
        badge: 'test_badge',
        tag: 'test_tag',
        color: 'test_color',
        click_action: 'test_click_action',
        body_loc_key: 'test_body_loc_key',
        body_loc_args: '["body0","body1"]',
        title_loc_key: 'test_title_loc_key',
        title_loc_args: '["title0","title1"]'
      }
    }
  }
}

module.exports = MyNotification

Credits

Support

Having trouble? Open an issue!

License

The MIT License (MIT). Please see License File for more information.