cordova-plugin-appice 2.2.8 → 2.2.9
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/example/www/index.html +1 -3
- package/example/www/js/Campaign.js +48 -0
- package/example/www/js/index.js +54 -25
- package/package.json +1 -1
- package/plugin.xml +9 -6
- package/src/android/AppICEPlugin.java +96 -47
- package/src/android/CampaignCampsReceiver.java +1 -2
- package/src/ios/AppDelegate+AppICEPlugin.m +4 -1
- package/src/ios/AppICEPlugin.h +4 -0
- package/src/ios/AppICEPlugin.m +41 -4
- package/www/AppICE.js +6 -2
package/example/www/index.html
CHANGED
|
@@ -82,9 +82,6 @@
|
|
|
82
82
|
|
|
83
83
|
<input id="msgId" type="text" placeholder="Enter Inbox Message ID">
|
|
84
84
|
<button id="synInbox" class="btn3">Synchronize Inbox</button>
|
|
85
|
-
|
|
86
|
-
<input id="cmpid" type="text" placeholder="Enter CampID to Schedule Campaign">
|
|
87
|
-
<button id="scheduleCampaign" class="btn3">Schedule Campaign</button>
|
|
88
85
|
</div>
|
|
89
86
|
|
|
90
87
|
<div id="inboxMessagesContainer">
|
|
@@ -94,6 +91,7 @@
|
|
|
94
91
|
|
|
95
92
|
<script src="cordova.js"></script>
|
|
96
93
|
<script src="js/index.js"></script>
|
|
94
|
+
<script src="js/Campaign.js"></script>
|
|
97
95
|
<script src="js/AppInboxMessage.js"></script>
|
|
98
96
|
</body>
|
|
99
97
|
</html>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
function Campaign(data) {
|
|
2
|
+
var isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
|
|
3
|
+
if (isIOS) {
|
|
4
|
+
this.campId = data.campId || "";
|
|
5
|
+
} else {
|
|
6
|
+
this.campId = data.camp_id || "";
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
this.actionType = data.actionType || data.et || "";
|
|
10
|
+
this.actionUrl = data.actionUrl || data.eurl || "";
|
|
11
|
+
this.actionContent = data.actionContent || "";
|
|
12
|
+
this.title = data.title || data.nh || "";
|
|
13
|
+
this.description = data.description || data.nd || "";
|
|
14
|
+
this.campType = data.campType || data.t || "";
|
|
15
|
+
this.selectedIndex = data.selectedIndex || data.selectedActionIndex || 0;
|
|
16
|
+
this.language = data.language || data.lang || "";
|
|
17
|
+
this.replyText = data.replyText || "";
|
|
18
|
+
this.customData = data.customData || data.cdata || {};
|
|
19
|
+
|
|
20
|
+
const selected = data.selectedAction || {};
|
|
21
|
+
this.selectedAction = selected;
|
|
22
|
+
this.actions = Array.isArray(data.actions)
|
|
23
|
+
? data.actions.map(function(action) {
|
|
24
|
+
return {
|
|
25
|
+
actionTitle: action.actionTitle || action.abt || "",
|
|
26
|
+
actionType: action.actionType || action.act || "",
|
|
27
|
+
actionContent: action.actionContent || action.acc || "",
|
|
28
|
+
actionUrl: action.actionUrl || action.acu || ""
|
|
29
|
+
};
|
|
30
|
+
})
|
|
31
|
+
: [];
|
|
32
|
+
|
|
33
|
+
if (isIOS) {
|
|
34
|
+
this.selectedActionTitle = selected.actionTitle || "";
|
|
35
|
+
this.selectedActionType = selected.actionType || "";
|
|
36
|
+
this.actionContent = selected.actionContent || "";
|
|
37
|
+
this.selectedActionUrl = selected.actionUrl || "";
|
|
38
|
+
} else {
|
|
39
|
+
this.selectedActionTitle = selected.abt || "";
|
|
40
|
+
this.selectedActionType = selected.act || "";
|
|
41
|
+
this.actionContent = selected.acc || "";
|
|
42
|
+
this.selectedActionUrl = selected.acu || "";
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
define('Campaign', [], function () {
|
|
47
|
+
return Campaign;
|
|
48
|
+
});
|
package/example/www/js/index.js
CHANGED
|
@@ -1,25 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
document.addEventListener('deviceready', onDeviceReady, false);
|
|
3
3
|
|
|
4
|
-
function fetchDeeplink(payload, type) {
|
|
5
|
-
console.log("Type:", type, "Payload:", JSON.stringify(payload));
|
|
6
|
-
|
|
7
|
-
// Example: Fetch and use 'eurl' from the payload's 'cdata' object
|
|
8
|
-
var eurl = payload['eurl']; // Extract 'eurl' from payload
|
|
9
|
-
console.log("eurl:", eurl);
|
|
10
|
-
|
|
11
|
-
AppICE.getDataForKey(payload, 'eurl', function (result) {
|
|
12
|
-
console.log('getDataForKey result:', result);
|
|
13
|
-
|
|
14
|
-
navigator.notification.alert(
|
|
15
|
-
result, // Message
|
|
16
|
-
alertDismissed, // Callback
|
|
17
|
-
'Notification EURL', // Title
|
|
18
|
-
'OK' // Button name
|
|
19
|
-
);
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
|
|
23
4
|
function alertDismissed() {
|
|
24
5
|
console.log('Alert dismissed');
|
|
25
6
|
}
|
|
@@ -36,12 +17,60 @@ function onDeviceReady() {
|
|
|
36
17
|
);
|
|
37
18
|
console.log('Running cordova-' + cordova.platformId + '@' + cordova.version);
|
|
38
19
|
document.getElementById('deviceready').classList.add('ready');
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
20
|
+
|
|
21
|
+
document.addEventListener("pushNotificationClicked", function (event) {
|
|
22
|
+
try {
|
|
23
|
+
const payload = event.payload;
|
|
24
|
+
console.log("Campaign Full Payload: ", JSON.stringify(payload));
|
|
25
|
+
const campaign = new Campaign(payload);
|
|
26
|
+
|
|
27
|
+
//handle deeplink
|
|
28
|
+
const cdata = campaign.customData || {};
|
|
29
|
+
const durl = cdata.test || "N/A";
|
|
30
|
+
|
|
31
|
+
if (durl === "campaign") {
|
|
32
|
+
window.location.href = "newscreen.html";
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//handle share action
|
|
36
|
+
if (campaign.selectedActionType === "sh") {
|
|
37
|
+
AppICE.shareContent(campaign.actionContent,"sample title",
|
|
38
|
+
function (success) {
|
|
39
|
+
console.log("response:", success);
|
|
40
|
+
},
|
|
41
|
+
function (error) {
|
|
42
|
+
console.error("Error:", error);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
//hanlde copy content action button
|
|
47
|
+
if (campaign.selectedActionType === "cp") {
|
|
48
|
+
AppICE.copyContent(campaign.actionContent,
|
|
49
|
+
function (success) {
|
|
50
|
+
console.log("copyContent response:", success);
|
|
51
|
+
},
|
|
52
|
+
function (error) {
|
|
53
|
+
console.error("Error:", error);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const popupMessage =
|
|
58
|
+
"Campaign ID: " + (campaign.campId || "N/A") + "\n" +
|
|
59
|
+
"Title: " + (campaign.title || "N/A") + "\n" +
|
|
60
|
+
"Description: " + (campaign.description || "N/A") + "\n" +
|
|
61
|
+
"notification url: " + (campaign.actionUrl || "N/A") + "\n" +
|
|
62
|
+
"Action Type: " + (campaign.actionType || "N/A") + "\n" +
|
|
63
|
+
"Selected Index: " + (campaign.selectedIndex ?? "N/A") + "\n" +
|
|
64
|
+
"Selected Action Content: " + (campaign.actionContent || "N/A") + "\n" +
|
|
65
|
+
"Selected Action Title: " + (campaign.selectedActionTitle || "N/A") + "\n" +
|
|
66
|
+
"Selected Action URL: " + (campaign.selectedActionUrl || "N/A") + "\n" +
|
|
67
|
+
"Selected Action Type : " + (campaign.selectedActionType || "N/A") + "\n" +
|
|
68
|
+
"Custom Data:\n" + (campaign.customData ? JSON.stringify(campaign.customData, null, 2) : "No custom data");
|
|
69
|
+
|
|
70
|
+
alert(popupMessage);
|
|
71
|
+
|
|
72
|
+
} catch (e) {
|
|
73
|
+
console.error("CORDOVAAPP Error parsing campaign:", e);
|
|
45
74
|
}
|
|
46
75
|
});
|
|
47
76
|
|
package/package.json
CHANGED
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.
|
|
3
|
+
id="cordova-plugin-appice" version="2.2.9">
|
|
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.
|
|
44
|
+
<pod name="AppICE-IOS-SDK" spec="1.8.15" />
|
|
45
45
|
</pods>
|
|
46
46
|
</podspec>
|
|
47
47
|
|
|
@@ -121,7 +121,10 @@
|
|
|
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.
|
|
124
|
+
<preference name="APPICE_VERSION" default="2.6.34"/>
|
|
125
|
+
|
|
126
|
+
<!-- CloudMessaging -->
|
|
127
|
+
<preference name="CLOUD_MESSAGING" default="17.0.2"/>
|
|
125
128
|
|
|
126
129
|
|
|
127
130
|
<!-- USES PERMISSION -->
|
|
@@ -133,9 +136,6 @@
|
|
|
133
136
|
<config-file target="AndroidManifest.xml" parent="/manifest/application">
|
|
134
137
|
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
|
|
135
138
|
|
|
136
|
-
<service android:name="semusi.activitysdk.Api"
|
|
137
|
-
android:exported="false" android:protectionLevel="signature"/>
|
|
138
|
-
|
|
139
139
|
<receiver android:name="com.appice.cordova.CampaignCampsReceiver"
|
|
140
140
|
android:exported="false" android:protectionLevel="signature">
|
|
141
141
|
<intent-filter>
|
|
@@ -195,6 +195,9 @@
|
|
|
195
195
|
<framework src= "androidx.media3:media3-exoplayer:$MEDIA3_EXOPLAYER_VERSION"/>
|
|
196
196
|
<framework src= "androidx.media3:media3-ui:$MEDIA3_UI_VERSION"/>
|
|
197
197
|
<framework src= "appice.io.android:sdk:$APPICE_VERSION"/>
|
|
198
|
+
<framework src= "com.google.android.gms:play-services-cloud-messaging:CLOUD_MESSAGING"/>
|
|
199
|
+
|
|
200
|
+
|
|
198
201
|
|
|
199
202
|
<!-- SCRIPT PATH -->
|
|
200
203
|
<!-- <hook type="before_build" src="scripts/BeforeAndroidBuilt.js" />-->
|
|
@@ -48,6 +48,8 @@ import semusi.activitysdk.IAppICEDataCallback;
|
|
|
48
48
|
|
|
49
49
|
import androidx.annotation.NonNull;
|
|
50
50
|
import androidx.annotation.Nullable;
|
|
51
|
+
import semusi.model.campaign.Campaign;
|
|
52
|
+
import semusi.model.campaign.Action;
|
|
51
53
|
|
|
52
54
|
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
|
53
55
|
|
|
@@ -119,41 +121,66 @@ public class AppICEPlugin extends CordovaPlugin {
|
|
|
119
121
|
onNewIntent(cordova.getActivity().getIntent());
|
|
120
122
|
}
|
|
121
123
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
124
|
+
@Override
|
|
125
|
+
public void onNewIntent(Intent intent) {
|
|
126
|
+
if (intent == null) return;
|
|
127
|
+
try {
|
|
128
|
+
Bundle extras = intent.getExtras();
|
|
129
|
+
if (extras == null) return;
|
|
130
|
+
|
|
131
|
+
String payload = extras.getString("ai_content");
|
|
132
|
+
int pos = extras.getInt("pos", -1);
|
|
133
|
+
int notificationId = extras.getInt("n", 0);
|
|
134
|
+
|
|
135
|
+
if (payload == null || payload.isEmpty()) return;
|
|
136
|
+
|
|
137
|
+
JSONObject payloadJson = new JSONObject(payload);
|
|
138
|
+
JSONArray actionsArray = payloadJson.optJSONArray("actions");
|
|
139
|
+
boolean isPushNotification = payloadJson.length() > 0;
|
|
140
|
+
payloadJson.put("notificationId", notificationId);
|
|
141
|
+
payloadJson.put("selectedIndex", pos);
|
|
142
|
+
|
|
143
|
+
Campaign campaign = ContextSdk.handlePush(payloadJson.toString(), cordova.getActivity());
|
|
144
|
+
Action selecteddlAction = campaign.getSelectedAction();
|
|
145
|
+
if (selecteddlAction != null){
|
|
146
|
+
payloadJson.put("selectedAction", selecteddlAction.toJson());
|
|
147
|
+
}
|
|
148
|
+
else{
|
|
149
|
+
ContextSdk.pushNotificationClicked(payloadJson.toString(), cordova.getActivity().getApplicationContext());
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (isPushNotification) {
|
|
153
|
+
String notificationType = payloadJson.optString("et");
|
|
154
|
+
|
|
155
|
+
if (selecteddlAction == null && Utility.isValidObject(notificationType) && notificationType.equalsIgnoreCase("lp")) {
|
|
156
|
+
String url = payloadJson.optString("eurl");
|
|
157
|
+
handleLandingPage(url, cordova.getActivity().getApplicationContext());
|
|
158
|
+
}
|
|
159
|
+
else if(selecteddlAction != null && selecteddlAction.getActionType().equalsIgnoreCase("lp")){
|
|
160
|
+
handleLandingPage(selecteddlAction.getActionUrl(), cordova.getActivity().getApplicationContext());
|
|
161
|
+
}else {
|
|
162
|
+
JSONObject json = new JSONObject();
|
|
163
|
+
json.put("payload", payloadJson);
|
|
164
|
+
|
|
165
|
+
if (mwebView != null && mwebView.getEngine() != null && mwebView.getUrl() != null) {
|
|
166
|
+
// WebView already loaded, fire immediately
|
|
167
|
+
mwebView.getView().post(() -> {
|
|
168
|
+
String js = "javascript:cordova.fireDocumentEvent('pushNotificationClicked'," + json + ");";
|
|
169
|
+
mwebView.loadUrl(js);
|
|
170
|
+
});
|
|
171
|
+
} else {
|
|
172
|
+
// WebView not ready yet → store temporarily
|
|
173
|
+
storeTempData(CALLBACK_CONSTANTS, json.toString(), cordova.getActivity());
|
|
149
174
|
}
|
|
150
|
-
ContextSdk.pushNotificationClicked(payload, cordova.getActivity().getApplicationContext());
|
|
151
175
|
}
|
|
152
176
|
}
|
|
153
177
|
} catch (Throwable e) {
|
|
178
|
+
Utility.loginfo("Error processing push notification intent: "+e);
|
|
179
|
+
if (callbackContext != null) {
|
|
154
180
|
callbackContext.error(e.getMessage());
|
|
155
181
|
}
|
|
156
182
|
}
|
|
183
|
+
}
|
|
157
184
|
|
|
158
185
|
@Override
|
|
159
186
|
public boolean execute(String action, JSONArray data, CallbackContext callbackId) {
|
|
@@ -740,25 +767,22 @@ public class AppICEPlugin extends CordovaPlugin {
|
|
|
740
767
|
}
|
|
741
768
|
}
|
|
742
769
|
|
|
743
|
-
public void sendNotification(JSONObject bundle, Context context) {
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
mwebView.getEngine().evaluateJavascript(js, null);
|
|
770
|
+
public static void sendNotification(JSONObject bundle, Context context) {
|
|
771
|
+
new Thread(new Runnable() {
|
|
772
|
+
@Override
|
|
773
|
+
public void run() {
|
|
774
|
+
try {
|
|
775
|
+
if (callbackContext != null) {
|
|
776
|
+
String pushPaylaod = bundle.getString("ai_content");
|
|
777
|
+
PluginResult result = new PluginResult(PluginResult.Status.OK, pushPaylaod);
|
|
778
|
+
result.setKeepCallback(true);
|
|
779
|
+
callbackContext.sendPluginResult(result);
|
|
754
780
|
}
|
|
755
|
-
})
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
Utility.loginfo("Error sending notification to JS "+e);
|
|
761
|
-
}
|
|
781
|
+
} catch (Throwable e) {
|
|
782
|
+
Utility.loginfo("Runnable: error "+e);
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
}).start();
|
|
762
786
|
}
|
|
763
787
|
|
|
764
788
|
// ==================================
|
|
@@ -1254,7 +1278,7 @@ public class AppICEPlugin extends CordovaPlugin {
|
|
|
1254
1278
|
resultMap.put(key, value);
|
|
1255
1279
|
}
|
|
1256
1280
|
} catch (JSONException e) {
|
|
1257
|
-
|
|
1281
|
+
Utility.loginfo("JSON Exception: "+e);
|
|
1258
1282
|
}
|
|
1259
1283
|
return resultMap;
|
|
1260
1284
|
}
|
|
@@ -1579,6 +1603,31 @@ public class AppICEPlugin extends CordovaPlugin {
|
|
|
1579
1603
|
}
|
|
1580
1604
|
}
|
|
1581
1605
|
|
|
1606
|
+
|
|
1607
|
+
@CordovaMethod
|
|
1608
|
+
private void shareContent(JSONArray data, CallbackContext callbackContext) {
|
|
1609
|
+
try {
|
|
1610
|
+
JSONObject object = data.optJSONObject(0);
|
|
1611
|
+
String content = object.optString("content");
|
|
1612
|
+
String title = object.optString("title");
|
|
1613
|
+
ContextSdk.shareActionContent(content,title,cordova.getActivity());
|
|
1614
|
+
} catch (Throwable e) {
|
|
1615
|
+
callbackContext.error(e.getMessage());
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
|
|
1619
|
+
@CordovaMethod
|
|
1620
|
+
private void copyContent(JSONArray data, CallbackContext callbackContext) {
|
|
1621
|
+
try {
|
|
1622
|
+
JSONObject object = data.optJSONObject(0);
|
|
1623
|
+
String text = object.optString("text");
|
|
1624
|
+
ContextSdk.copyToClipboard(text,cordova.getActivity().getApplicationContext());
|
|
1625
|
+
callbackContext.success();
|
|
1626
|
+
} catch (Throwable e) {
|
|
1627
|
+
callbackContext.error(e.getMessage());
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1582
1631
|
@CordovaMethod
|
|
1583
1632
|
private void sendClickCallback(JSONArray data, CallbackContext callbackContext) {
|
|
1584
1633
|
try {
|
|
@@ -104,8 +104,7 @@ public class CampaignCampsReceiver extends BroadcastReceiver {
|
|
|
104
104
|
Log.e(TAG, "sendCallback: error ",e );
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
AppICEPlugin
|
|
108
|
-
plugin.sendNotification(json, context);
|
|
107
|
+
AppICEPlugin.sendNotification(json, context);
|
|
109
108
|
} catch (Throwable e) {
|
|
110
109
|
Log.e(TAG, "sendCallback: error ",e );
|
|
111
110
|
}
|
|
@@ -203,10 +203,13 @@ static OriginalImpType originalImp;
|
|
|
203
203
|
NSDictionary *userInfo = response.notification.request.content.userInfo;
|
|
204
204
|
NSLog(@"Deeplink Push : STATE 1 inside swizzledidresponse %@",userInfo);
|
|
205
205
|
BOOL appIceServer = [[appICE sharedInstance] isAppICENotification:userInfo];
|
|
206
|
+
NSMutableDictionary *responseDict = [NSMutableDictionary dictionary];
|
|
207
|
+
responseDict[@"userInfo"] = userInfo;
|
|
208
|
+
responseDict[@"actionIdentifier"] = response.actionIdentifier ?: @"";
|
|
206
209
|
if(appIceServer)
|
|
207
210
|
{
|
|
208
211
|
// If yes, Appice plugin will be notified.
|
|
209
|
-
[[AppICEPlugin appice] onHandleNotificationUResponse:
|
|
212
|
+
[[AppICEPlugin appice] onHandleNotificationUResponse:responseDict];
|
|
210
213
|
completionHandler();
|
|
211
214
|
}
|
|
212
215
|
else
|
package/src/ios/AppICEPlugin.h
CHANGED
|
@@ -118,5 +118,9 @@ static NSString* const AIHandleActionNotification = @"AIHandleActionNotification
|
|
|
118
118
|
//INAPP CTA
|
|
119
119
|
- (void)sendClickCallback:(CDVInvokedUrlCommand *)command;
|
|
120
120
|
|
|
121
|
+
//Action Button
|
|
122
|
+
- (void)shareContent:(CDVInvokedUrlCommand *)command;
|
|
123
|
+
- (void)copyContent:(CDVInvokedUrlCommand *)command;
|
|
124
|
+
|
|
121
125
|
@end
|
|
122
126
|
|
package/src/ios/AppICEPlugin.m
CHANGED
|
@@ -1166,7 +1166,7 @@ static NSDictionary *pendingDeeplink = nil;
|
|
|
1166
1166
|
pendingPayload = pendingDeeplink;
|
|
1167
1167
|
}
|
|
1168
1168
|
|
|
1169
|
-
[[appICE sharedInstance] handleClickOnPush:pendingPayload OpenDeepLink:YES];
|
|
1169
|
+
// [[appICE sharedInstance] handleClickOnPush:pendingPayload OpenDeepLink:YES];
|
|
1170
1170
|
[self eventClickedPayload:pendingPayload];
|
|
1171
1171
|
|
|
1172
1172
|
pendingDeeplink = nil;
|
|
@@ -1194,11 +1194,17 @@ static NSDictionary *pendingDeeplink = nil;
|
|
|
1194
1194
|
}
|
|
1195
1195
|
|
|
1196
1196
|
- (void)eventClickedPayload:(NSDictionary *)userInfo {
|
|
1197
|
-
NSDictionary *pushPayload = [userInfo
|
|
1197
|
+
NSDictionary *pushPayload = userInfo[@"userInfo"] ? userInfo[@"userInfo"][@"data"][@"message"] : nil;
|
|
1198
1198
|
if(pushPayload)
|
|
1199
1199
|
{
|
|
1200
|
+
|
|
1201
|
+
Campaign *campaign = [[appICE sharedInstance] handlePush:userInfo openDeepLink:YES];
|
|
1202
|
+
if (campaign) {
|
|
1203
|
+
NSLog(@"Deeplink Push: Campaign processed: %@", campaign);
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1200
1206
|
NSError *error = nil;
|
|
1201
|
-
NSMutableDictionary *payloadKey = [
|
|
1207
|
+
NSMutableDictionary *payloadKey = [campaign toDictionary].mutableCopy;
|
|
1202
1208
|
payloadKey[@"payload"] = pushPayload;
|
|
1203
1209
|
NSData *payloadData = [NSJSONSerialization dataWithJSONObject:payloadKey
|
|
1204
1210
|
options:kNilOptions
|
|
@@ -1215,7 +1221,7 @@ static NSDictionary *pendingDeeplink = nil;
|
|
|
1215
1221
|
}
|
|
1216
1222
|
NSLog(@"Deeplink Push :payloadString string: %@", payloadString);
|
|
1217
1223
|
|
|
1218
|
-
NSString *js = [NSString stringWithFormat:@"pushNotificationClicked
|
|
1224
|
+
NSString *js = [NSString stringWithFormat:@"cordova.fireDocumentEvent('pushNotificationClicked', { payload: %@ });", payloadString];
|
|
1219
1225
|
[self.commandDelegate evalJs:js];
|
|
1220
1226
|
}
|
|
1221
1227
|
else{
|
|
@@ -1644,6 +1650,37 @@ static NSDictionary *pendingDeeplink = nil;
|
|
|
1644
1650
|
}];
|
|
1645
1651
|
}
|
|
1646
1652
|
|
|
1653
|
+
- (void)shareContent:(CDVInvokedUrlCommand *)command {
|
|
1654
|
+
@try {
|
|
1655
|
+
NSDictionary *payload = [command.arguments firstObject];
|
|
1656
|
+
NSString *content = payload[@"content"] ?: @"";
|
|
1657
|
+
NSString *title = payload[@"title"] ?: @"";
|
|
1658
|
+
|
|
1659
|
+
[[appICE sharedInstance] shareActionContent:content withTitle:title];
|
|
1660
|
+
|
|
1661
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
|
1662
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
1663
|
+
} @catch (NSException *exception) {
|
|
1664
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:exception.reason];
|
|
1665
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
|
|
1669
|
+
- (void)copyContent:(CDVInvokedUrlCommand *)command {
|
|
1670
|
+
@try {
|
|
1671
|
+
NSDictionary *payload = [command.arguments firstObject];
|
|
1672
|
+
NSString *text = payload[@"text"] ?: @"";
|
|
1673
|
+
|
|
1674
|
+
[[appICE sharedInstance] copyToClipboard:text];
|
|
1675
|
+
|
|
1676
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
|
1677
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
1678
|
+
|
|
1679
|
+
} @catch (NSException *exception) {
|
|
1680
|
+
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:exception.reason];
|
|
1681
|
+
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1647
1684
|
|
|
1648
1685
|
@end
|
|
1649
1686
|
|
package/www/AppICE.js
CHANGED
|
@@ -412,8 +412,12 @@ AppICE.prototype.getMediaData = function (inboxMessages, mediaKey, success, erro
|
|
|
412
412
|
/*====================
|
|
413
413
|
Push Action
|
|
414
414
|
====================== */
|
|
415
|
-
AppICE.prototype.
|
|
416
|
-
cordova.exec(success, error, "AppICEPlugin", "
|
|
415
|
+
AppICE.prototype.shareContent = function (content,title, success, error) {
|
|
416
|
+
cordova.exec(success, error, "AppICEPlugin", "shareContent", [{"content":content,"title":title}]);
|
|
417
|
+
};
|
|
418
|
+
|
|
419
|
+
AppICE.prototype.copyContent = function (text,success, error) {
|
|
420
|
+
cordova.exec(success, error, "AppICEPlugin", "copyContent", [{"text":text}]);
|
|
417
421
|
};
|
|
418
422
|
|
|
419
423
|
/*===============================
|