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

vipera-npm-registry / de-doc-generator   js

Repository URL to install this package:

Version: 1.0.0 

/ htdocs / de_plugins / de_pushproxy_plugin.html

<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, minimal-ui">
    <title>Dynamic Engine Push Proxy Plugin</title>
    <link type="text/css" rel="stylesheet" href="../assets/css/github-markdown.css">
    <link type="text/css" rel="stylesheet" href="../assets/css/pilcrow.css">
    <link type="text/css" rel="stylesheet" href="../assets/css/hljs-github.min.css"/>
  </head>
  <body>
    <article class="markdown-body"><h1 id="dynamic-engine-push-proxy-plugin"><a class="header-link" href="#dynamic-engine-push-proxy-plugin"></a>Dynamic Engine Push Proxy Plugin</h1>
<p>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.</p>
<p><strong>NOTE</strong>:This plugin depends on <a href="https://github.com/phonegap/phonegap-plugin-push">phonegap-plugin-push</a> plugin.</p>
<h2 id="installation"><a class="header-link" href="#installation"></a>Installation</h2>
<pre class="hljs"><code>cordova <span class="hljs-keyword">plugin</span> add <span class="hljs-keyword">de</span>-push-proxy-<span class="hljs-keyword">plugin</span> --<span class="hljs-keyword">save</span></code></pre><p>After the installation your AndroidManifest.xml should contain these lines (only for <strong>Android platform</strong>):</p>
<pre class="hljs"><code><span class="hljs-tag">&lt;<span class="hljs-name">service</span> <span class="hljs-attr">android:exported</span>=<span class="hljs-string">"false"</span> <span class="hljs-attr">android:name</span>=<span class="hljs-string">"com.vipera.pushproxy.DEGCMIntentService"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">intent-filter</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">action</span> <span class="hljs-attr">android:name</span>=<span class="hljs-string">"com.google.android.c2dm.intent.RECEIVE"</span> /&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">intent-filter</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">service</span>&gt;</span></code></pre><h1 id="depushnotificationhandler"><a class="header-link" href="#depushnotificationhandler"></a>DEPushNotificationHandler</h1>
<p>To create a listener you must implement the <em>DEPushNotificationHandler</em> interface:</p>
<pre class="hljs"><code><span class="hljs-keyword">public</span> <span class="hljs-keyword">interface</span> <span class="hljs-title">DEPushNotificationHandler</span> {

    <span class="hljs-function"><span class="hljs-keyword">public</span> boolean <span class="hljs-title">canHandleMessage</span>(<span class="hljs-params">String <span class="hljs-keyword">from</span>, Bundle extras</span>)</span>;

}</code></pre><p>The <em>canHandleMessage</em> 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.</p>
<p>Example:</p>
<pre class="hljs"><code><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">CustomGCMHandler</span> <span class="hljs-keyword">implements</span> <span class="hljs-title">DEPushNotificationHandler</span> </span>{

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">boolean</span> <span class="hljs-title">canHandleMessage</span><span class="hljs-params">(String from, Bundle extras)</span> </span>{
        Log.d(<span class="hljs-string">"canHandleMessage called for "</span>+ from +<span class="hljs-string">" extras "</span> + extras, <span class="hljs-string">""</span>);
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">true</span>;
    }
}</code></pre><h1 id="depushnotificationhandlerregistry"><a class="header-link" href="#depushnotificationhandlerregistry"></a>DEPushNotificationHandlerRegistry</h1>
<p>To register a new instance of the <em>DEPushNotificationHandler</em> implementation you need to register it via <em>DEPushNotificationHandlerRegistry</em> singleton:</p>
<pre class="hljs"><code>customHandlerInstance = <span class="hljs-keyword">new</span> CustomGCMHandler():

....

DEPushNotificationHandlerRegistry.getInstance().registerNotificationHandler(customHandlerInstance);</code></pre><h1 id="ios-usage"><a class="header-link" href="#ios-usage"></a>iOS Usage</h1>
<p>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 &#39;AppDelegate+notification.m&#39; source file) like these:</p>
<pre class="hljs"><code><span class="hljs-selector-tag">-</span> (void)<span class="hljs-selector-tag">application</span><span class="hljs-selector-pseudo">:(UIApplication</span> *)<span class="hljs-selector-tag">application</span> <span class="hljs-selector-tag">didReceiveRemoteNotification</span><span class="hljs-selector-pseudo">:(NSDictionary</span> *)<span class="hljs-selector-tag">userInfo</span> <span class="hljs-selector-tag">fetchCompletionHandler</span><span class="hljs-selector-pseudo">:(void</span> (^)(UIBackgroundFetchResult))<span class="hljs-selector-tag">completionHandler</span> {
    <span class="hljs-selector-tag">NSLog</span>(@<span class="hljs-string">"didReceiveNotification with fetchCompletionHandler"</span>);

    <span class="hljs-selector-tag">if</span> ([[DEPushNotificationHandlerRegistry sharedInstance] <span class="hljs-attribute">canHandleMessage</span>:application <span class="hljs-attribute">didReceiveRemoteNotification</span>:userInfo]){
        <span class="hljs-selector-tag">return</span>;
    }

....</code></pre><p>and</p>
<pre class="hljs"><code>- (<span class="hljs-keyword">void</span>) <span class="hljs-string">application:</span>(UIApplication *)application <span class="hljs-string">didReceiveRemoteNotification:</span>(NSDictionary *)userInfo {
    NSLog(@<span class="hljs-string">"clicked on the shade"</span>);
    <span class="hljs-keyword">if</span> ([[DEPushNotificationHandlerRegistry sharedInstance] <span class="hljs-string">canHandleMessage:</span>application <span class="hljs-string">didReceiveRemoteNotification:</span>userInfo]){
        <span class="hljs-keyword">return</span>;
    }

  ...</code></pre><p>and import</p>
<pre class="hljs"><code>#<span class="hljs-keyword">import</span> <span class="hljs-string">"DEPushNotificationHandlerRegistry.h"</span></code></pre>    </article>
  </body>
</html>