Skip to content

Commit

Permalink
Merge pull request #106 from qonversion/release/3.6.0
Browse files Browse the repository at this point in the history
Release 3.6.0
  • Loading branch information
SpertsyanKM authored Sep 12, 2022
2 parents 4f05cfc + ebc02bf commit 6a1701f
Show file tree
Hide file tree
Showing 32 changed files with 502 additions and 1,518 deletions.
4 changes: 2 additions & 2 deletions Editor/QonversionDependencies.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<dependencies>
<androidPackages>
<androidPackage spec="io.qonversion.android.sdk:sdk:3.3.0" />
<androidPackage spec="io.qonversion.sandwich:sandwich:0.1.0" />
<androidPackage spec="com.fasterxml.jackson.core:jackson-databind:2.11.1" />
<androidPackage spec="org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.61" />
</androidPackages>
<iosPods>
<iosPod name="Qonversion" version="2.20.0" />
<iosPod name="QonversionSandwich" version="0.1.0" />
</iosPods>
</dependencies>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package com.qonversion.unitywrapper;

import android.util.Log;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.fasterxml.jackson.core.JsonProcessingException;

import org.jetbrains.annotations.NotNull;

import java.util.HashMap;
import java.util.Map;

import io.qonversion.sandwich.AutomationsEventListener;
import io.qonversion.sandwich.AutomationsSandwich;

public class AutomationsWrapper implements AutomationsEventListener {
private static final String EVENT_SCREEN_SHOWN = "OnAutomationsScreenShown";
private static final String EVENT_ACTION_STARTED = "OnAutomationsActionStarted";
private static final String EVENT_ACTION_FAILED = "OnAutomationsActionFailed";
private static final String EVENT_ACTION_FINISHED = "OnAutomationsActionFinished";
private static final String EVENT_AUTOMATIONS_FINISHED = "OnAutomationsFinished";

public static String TAG = "AutomationsDelegate";
private final MessageSender messageSender;
private final AutomationsSandwich automationsSandwich;

public AutomationsWrapper(MessageSender messageSender) {
this.messageSender = messageSender;
automationsSandwich = new AutomationsSandwich();
}

public void subscribe() {
automationsSandwich.subscribe(this);
}

@Override
public void onAutomationEvent(@NonNull Event event, @Nullable Map<String, ?> data) {
String methodName = "";
switch (event) {
case ScreenShown:
methodName = EVENT_SCREEN_SHOWN;
break;
case ActionStarted:
methodName = EVENT_ACTION_STARTED;
break;
case ActionFinished:
methodName = EVENT_ACTION_FINISHED;
break;
case ActionFailed:
methodName = EVENT_ACTION_FAILED;
break;
case AutomationsFinished:
methodName = EVENT_AUTOMATIONS_FINISHED;
break;
default:
return;
}

sendMessageToUnity(data == null ? new HashMap<>() : data, methodName);
}

private void sendMessageToUnity(@NotNull Object objectToConvert, @NotNull String methodName) {
try {
messageSender.sendMessageToUnity(objectToConvert, methodName);
} catch (JsonProcessingException e) {
handleException(e);
}
}

private void handleException(Exception e) {
Log.e(TAG, "An error occurred while processing automations flow: " + e.getLocalizedMessage());
}
}
Loading

0 comments on commit 6a1701f

Please sign in to comment.