Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
  docs
  hooks
  jsdoc2md
  src
  www
  package.json
  plugin.xml
  README.md
Size: Mime:
  README.md

Dynamic Engine Push Proxy Plugin

This plugin adds the push notifications dispatch mechanism to the listeners who demand it: when a push is received from the operating system it has a single entry point. if you need to handle push from multiple points in your app you can use this listener-based dispatcher.

NOTE:This plugin depends on phonegap-plugin-push plugin.

Installation

cordova plugin add de-push-proxy-plugin --save

After the installation your AndroidManifest.xml should contain these lines (only for Android platform):

<service android:exported="false" android:name="com.vipera.pushproxy.DEGCMIntentService">
    <intent-filter>
        <action android:name="com.google.android.c2dm.intent.RECEIVE" />
    </intent-filter>
</service>

DEPushNotificationHandler

To create a listener you must implement the DEPushNotificationHandler interface:

public interface DEPushNotificationHandler {

    public boolean canHandleMessage(String from, Bundle extras);

}

The canHandleMessage method must return a boolean value depending on whether the listener has managed push reception. If the push is handled it will have to return TRUE.

Example:

public class CustomGCMHandler implements DEPushNotificationHandler {

    @Override
    public boolean canHandleMessage(String from, Bundle extras) {
        Log.d("canHandleMessage called for "+ from +" extras " + extras, "");
        return true;
    }
}

DEPushNotificationHandlerRegistry

To register a new instance of the DEPushNotificationHandler implementation you need to register it via DEPushNotificationHandlerRegistry singleton:

customHandlerInstance = new CustomGCMHandler():

....

DEPushNotificationHandlerRegistry.getInstance().registerNotificationHandler(customHandlerInstance);

iOS Usage

To use this plugin in iOS you need to perform some changes manually. Basically you have to add these lines at the start in the AppDelegate methods (probably in 'AppDelegate+notification.m' source file) like these:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
    NSLog(@"didReceiveNotification with fetchCompletionHandler");

    if ([[DEPushNotificationHandlerRegistry sharedInstance] canHandleMessage:application didReceiveRemoteNotification:userInfo]){
        return;
    }

....

and

- (void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
    NSLog(@"clicked on the shade");
    if ([[DEPushNotificationHandlerRegistry sharedInstance] canHandleMessage:application didReceiveRemoteNotification:userInfo]){
        return;
    }

  ...

and import

#import "DEPushNotificationHandlerRegistry.h"