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

ember-cli-cordova-shims

v0.3.0

Published

Makes it simple to use a range of different Cordova plugins.

Downloads

2

Readme

Ember CLI Cordova Shims

This Ember addon makes it simple to use a range of different Cordova plugins.

Supported features

Push Notifications

Dependencies:

  • cordova plugin add org.apache.cordova.device
  • cordova plugin add https://github.com/phonegap-build/PushPlugin.git

Automatic behavior:

  • Badge count will be set on the application on incoming notification
  • Sounds will play on incoming notification (if set in the payload)

Events:

  • alert - passes the message in the notification
  • badge - passes a badge count with every emitted event
  • sound - passes the filename of the sound to play

Public Methods:

  • register - Prompts the user to allow notifications to this device
  • unregister - Revokes notification subscription for this device

Usage:

// app/initializers/pushplugin.js
import NotificationsService from 'ember-cli-cordova-shims/services/notifications';

export function initialize(container, application) {
  let service = NotificationsService.create({
    gcmSenderId: '{INSERT-KEY-FROM-GCM-HERE}',
    gcmTimeout: 10000 // Timeout for GCM in ms. Default: 15000
  });
  application.register('service:notifications', service, {
    instantiate: false
  });
  application.inject('route', 'notifications', 'service:notifications');
}

export default {
  name: 'notifications-service',
  initialize: initialize
};
// app/routes/application.js
import Em from 'ember';

export default Em.Route.extend({

  badge: 0,

  listenForNotifications: function(){
    this.notifications.on('alert', function(message){
      alert(message); // or do whatever you want
    });
    this.notifications.on('badge', (badgeCount) => {
      this.set('badge', badgeCount); // or do whatever you want
    });
  }.on('init'),

  actions: {
    subscribeForNotifications: function(){
      let store = this.store;

      this.notifications.register().then(function(data){
        let network = data.network,
              token = data.token;
        return store.createRecord('device', {
          network: network,
          token: token
        }).save();
      }).then(function(deviceModelFromStore){
        Em.Logger.info('Successfully registered for notifications');
      }).catch(function(error){
        Em.Logger.error('Something went wrong registering for notifications', error);
      });
    },

    unsubscribeNotifications: function(){
      this.notifications.unregister().then(function(){
        Em.Logger.info('Successfully unregistered the device');
      }).catch(function(error){
        Em.Logger.error('Something went wrong while unregistering', error);
      });
    }
  }
});

Caveats:

  • It's not possible to know what device what unregistered when calling unregister
  • PushPlugin has a weird setup for registering devices with GCM. There is a timeout of 15 seconds when doing a registration with GCM. If GCM does not send a registered event within this timeframe, the device is not registered. The timeout value may be overridden by passing gcmTimeout when instantiating the service.

Dialogs

Dependencies:

  • cordova plugin add https://github.com/apache/cordova-plugin-dialogs.git

Public Methods:

  • alert - Show a message to the user
  • confirm - Ask for some confirmation from the user
  • prompt - Ask for some information from the user

Usage:

// app/initializers/dialogs-service.js
import DialogsService from 'ember-cli-cordova-shims/services/dialogs';

export function initialize(container, application) {
  application.register('service:dialogs', DialogsService);
  application.inject('route', 'dialogs', 'service:dialogs');
}

export default {
  name: 'dialogs-service',
  initialize: initialize
};
// app/routes/application.js
import Em from 'ember';

export default Em.Route.extend({

  actions: {
    something: function(){
      this.dialogs.alert({
        title: 'Hey',
        message: 'This just happened',
        button: 'OK'
      }).then(function(){
        // Do something
      });
    }
  }
});

Network Activity Indicator

Dependencies:

  • cordova plugin add com.wearecocoon.cordova.plugin.networkactivity

Usage:

// app/adaptesr/application.js
import NetworkActivityAdapterMixin from 'ember-cli-cordova-shims/mixins/network-activity-adapter';

export default DS.RESTAdapter.extend(NetworkActivityAdapterMixin, {
  // Your implementation goes here
});

Installation

  • git clone this repository
  • npm install
  • bower install

Running

  • ember server
  • Visit your app at http://localhost:4200.

Running Tests

  • ember test
  • ember test --server

Documentation

The modules are documented with yuidoc.

  • npm install yuidocjs -g
  • yuidoc -c yuidoc.json

Building

  • ember build

For more information on using ember-cli, visit http://www.ember-cli.com/.