cordova-plugin-appice 2.3.0 → 2.3.1
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/js/index.js
CHANGED
|
@@ -84,6 +84,10 @@ function onDeviceReady() {
|
|
|
84
84
|
console.error("Error in click callback:", err);
|
|
85
85
|
});
|
|
86
86
|
|
|
87
|
+
document.addEventListener("AppICEInAppClicked", function (event) {
|
|
88
|
+
console.log("[INAPP] Received AppICEInAppClicked", event);
|
|
89
|
+
});
|
|
90
|
+
|
|
87
91
|
document.addEventListener('pause', function () {
|
|
88
92
|
console.log("App is in background, calling suspendInApp");
|
|
89
93
|
AppICE.suspendInApp(
|
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.3.
|
|
3
|
+
id="cordova-plugin-appice" version="2.3.1">
|
|
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.22" />
|
|
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.
|
|
124
|
+
<preference name="APPICE_VERSION" default="2.6.41"/>
|
|
125
125
|
|
|
126
126
|
<!-- CloudMessaging -->
|
|
127
127
|
<preference name="CLOUD_MESSAGING" default="17.0.2"/>
|
|
@@ -139,16 +139,9 @@
|
|
|
139
139
|
<receiver android:name="com.appice.cordova.CampaignCampsReceiver"
|
|
140
140
|
android:exported="false" android:protectionLevel="signature">
|
|
141
141
|
<intent-filter>
|
|
142
|
-
<action android:name="com.appice.campaignEvent" />
|
|
142
|
+
<action android:name="com.appice.inapp.campaignEvent" />
|
|
143
143
|
</intent-filter>
|
|
144
144
|
</receiver>
|
|
145
|
-
<service android:name="com.appice.cordova.NotificationEventService"
|
|
146
|
-
android:protectionLevel="signature"
|
|
147
|
-
android:exported="false" android:permission="android.permission.BIND_JOB_SERVICE">
|
|
148
|
-
<intent-filter>
|
|
149
|
-
<action android:name="com.appice.campaignEvent" />
|
|
150
|
-
</intent-filter>
|
|
151
|
-
</service>
|
|
152
145
|
|
|
153
146
|
<activity android:name="semusi.context.ui.UIEventsHandler" android:exported="false" android:protectionLevel="signature" android:theme="@android:style/Theme.Translucent.NoTitleBar"/>
|
|
154
147
|
|
|
@@ -180,7 +173,7 @@
|
|
|
180
173
|
<source-file src="src/android/AppICEPlugin.java" target-dir="com/appice/cordova/" />
|
|
181
174
|
<source-file src="src/android/ClickCallback.java" target-dir="com/appice/cordova/" />
|
|
182
175
|
<source-file src="src/android/CampaignCampsReceiver.java" target-dir="com/appice/cordova/" />
|
|
183
|
-
<source-file src="src/android/
|
|
176
|
+
<source-file src="src/android/AppLifecycleObserver.java" target-dir="com/appice/cordova/" />
|
|
184
177
|
|
|
185
178
|
<!-- DEPENDENCIES -->
|
|
186
179
|
<framework src="com.google.firebase:firebase-messaging:$FIREBASE_MESSAGING_VERSION" />
|
|
@@ -2,6 +2,7 @@ package com.appice.cordova;
|
|
|
2
2
|
|
|
3
3
|
import static com.appice.cordova.AppICEPushHandler.handleLandingPage;
|
|
4
4
|
import android.content.Context;
|
|
5
|
+
import com.google.firebase.FirebaseApp;
|
|
5
6
|
import android.content.Intent;
|
|
6
7
|
import android.content.SharedPreferences;
|
|
7
8
|
import android.content.pm.PackageManager;
|
|
@@ -46,8 +47,8 @@ import semusi.context.ui.appInbox.AppICEInboxMessage;
|
|
|
46
47
|
import semusi.context.ui.appInbox.IAppICESuccessCallback;
|
|
47
48
|
import semusi.activitysdk.IAppICEDataCallback;
|
|
48
49
|
|
|
49
|
-
import androidx.
|
|
50
|
-
|
|
50
|
+
import androidx.lifecycle.ProcessLifecycleOwner;
|
|
51
|
+
|
|
51
52
|
import semusi.model.campaign.Campaign;
|
|
52
53
|
import semusi.model.campaign.Action;
|
|
53
54
|
|
|
@@ -295,10 +296,17 @@ public void onNewIntent(Intent intent) {
|
|
|
295
296
|
@CordovaMethod
|
|
296
297
|
private void isDeviceReady(JSONArray data, CallbackContext callbackContext) {
|
|
297
298
|
try {
|
|
299
|
+
boolean flag = data.optBoolean(0);
|
|
298
300
|
if (statusFlag == false) {
|
|
299
301
|
checkIfAnyPendingCallback(cordova.getActivity());
|
|
300
302
|
}
|
|
301
|
-
statusFlag =
|
|
303
|
+
statusFlag = flag;
|
|
304
|
+
cordova.getActivity().runOnUiThread(() -> {
|
|
305
|
+
ProcessLifecycleOwner.get().getLifecycle()
|
|
306
|
+
.addObserver(new AppLifecycleObserver(
|
|
307
|
+
cordova.getActivity().getApplicationContext()
|
|
308
|
+
));
|
|
309
|
+
});
|
|
302
310
|
callbackContext.success();
|
|
303
311
|
} catch (Throwable e) {
|
|
304
312
|
callbackContext.error(e.getMessage());
|
|
@@ -1658,4 +1666,13 @@ public void onNewIntent(Intent intent) {
|
|
|
1658
1666
|
callbackContext.error(e.getMessage());
|
|
1659
1667
|
}
|
|
1660
1668
|
}
|
|
1669
|
+
|
|
1670
|
+
public void sendEvent(String key, Object json) {
|
|
1671
|
+
if (mwebView != null) {
|
|
1672
|
+
mwebView.getView().post(() -> {
|
|
1673
|
+
String js = "javascript:cordova.fireDocumentEvent('" + key + "'," + json + ");";
|
|
1674
|
+
mwebView.loadUrl(js);
|
|
1675
|
+
});
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1661
1678
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
package com.appice.cordova;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
|
|
5
|
+
import androidx.annotation.NonNull;
|
|
6
|
+
import androidx.lifecycle.DefaultLifecycleObserver;
|
|
7
|
+
import androidx.lifecycle.LifecycleOwner;
|
|
8
|
+
|
|
9
|
+
import semusi.activitysdk.ContextSdk;
|
|
10
|
+
|
|
11
|
+
public class AppLifecycleObserver implements DefaultLifecycleObserver {
|
|
12
|
+
|
|
13
|
+
private final Context appContext;
|
|
14
|
+
|
|
15
|
+
public static volatile boolean isDeviceReady = false;
|
|
16
|
+
|
|
17
|
+
public AppLifecycleObserver(Context context) {
|
|
18
|
+
this.appContext = context.getApplicationContext();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@Override
|
|
22
|
+
public void onResume(@NonNull LifecycleOwner owner) {
|
|
23
|
+
System.out.println("AppCycle : onResume");
|
|
24
|
+
new AppICEPlugin().sendEvent("onForeground", true);
|
|
25
|
+
ContextSdk.resumeInApp(appContext);
|
|
26
|
+
ContextSdk.checkIfDeviceRegisterToFCM(appContext);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@Override
|
|
30
|
+
public void onPause(@NonNull LifecycleOwner owner) {
|
|
31
|
+
System.out.println("AppCycle : onPause");
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@Override
|
|
35
|
+
public void onStop(@NonNull LifecycleOwner owner) {
|
|
36
|
+
System.out.println("AppCycle : onStop");
|
|
37
|
+
new AppICEPlugin().sendEvent("onBackground", true);
|
|
38
|
+
ContextSdk.discardInApp(appContext);
|
|
39
|
+
ContextSdk.checkIfDeviceRegisterToFCM(appContext);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -50,26 +50,12 @@ public class CampaignCampsReceiver extends BroadcastReceiver {
|
|
|
50
50
|
if (clickCallback != null) {
|
|
51
51
|
clickCallback.clickPayload(cdataObject);
|
|
52
52
|
Utility.loginfo("CampaignRec : clickCallback "+cdata);
|
|
53
|
+
new AppICEPlugin().sendEvent("AppICEInAppClicked", cdataObject);
|
|
53
54
|
} else
|
|
54
55
|
Utility.loginfo("callback is null");
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
|
-
|
|
58
|
-
// gather deeplink data
|
|
59
|
-
if (url != null && url.length() > 0) {
|
|
60
|
-
HashMap<String, Object> deeplinkData = ContextSdk.gatherDeepLinkData(Uri.parse(url));
|
|
61
|
-
Set<String> keys = deeplinkData.keySet();
|
|
62
|
-
for (String key : keys) {
|
|
63
|
-
try {
|
|
64
|
-
json.put(key, deeplinkData.get(key));
|
|
65
|
-
} catch (Throwable e) {
|
|
66
|
-
Log.e(TAG, "sendCallback: error ",e );
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
} catch (Throwable e) {
|
|
71
|
-
Log.e(TAG, "sendCallback: error ",e );
|
|
72
|
-
}
|
|
58
|
+
|
|
73
59
|
|
|
74
60
|
// Gather extra data from json object root
|
|
75
61
|
try {
|
package/src/ios/AppICEPlugin.m
CHANGED
|
@@ -1635,13 +1635,27 @@ static NSDictionary *pendingDeeplink = nil;
|
|
|
1635
1635
|
|
|
1636
1636
|
[[appICE sharedInstance] setClickCallback:^(NSDictionary *cData) {
|
|
1637
1637
|
NSLog(@"Cordova Plugin: Received click callback %@", cData);
|
|
1638
|
-
|
|
1638
|
+
// 1) Existing callback flow
|
|
1639
1639
|
if (self.clickCallbackId != nil && cData != nil) {
|
|
1640
1640
|
CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:cData];
|
|
1641
1641
|
[result setKeepCallbackAsBool:YES]; // Keep callback for future events
|
|
1642
1642
|
[self.commandDelegate sendPluginResult:result callbackId:self.clickCallbackId];
|
|
1643
1643
|
}
|
|
1644
|
-
}
|
|
1644
|
+
}
|
|
1645
|
+
|
|
1646
|
+
// 2) New event flow (added)
|
|
1647
|
+
NSError *error = nil;
|
|
1648
|
+
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:cData options:0 error:&error];
|
|
1649
|
+
if (!error && jsonData) {
|
|
1650
|
+
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
|
1651
|
+
if (jsonString) {
|
|
1652
|
+
NSString *js = [NSString stringWithFormat:
|
|
1653
|
+
@"cordova.fireDocumentEvent('AppICEInAppClicked', %@);",
|
|
1654
|
+
jsonString];
|
|
1655
|
+
[self.commandDelegate evalJs:js];
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
];
|
|
1645
1659
|
|
|
1646
1660
|
// Initial response to JS to keep callback open
|
|
1647
1661
|
CDVPluginResult *initialResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_NO_RESULT];
|