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-mfp-push

v8.0.2024082808

Published

Cordova Plugin for the IBM MobileFirst Platform Foundation Push

Downloads

314

Readme

IBM MobileFirst Platform Foundation Push Plugin

Cordova Plugin for the IBM Mobile First Platform Push SDK

Installation

Installing necessary libraries

You should already have Node.js/npm and the Cordova package installed. If you don't, you can download and install Node from https://nodejs.org/en/download/.

The Cordova library is also required to use this plugin. You can find instructions to install Cordova and set up your Cordova app at https://cordova.apache.org/#getstarted.

Creating a Cordova application

Run the following commands to create a new Cordova application. Alternatively you can use an existing application as well.

```
$ cordova create {appName}
$ cd {appName}
```

Adding Cordova platforms

Run the following commands according to which platform you want to add to your Cordova application

cordova platform add ios

cordova platform add android

cordova platform add windows

Editing config.xml

  1. Edit config.xml file and set the desired application name in the <name> element instead of a default HelloCordova.

  2. Continue editing config.xml. Update the <platform name="android"> element with a minimum and target SDK versions as shown in the code snippet below.

    <platform name="android">
    	<preference name="android-minSdkVersion" value="15" />
    	<preference name="android-targetSdkVersion" value="23" />
    	// other properties
    </platform>

    The minSdkVersion should be above 15.

    The targetSdkVersion should always reflect the latest Android SDK available from Google.

Adding the Cordova plugin

From your Cordova application root directory, enter the following command to install the Cordova Push plugin.

cordova plugin add cordova-plugin-mfp-push

From your app root folder, verify that the Cordova Core and Push plugin were installed successfully, using the following command.

cordova plugin list

Updating your client application to use the Push SDK

Configuring Your iOS Development Environment

You can open the iOS Project generated by Cordova in [your-app-name]/platforms/ios directory with XCode or use Cordova CLI to build and run it.

Configuring Your Android Development Environment

You can open the Android Project generated by Cordova in [your-app-name]/platforms/android directory with Android Studio or use Cordova CLI to build and run it.

Configuring Your Windows Development Environment

You can open the Windows Project generated by Cordova in [your-app-name]/platforms/windows directory with Visual Studio or use Cordova CLI to build and run it.

Usage

The following MFPPush Javascript functions are available:

Javascript Function | Description --- | --- registerDevice(success, failure) | Registers the device with the Push Notifications Service. unregisterDevice(success, failure) | Unregisters the device from the Push Notifications Service getSubscriptions(success, failure) | Retrieves the tags device is currently subscribed to getTags(success, failure) | Retrieves all the tags available in a push notification service instance. subscribe(tag, success, failure) | Subscribes to a particular tag. unsubscribe(tag, success, failure) | Unsubscribes from a particular tag. registerNotificationsCallback(callback) | Registers a callback for when a notification arrives on the device.

Android (Native) The following native Android function is available.

Android function | Description --- | --- CDVMFPPush. setIgnoreIncomingNotifications(boolean ignore) | By default, push notifications plugin handles all incoming Push Notification by tunnelling them to JavaScript callback. Use this method to override the plugin's default behavior in case you want to manually handle incoming push notifications in native code.

Examples

Using MFPPush

Register for Push Notifications


var success = function(message) { console.log("Success: " + message); };
var failure = function(message) { console.log("Error: " + message); };
    
MFPPush.registerDevice(success, failure);

The settings structure contains the settings that you want to enable for push notifications. You must use the defined structure and should only change the boolean value of each notification setting.

Android does NOT make use of the settings parameter. If you're only building Android app pass an empty object, e.g.

MFPPush.registerDevice(success, failure);

To unregister for push notifications simply call the following:

MFPPush.unregisterDevice(success, failure);

Retrieving Tags

In the following examples, the function parameter is a success callback that receives an array of tags. The second parameter is a callback function called on error.

To retrieve an array of tags to which the user is currently subscribed, use the following Javascript function:

MFPPush.getSubscriptions(function(tags) {
	alert(tags);
}, failure);

To retrieve an array of tags that are available to subscribe, use the following Javascript function:

MFPPush.getTags(function(tags) {
	alert(tags);
}, failure);

Subscribe and Unsubscribe to/from Tags

var tag = "YourTag";
MFPPush.subscribe(tag, success, failure);
MFPPush.unsubscribe(tag, success, failure);

Receiving a Notification

var handleNotificationCallback = function(notification) {
	// notification is a JSON object
	alert(notif);
}

MFPPush.registerNotificationsCallback(handleNotificationCallback);

The following table describes the properties of the notification object:

Property | Description --- | --- message | Push notification message text payload | JSON object containing additional notification payload. sound | The name of a sound file in the app bundle or in the Library/Sounds folder of the app’s data container (iOS only). badge | The number to display as the badge of the app icon. If this property is absent, the badge is not changed. To remove the badge, set the value of this property to 0 (iOS only). action-loc-key | The string is used as a key to get a localized string in the current localization to use for the right button’s title instead of “View� (iOS only).

Example Notification structure:

// iOS
notification = {
	message: "Something has happened",
	payload: {
		customProperty:12345
	},
	sound: "mysound.mp3",
	badge: 7,
	action-loc-key: "Click me"
}

// Android
notification = {
	message: "Something has happened",
	payload: {
		customProperty:12345
	},
	id: <id>,
	url: <url>
}

// Windows
notification = {
	message: "Something has happened",
	payload: {
		customProperty:12345
	},
	settings: { wns:{
    raw: {payload:{custom:"Push Message from MFP"}},
    badge: { value: "10"}}}
}

For details of the changes in this latest release, see http://www-01.ibm.com/support/docview.wss?uid=swg2C7000003