Skip to content

Commit

Permalink
upstream repo updated
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyVerbruggen committed Mar 18, 2015
2 parents 7b30e7b + a84df60 commit 1e5481c
Show file tree
Hide file tree
Showing 8 changed files with 228 additions and 92 deletions.
6 changes: 4 additions & 2 deletions MIT-LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2014 Pushwoosh (http://www.pushwoosh.com)
Copyright (c) 2014 Pushwoosh (http://www.pushwoosh.com)

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand All @@ -8,7 +8,9 @@ distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
(i) the original and/or modified Software should be used exclusively to work with Pushwoosh services,

(ii) the above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
Expand Down
12 changes: 6 additions & 6 deletions plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android"
id="com.pushwoosh.plugins.pushwoosh"
version="3.2.1">
version="3.4.13">

<name>Pushwoosh</name>

Expand Down Expand Up @@ -29,18 +29,17 @@
<config-file target="AndroidManifest.xml" parent="/manifest">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

<!--library-->
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.VIBRATE" />

<!-- GCM connects to Google Services. -->
<uses-permission android:name="android.permission.INTERNET"/>

<!-- GCM requires a Google account. -->
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>

<!-- Keeps the processor from sleeping when a message is received. -->
<uses-permission android:name="android.permission.WAKE_LOCK"/>

<!-- So the sounds from assets folder could work for notification sounds. -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

<!--
Creates a custom permission so only this app can receive its messages.
Expand Down Expand Up @@ -124,6 +123,7 @@
<platform name="ios">
<framework src="Security.framework" />
<framework src="Storekit.framework" />
<framework src="CoreLocation.framework" />
<config-file target="config.xml" parent="/*">
<feature name="PushNotification">
<param name="ios-package" value="PushNotification"/>
Expand Down
Binary file modified src/android/lib/Pushwoosh.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

package com.pushwoosh.plugin.pushnotifications;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
Expand All @@ -24,11 +25,14 @@

import com.arellomobile.android.push.BasePushMessageReceiver;
import com.arellomobile.android.push.PushManager;
import com.arellomobile.android.push.PushPersistance;
import com.arellomobile.android.push.PushManager.GetTagsListener;
import com.arellomobile.android.push.exception.PushWooshException;
import com.arellomobile.android.push.SendPushTagsCallBack;
import com.arellomobile.android.push.preference.SoundType;
import com.arellomobile.android.push.preference.VibrateType;
import com.arellomobile.android.push.utils.PreferenceUtils;
import com.arellomobile.android.push.utils.RegisterBroadcastReceiver;
import com.arellomobile.android.push.utils.rich.RichPushUtils;
import com.google.android.gcm.GCMRegistrar;

import org.apache.cordova.CallbackContext;
Expand Down Expand Up @@ -58,6 +62,7 @@ public class PushNotifications extends CordovaPlugin
public static final String GET_HWID = "getPushwooshHWID";

boolean receiversRegistered = false;
boolean deviceReady = false;

HashMap<String, CallbackContext> callbackIds = new HashMap<String, CallbackContext>();
PushManager mPushManager = null;
Expand Down Expand Up @@ -320,24 +325,38 @@ private boolean internalSendTags(JSONArray data, final CallbackContext callbackC
}
}

try
callbackIds.put("setTags", callbackContext);

final class SendTagsListenerImpl implements SendPushTagsCallBack
{
Map<String, String> skippedTags = PushManager.sendTagsFromBG(cordova.getActivity(), paramsMap);
@Override
public void onSentTagsSuccess(Map<String, String> skippedTags)
{
CallbackContext callback = callbackIds.get("setTags");
if (callback == null)
return;

callback.success(new JSONObject(skippedTags));
callbackIds.remove("setTags");
}

JSONObject skippedTagsObj = new JSONObject();
for (String tagName : skippedTags.keySet())
@Override
public void onSentTagsError(Exception e)
{
skippedTags.put(tagName, skippedTags.get(tagName));
CallbackContext callback = callbackIds.get("setTags");
if (callback == null)
return;

callback.error(e.getMessage());
callbackIds.remove("setTags");
}

callbackContext.success(skippedTagsObj);
return true;
}
catch (PushWooshException e)
{
e.printStackTrace();
return false;
@Override
public void taskStarted() {}
}

PushManager.sendTags(cordova.getActivity(), paramsMap, new SendTagsListenerImpl());
return true;
}

@Override
Expand All @@ -364,6 +383,7 @@ public boolean execute(String action, JSONArray data, CallbackContext callbackId
{
initialize(data, callbackId);
checkMessage(cordova.getActivity().getIntent());
deviceReady = true;
return true;
}

Expand Down Expand Up @@ -571,6 +591,26 @@ public boolean execute(String action, JSONArray data, CallbackContext callbackId

return true;
}

if ("setColorLED".equals(action))
{
try
{
String colorString = (String) data.get(0);
if (colorString == null)
return false;

int colorLed = RichPushUtils.parseColor(colorString);
PushManager.setColorLED(cordova.getActivity(), colorLed);
}
catch (Exception e)
{
e.printStackTrace();
return false;
}

return true;
}


if ("sendGoalAchieved".equals(action))
Expand Down Expand Up @@ -640,6 +680,25 @@ public void onError(Exception e)
PushManager.getTagsAsync(cordova.getActivity(), new GetTagsListenerImpl());
return true;
}

if(action.equals("getPushHistory"))
{
ArrayList<String> pushHistory = PushPersistance.getPushHistory(cordova.getActivity());
callbackId.success(new JSONArray(pushHistory));
return true;
}

if(action.equals("clearPushHistory"))
{
PushPersistance.clearPushHistory(cordova.getActivity());
return true;
}

if(action.equals("clearNotificationCenter"))
{
PushManager.clearNotificationCenter(cordova.getActivity());
return true;
}

Log.d("DirectoryListPlugin", "Invalid action : " + action + " passed");
return false;
Expand Down
Loading

0 comments on commit 1e5481c

Please sign in to comment.