cordova-plugin-appice 2.2.7 → 2.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cordova-plugin-appice",
3
- "version": "2.2.7",
3
+ "version": "2.2.8",
4
4
  "description": "AppICE Plugin for Cordova/PhoneGap",
5
5
  "cordova": {
6
6
  "id": "cordova-plugin-appice",
package/plugin.xml CHANGED
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
3
- id="cordova-plugin-appice" version="2.2.7">
3
+ id="cordova-plugin-appice" version="2.2.8">
4
4
  <name>AppICE</name>
5
5
  <description>AppICE Plugin for Cordova/PhoneGap</description>
6
6
  <license>Commercial</license>
@@ -121,7 +121,7 @@
121
121
  <preference name="MEDIA3_UI_VERSION" default="1.0.2"/>
122
122
 
123
123
  <!-- AppICE VERSION-->
124
- <preference name="APPICE_VERSION" default="2.6.14-release"/>
124
+ <preference name="APPICE_VERSION" default="2.6.17"/>
125
125
 
126
126
 
127
127
  <!-- USES PERMISSION -->
@@ -62,6 +62,7 @@ public class AppICEPlugin extends CordovaPlugin {
62
62
  private static boolean inBackground = true;
63
63
  private static CallbackContext notificationCallbackContext;
64
64
  private static CallbackContext callbackContext;
65
+ private static CordovaWebView mwebView;
65
66
 
66
67
  @Retention(RUNTIME)
67
68
  @interface CordovaMethod {
@@ -114,7 +115,7 @@ public class AppICEPlugin extends CordovaPlugin {
114
115
  @Override
115
116
  public void initialize(CordovaInterface cordova, CordovaWebView webView) {
116
117
  super.initialize(cordova, webView);
117
-
118
+ mwebView = webView;
118
119
  onNewIntent(cordova.getActivity().getIntent());
119
120
  }
120
121
 
@@ -739,22 +740,25 @@ public class AppICEPlugin extends CordovaPlugin {
739
740
  }
740
741
  }
741
742
 
742
- public static void sendNotification(JSONObject bundle, Context context) {
743
- new Thread(new Runnable() {
744
- @Override
745
- public void run() {
746
- try {
747
- if (callbackContext != null) {
748
- String pushPaylaod = bundle.getString("ai_content");
749
- PluginResult result = new PluginResult(PluginResult.Status.OK, pushPaylaod);
750
- result.setKeepCallback(true);
751
- callbackContext.sendPluginResult(result);
743
+ public void sendNotification(JSONObject bundle, Context context) {
744
+ try {
745
+ String pushPayload = bundle.getString("ai_content");
746
+ String eventName = "pushNotificationClicked";
747
+ String js = "cordova.fireDocumentEvent('" + eventName + "', { payload: " + pushPayload + " });";
748
+
749
+ if (mwebView != null && mwebView.getEngine() != null) {
750
+ mwebView.getView().post(new Runnable() {
751
+ @Override
752
+ public void run() {
753
+ mwebView.getEngine().evaluateJavascript(js, null);
752
754
  }
753
- } catch (Throwable e) {
754
- Utility.loginfo("Runnable: error "+e);
755
- }
756
- }
757
- }).start();
755
+ });
756
+ } else {
757
+ Utility.loginfo("WebView or its engine is null");
758
+ }
759
+ } catch (Exception e) {
760
+ Utility.loginfo("Error sending notification to JS "+e);
761
+ }
758
762
  }
759
763
 
760
764
  // ==================================
@@ -104,7 +104,8 @@ public class CampaignCampsReceiver extends BroadcastReceiver {
104
104
  Log.e(TAG, "sendCallback: error ",e );
105
105
  }
106
106
 
107
- AppICEPlugin.sendNotification(json, context);
107
+ AppICEPlugin plugin=new AppICEPlugin();
108
+ plugin.sendNotification(json, context);
108
109
  } catch (Throwable e) {
109
110
  Log.e(TAG, "sendCallback: error ",e );
110
111
  }