Skip to content

Commit d52e258

Browse files
Merge pull request #313 from qonversion/release/9.6.0
Release 9.6.0
2 parents 7c04d1c + 87af2dc commit d52e258

22 files changed

Lines changed: 112 additions & 21 deletions

Editor/QonversionDependencies.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<dependencies>
33
<androidPackages>
4-
<androidPackage spec="io.qonversion:sandwich:7.8.2" />
4+
<androidPackage spec="io.qonversion:sandwich:7.9.0" />
55
<androidPackage spec="com.fasterxml.jackson.core:jackson-databind:2.11.1" />
66
<androidPackage spec="org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.61" />
77
</androidPackages>
88
<iosPods>
9-
<iosPod name="QonversionSandwich" version="7.8.2" />
9+
<iosPod name="QonversionSandwich" version="7.9.0" />
1010
</iosPods>
1111
</dependencies>

Runtime/Android/Plugins/com/qonversion/unitywrapper/MessageSender.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,8 @@ void sendMessageToUnity(@NotNull Object objectToConvert, @NotNull String methodN
1818
final String json = mapper.writeValueAsString(objectToConvert);
1919
UnityPlayer.UnitySendMessage(unityListenerName, methodName, json);
2020
}
21+
22+
public String getListenerName() {
23+
return unityListenerName;
24+
}
2125
}

Runtime/Android/Plugins/com/qonversion/unitywrapper/NoCodesWrapper.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,24 @@ public static synchronized void setScreenPresentationConfig(String configJson, S
9292
}
9393
}
9494

95-
public static synchronized void showScreen(String contextKey) {
95+
public static synchronized void showScreen(String contextKey, String customVariablesJson) {
9696
if (noCodesSandwich == null) {
9797
Log.e(TAG, "NoCodesSandwich is not initialized");
9898
return;
9999
}
100100

101-
noCodesSandwich.showScreen(contextKey);
101+
Map<String, String> customVariables = null;
102+
if (customVariablesJson != null && !customVariablesJson.isEmpty()) {
103+
try {
104+
ObjectMapper mapper = new ObjectMapper();
105+
TypeReference<HashMap<String, String>> typeRef = new TypeReference<HashMap<String, String>>() {};
106+
customVariables = mapper.readValue(customVariablesJson, typeRef);
107+
} catch (JsonProcessingException e) {
108+
Log.e(TAG, "Failed to parse custom variables: " + e.getLocalizedMessage());
109+
}
110+
}
111+
112+
noCodesSandwich.showScreen(contextKey, customVariables);
102113
}
103114

104115
public static synchronized void close() {

Runtime/Android/Plugins/com/qonversion/unitywrapper/QonversionWrapper.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ public static synchronized void userProperties(String unityCallbackName) {
9898
qonversionSandwich.userProperties(getResultListener(unityCallbackName));
9999
}
100100

101+
public static synchronized void forceSendProperties(String unityCallbackName) {
102+
qonversionSandwich.forceSendProperties(() -> {
103+
UnityPlayer.UnitySendMessage(messageSender.getListenerName(), unityCallbackName, "");
104+
return null;
105+
});
106+
}
107+
101108
public static synchronized void attribution(String conversionData, String attributionProvider) {
102109
try {
103110
ObjectMapper mapper = new ObjectMapper();

Runtime/Android/QonversionWrapperAndroid.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ public void UserProperties(string callbackName)
5555
CallQonversion("userProperties", callbackName);
5656
}
5757

58+
public void ForceSendProperties(string callbackName)
59+
{
60+
CallQonversion("forceSendProperties", callbackName);
61+
}
62+
5863
public void SyncPurchases()
5964
{
6065
using (var purchases = new AndroidJavaClass("com.qonversion.unitywrapper.QonversionWrapper"))

Runtime/Scripts/IQonversion.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,14 @@ AttributionProvider attributionProvider
283283
/// <param name="callback">Callback that will be called when response is received</param>
284284
public void UserProperties(Qonversion.OnUserPropertiesReceived callback);
285285

286+
/// <summary>
287+
/// Force-flushes any pending user property updates to the server immediately.
288+
/// Use this when you need to ensure all previously set properties have been sent
289+
/// before performing an operation that depends on them.
290+
/// </summary>
291+
/// <param name="callback">Callback that will be called when the flush is complete.</param>
292+
public void ForceSendProperties(Qonversion.OnForceSendPropertiesCompleted callback);
293+
286294
/// <summary>
287295
/// iOS only.
288296
/// On iOS 14.5+, after requesting the app tracking entitlement using ATT, you need to notify Qonversion if tracking

Runtime/Scripts/Internal/QonversionInternal.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@ internal class QonversionInternal : MonoBehaviour, IQonversion
2222
private const string OnIdentityMethodName = "OnIdentity";
2323
private const string OnUserInfoMethodName = "OnUserInfo";
2424
private const string OnUserPropertiesMethodName = "OnUserProperties";
25+
private const string OnForceSendPropertiesMethodName = "OnForceSendProperties";
2526
private const string OnAttachUserMethodName = "OnAttachUser";
2627
private const string OnDetachUserMethodName = "OnDetachUser";
2728
private const string OnIsFallbackFileAccessibleMethodName = "OnIsFallbackFileAccessible";
2829
private const string OnPromotionalOfferMethodName = "OnPromotionalOffer";
2930

30-
private const string SdkVersion = "9.5.1";
31+
private const string SdkVersion = "9.6.0";
3132
private const string SdkSource = "unity";
3233

3334
private const string DefaultRemoteConfigContextKey = "";
@@ -52,6 +53,7 @@ internal class QonversionInternal : MonoBehaviour, IQonversion
5253
private Qonversion.OnUserInfoReceived IdentityCallback { get; set; }
5354
private Qonversion.OnUserInfoReceived UserInfoCallback { get; set; }
5455
private Qonversion.OnUserPropertiesReceived UserPropertiesCallback { get; set; }
56+
private Qonversion.OnForceSendPropertiesCompleted ForceSendPropertiesCallback { get; set; }
5557
private Qonversion.OnAttachUserResponseReceived AttachUserCallback { get; set; }
5658
private Qonversion.OnAttachUserResponseReceived DetachUserCallback { get; set; }
5759
private Qonversion.OnFallbackFileAccessibilityResponseReceived FallbackFileCallback { get; set; }
@@ -340,6 +342,13 @@ public void UserProperties(Qonversion.OnUserPropertiesReceived callback)
340342
instance.UserProperties(OnUserPropertiesMethodName);
341343
}
342344

345+
public void ForceSendProperties(Qonversion.OnForceSendPropertiesCompleted callback)
346+
{
347+
ForceSendPropertiesCallback = callback;
348+
IQonversionWrapper instance = GetNativeWrapper();
349+
instance.ForceSendProperties(OnForceSendPropertiesMethodName);
350+
}
351+
343352
public void CollectAdvertisingId()
344353
{
345354
IQonversionWrapper instance = GetNativeWrapper();
@@ -666,6 +675,13 @@ private void OnUserProperties(string jsonString)
666675
UserPropertiesCallback = null;
667676
}
668677

678+
// Called from the native SDK - Called when forceSendProperties completes
679+
private void OnForceSendProperties(string _)
680+
{
681+
ForceSendPropertiesCallback?.Invoke();
682+
ForceSendPropertiesCallback = null;
683+
}
684+
669685
// Called from the native SDK - Called when entitlements update. For example, when pending purchases like SCA, Ask to buy, etc., happen.
670686
private void OnReceivedUpdatedEntitlements(string jsonString)
671687
{

Runtime/Scripts/Internal/wrappers/qonversion/IQonversionWrapper.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ internal interface IQonversionWrapper
1414
void SetUserProperty(UserPropertyKey key, string value);
1515
void SetCustomUserProperty(string key, string value);
1616
void UserProperties(string callbackName);
17+
void ForceSendProperties(string callbackName);
1718
void SyncPurchases();
1819
void AddAttributionData(string conversionData, string providerName);
1920
void CheckEntitlements(string callbackName);

Runtime/Scripts/Internal/wrappers/qonversion/QonversionWrapperNoop.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ public void UserProperties(string callbackName)
3131
{
3232
}
3333

34+
public void ForceSendProperties(string callbackName)
35+
{
36+
}
37+
3438
public void AddAttributionData(string conversionData, string providerName)
3539
{
3640
}

Runtime/Scripts/NoCodes/Android/NoCodesWrapperAndroid.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ public void SetScreenPresentationConfig(string configJson, string contextKey)
2121
CallNoCodes("setScreenPresentationConfig", configJson, contextKey ?? "");
2222
}
2323

24-
public void ShowScreen(string contextKey)
24+
public void ShowScreen(string contextKey, string customVariablesJson)
2525
{
26-
CallNoCodes("showScreen", contextKey);
26+
CallNoCodes("showScreen", contextKey, customVariablesJson ?? "");
2727
}
2828

2929
public void Close()

0 commit comments

Comments
 (0)