cordova-plugin-appice 2.2.6 → 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.6",
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.6">
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>
@@ -41,7 +41,7 @@
41
41
 
42
42
  <podspec>
43
43
  <pods>
44
- <pod name="AppICE-IOS-SDK" spec="1.8.01" />
44
+ <pod name="AppICE-IOS-SDK" spec="1.8.02" />
45
45
  </pods>
46
46
  </podspec>
47
47
 
@@ -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.12"/>
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
  // ==================================
@@ -1585,7 +1589,7 @@ public class AppICEPlugin extends CordovaPlugin {
1585
1589
  public void run() {
1586
1590
  ClickCallback clickCallback = new ClickCallback() {
1587
1591
  @Override
1588
- public void clickPayload(String obj) {
1592
+ public void clickPayload(JSONObject obj) {
1589
1593
  if (Utility.isValidObject(obj)) {
1590
1594
  if (callbackContext != null) {
1591
1595
  try {
@@ -1601,7 +1605,6 @@ public class AppICEPlugin extends CordovaPlugin {
1601
1605
  CampaignCampsReceiver campaignCampsReceiver = new CampaignCampsReceiver(clickCallback);
1602
1606
  }
1603
1607
  });
1604
- callbackContext.success();
1605
1608
  } catch (Throwable e) {
1606
1609
  callbackContext.error(e.getMessage());
1607
1610
  }
@@ -46,8 +46,9 @@ public class CampaignCampsReceiver extends BroadcastReceiver {
46
46
 
47
47
  if (inApp) {
48
48
  if (cdata != null && cdata.length() > 0) {
49
+ JSONObject cdataObject = new JSONObject(cdata);
49
50
  if (clickCallback != null) {
50
- clickCallback.clickPayload(cdata);
51
+ clickCallback.clickPayload(cdataObject);
51
52
  Utility.loginfo("CampaignRec : clickCallback "+cdata);
52
53
  } else
53
54
  Utility.loginfo("callback is null");
@@ -103,7 +104,8 @@ public class CampaignCampsReceiver extends BroadcastReceiver {
103
104
  Log.e(TAG, "sendCallback: error ",e );
104
105
  }
105
106
 
106
- AppICEPlugin.sendNotification(json, context);
107
+ AppICEPlugin plugin=new AppICEPlugin();
108
+ plugin.sendNotification(json, context);
107
109
  } catch (Throwable e) {
108
110
  Log.e(TAG, "sendCallback: error ",e );
109
111
  }
@@ -1,6 +1,7 @@
1
1
  package com.appice.cordova;
2
+ import org.json.JSONObject;
2
3
 
3
4
  public interface ClickCallback {
4
- void clickPayload(String obj);
5
+ void clickPayload(JSONObject obj);
5
6
 
6
7
  }
@@ -1584,9 +1584,7 @@ static NSDictionary *pendingDeeplink = nil;
1584
1584
  - (void)suspendInApp:(CDVInvokedUrlCommand *)command {
1585
1585
  [self.commandDelegate runInBackground:^{
1586
1586
  @try {
1587
- // [[appICE sharedInstance] suspendInApp];
1588
- /**NOTE: As suspendInApp is queing the INAPP ,calling discardInApp in suspendInApp function which will do NOTHING (not queue) Done as Android**/
1589
- [[appICE sharedInstance] discardInApp];
1587
+ [[appICE sharedInstance] suspendInApp];
1590
1588
  CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
1591
1589
  [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
1592
1590
  } @catch (NSException *e) {