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

cordova-plugin-firebase-complete

v1.0.5

Published

> Extremely easy plug & play plugins for Cordova applications with all Firebase Features.

Downloads

9

Readme

A Complete Firebase Features include in this Cordova Plugin.

Extremely easy plug & play plugins for Cordova applications with all Firebase Features.

Google Firebase Analytics Cordova Plugin

Set Analytics Enable or Disable

FirebaseCompletePlugin.setAnalyticsCollectionEnabled(function(enable){ //if true means enable, false means not enable
  
});

Log Events for analytics.

FirebaseCompletePlugin.logEvent(function(name,message){
  
});

Log Errors for analytics.

FirebaseCompletePlugin.logError(function(name,errors){
  
});

Google Firebase Cloud Messaging Cordova Push Plugin

Extremely easy plug&play push notification plugin for Cordova applications with Google Firebase FCM.

Authorship

This is a fork from https://github.com/fechanique/cordova-plugin-fcm & https://github.com/andrehtissot/cordova-plugin-fcm-with-dependecy-updated with improvements.

This fork has its google and firebase dependencies versions defined, which is necessary to avoid cordova build errors.

  • Tested on Android and iOS using Cordova cli 6.4.0, Cordova android 6.0.0 and Cordova ios 4.3.1
  • Available sdk functions: onTokenRefresh, getToken, subscribeToTopic, unsubscribeFromTopic and onNotification
  • 'google-services.json' and 'GoogleService-Info.plist' are added automatically from Cordova project root to platform folders
  • Added data payload parameter to check whether the user tapped on the notification or was received while in foreground.
  • Free testing server available for free! https://cordova-plugin-fcm.appspot.com

Installation

Make sure you have ‘google-services.json’ for Android or ‘GoogleService-Info.plist’ for iOS in your Cordova project root folder. You don´t need to configure anything else in order to have push notification working for both platforms, everything is magic.

cordova plugin add cordova-plugin-firebase-complete

Firebase configuration files

Get the needed configuration files for Android or iOS from the Firebase Console (see docs: https://firebase.google.com/docs/).

Android compilation details

Put the downloaded file 'google-services.json' in the Cordova project root folder.

You will need to ensure that you have installed the appropiate Android SDK libraries.

:warning: For Android >5.0 status bar icon, you must include transparent solid color icon with name 'fcm_push_icon.png' in the 'res' folder in the same way you add the other application icons. If you do not set this resource, then the SDK will use the default icon for your app which may not meet the standards for Android >5.0.

iOS compilation details

Put the downloaded file 'GoogleService-Info.plist' in the Cordova project root folder.

Usage

:warning: It's highly recommended to use REST API to send push notifications because Firebase console does not have all the functionalities. Pay attention to the payload example in order to use the plugin properly.
You can also test your notifications with the free testing server: https://cordova-plugin-fcm.appspot.com

Checking for permissions

Useful for IOS. On android, it will always return true.

FirebaseCompletePlugin.hasPermission(function(doesIt){
    // doesIt === true => yes, push was allowed
    // doesIt === false => nope, push will not be available
    // doesIt === null => still not answered, recommended checking again later
    if(doesIt) {
        haveFun();
    }
});

Receiving Token Refresh

//FirebaseCompletePlugin.onTokenRefresh( onTokenRefreshCallback(token) );
//Note that this callback will be fired everytime a new token is generated, including the first time.
FirebaseCompletePlugin.onTokenRefresh(function(token){
    alert( token );
});

Get token

//FirebaseCompletePlugin.getToken( successCallback(token), errorCallback(err) );
//Keep in mind the function will return null if the token has not been established yet.
FirebaseCompletePlugin.getToken(function(token){
    alert(token);
});

Subscribe to topic

//FirebaseCompletePlugin.subscribeToTopic( topic, successCallback(msg), errorCallback(err) );
//All devices are subscribed automatically to 'all' and 'ios' or 'android' topic respectively.
//Must match the following regular expression: "[a-zA-Z0-9-_.~%]{1,900}".
FirebaseCompletePlugin.subscribeToTopic('topicExample');

Unsubscribe from topic

//FirebaseCompletePlugin.unsubscribeFromTopic( topic, successCallback(msg), errorCallback(err) );
FirebaseCompletePlugin.unsubscribeFromTopic('topicExample');

Receiving push notification data

//FirebaseCompletePlugin.onNotification( onNotificationCallback(data), successCallback(msg), errorCallback(err) )
//Here you define your application behaviour based on the notification data.
FirebaseCompletePlugin.onNotification(function(data){
    if(data.wasTapped){
      //Notification was received on device tray and tapped by the user.
      alert( JSON.stringify(data) );
    }else{
      //Notification was received in foreground. Maybe the user needs to be notified.
      alert( JSON.stringify(data) );
    }
});

Send notification. Payload example (REST API)

Full documentation: https://firebase.google.com/docs/cloud-messaging/http-server-ref
Free testing server: https://cordova-plugin-fcm.appspot.com

//POST: https://fcm.googleapis.com/fcm/send
//HEADER: Content-Type: application/json
//HEADER: Authorization: key=AIzaSy*******************
{
  "notification":{
    "title":"Notification title",
    "body":"Notification body",
    "sound":"default",
    "click_action":"FCM_PLUGIN_ACTIVITY",
    "icon":"fcm_push_icon"
  },
  "data":{
    "param1":"value1",
    "param2":"value2"
  },
    "to":"/topics/topicExample",
    "priority":"high",
    "restricted_package_name":""
}
//sound: optional field if you want sound with the notification
//click_action: must be present with the specified value for Android
//icon: white icon resource name for Android >5.0
//data: put any "param":"value" and retreive them in the JavaScript notification callback
//to: device token or /topic/topicExample
//priority: must be set to "high" for delivering notifications on closed iOS apps
//restricted_package_name: optional field if you want to send only to a restricted app package (i.e: com.myapp.test)

How it works

Send a push notification to a single device or topic.

  • 1.a Application is in foreground:
  • The notification data is received in the JavaScript callback without notification bar message (this is the normal behaviour of mobile push notifications).
  • 1.b Application is in background or closed:
  • The device displays the notification message in the device notification bar.
  • If the user taps the notification, the application comes to foreground and the notification data is received in the JavaScript callback.
  • If the user does not tap the notification but opens the applicacion, nothing happens until the notification is tapped.