Customizing Plugin

Push Notifications in Foreground

By default Pushwoosh plugin does not display notifications in the foreground and automatically triggers push-notification event. This can be controlled by using IOS_FOREGROUND_ALERT_TYPE and ANDROID_FOREGROUND_PUSH preferences:

IOS_FOREGROUND_ALERT_TYPE

  • BANNER – displays banner in-app alert
  • ALERT – alert notification
  • NONE – do not display a notification when the app is in the foreground (default)

ANDROID_FOREGROUND_PUSH

  • true – do not automatically handle foreground pushes
  • false – automatically handle foreground pushes (default)

Example:

cordova plugin add pushwoosh-cordova-plugin --variable IOS_FOREGROUND_ALERT_TYPE="ALERT" --variable ANDROID_FOREGROUND_PUSH="true"

Custom Push Sound

To enable custom push notifications sounds for Android place sound samples in www/res folder. The sounds will be accessible in Sound dropdown menu of Send Push panel.
In iOS, sound files are not automatically associated with Pushwoosh Application yet, but can be used manually, e.g. www/res/sound_name.wav.

iOS

iOS notifications support only .aiff, .wav and .caf file formats

Custom Push Icon

Push notification icon can be customized on Android locally by using pw_notification as resource name for such icon (see sample 1 2); or remotely by referencing any resource name in Icon setting in Send Push panel.

Custom Push Data

Custom push data can be sent using Action setting in the Send Push panel. To receive and handle such data use the following code:

document.addEventListener('push-notification',
  function(event) {
    var message = event.notification.message; // Push message
    var userData = event.notification.userdata; // Custom push data

    if (userData) {
      // handle custom push data here
    }
  }
);

Controlling Log Level

In order to assist with debugging and integration, SDK will print all the requests to the console by default. When you are ready for the production build, set LOG_LEVEL variable to one of the following values:

  • NONE – no logs from the SDK
  • ERROR – only display errors in the console
  • WARNING – show warnings
  • INFO – show informational messages
  • DEBUG – show everything, including debug information (default)

Example:

cordova plugin add pushwoosh-cordova-plugin --variable LOG_LEVEL="INFO"

Geozones Push Notifications

1. To enable location tracking in your application:

1.1 For iOS follow this guide

1.2 For Android add the following permissions:

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

1.3 For Windows Phone add the following capabilities:

<Capabilities>
      ...
      <Capability Name="ID_CAP_LOCATION" />
</Capabilities>

1.4 On PhoneGap Build these permissions could be added using cordova-plugin-geolocation plugin. NSLocationWhenInUseUsageDescription can be specified using GEOLOCATION_USAGE_DESCRIPTION variable

2. To start location tracking simply call:

var pushwoosh = cordova.require("pushwoosh-cordova-plugin.PushNotification");
pushwoosh.startLocationTracking();

Deep linking

We recommend using https://github.com/nordnet/cordova-universal-links-plugin
It's super easy to set deep links for Cordova and it works with Pushwoosh deep linking functionality out of the box.

For example add the following to Cordova config.xml:

<universal-links>
    <host name="sample.com" scheme="pushwoosh" event="ul_myExampleEvent" />
</universal-links>

This will set the deep link for pushwoosh://sample.com and will trigger ul_myExampleEvent

Also, add the following to your javascript code:

universalLinks.subscribe('ul_myExampleEvent', function (eventData) {
    // handle deep link open here
});

Customizing Plugin