Skip to content

Commit

Permalink
Added observer mode flag to launch function + updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
suriksarkisyan committed Mar 5, 2021
1 parent e10506a commit 8fa2633
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 15 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Just add this line to the `Packages/manifest.json` file of your Unity Project:
| -------- | ------------- |
| **Application Access Key** | Qonversion [Application Access Key](https://dash.qonversion.io/project/settings), If debug mode set to true, user purchases will be checked on the sandbox environment and will not be sent to third-party integrations. |
| **Debug Mode** | Set this to true to view the debug logs. (for development only!) |
| **Observer Mode** | Set this to true for this SDK version. |

### Setup with a Launcher

Expand All @@ -56,14 +57,15 @@ Just add this line to the `Packages/manifest.json` file of your Unity Project:
*RECOMMENDED*

Sample code:

```csharp
using QonversionUnity;

public class QonversionLauncher : MonoBehaviour
{
private void Start()
{
Qonversion.Launch(applicationAccessKey);
Qonversion.Launch(applicationAccessKey, true);
}
}
```
Expand Down Expand Up @@ -126,6 +128,9 @@ public class AppsFlyerObjectScript : MonoBehaviour , IAppsFlyerConversionData
}
```

## Documentation
See more info in the [documentation](https://documentation.qonversion.io/docs/observer-mode)

## License

Qonversion SDK is available under the MIT license.
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ public class QonversionWrapper {

private static Handler mUnityMainThreadHandler;

public static synchronized void launch(String projectKey) {
public static synchronized void launch(String projectKey, boolean observerMode) {
Log.d(TAG, "Qonversion Launch starting. Project key: " + projectKey);

Activity unityActivity = UnityPlayer.currentActivity;

Qonversion.launch(unityActivity.getApplication(), projectKey, true, new QonversionLaunchCallback()
Qonversion.launch(unityActivity.getApplication(), projectKey, observerMode, new QonversionLaunchCallback()
{
@Override
public void onSuccess(@NotNull QLaunchResult launchResult) {
Expand Down
4 changes: 2 additions & 2 deletions Runtime/Android/QonversionWrapperAndroid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ namespace QonversionUnity
{
internal class QonversionWrapperAndroid : IQonversionWrapper
{
public void Launch(string projectKey)
public void Launch(string projectKey, bool observerMode)
{
using (var purchases = new AndroidJavaClass("com.qonversion.unitywrapper.QonversionWrapper"))
{
purchases.CallStatic("launch", projectKey);
purchases.CallStatic("launch", projectKey, observerMode);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Runtime/Scripts/IQonversionWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace QonversionUnity
internal interface IQonversionWrapper
{
void SetDebugMode();
void Launch(string projectKey);
void Launch(string projectKey, bool observerMode);
void SetUserID(string userID);
void SyncPurchases();
void AddAttributionData(string conversionData, AttributionSource source);
Expand Down
9 changes: 3 additions & 6 deletions Runtime/Scripts/Qonversion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,21 @@ private static IQonversionWrapper getFinalInstance()
return _Instance;
}

public static void Launch(string apiKey)
public static void Launch(string apiKey, bool observerMode)
{
IQonversionWrapper instance = getFinalInstance();
Debug.Log("INSTAAAANCE LAUNCH:" + instance);
instance.Launch(apiKey);
instance.Launch(apiKey, observerMode);
}

public static void SetDebugMode()
{
IQonversionWrapper instance = getFinalInstance();
Debug.Log("INSTAAAANCE DEBUG:" + instance);
instance.SetDebugMode();
}

public static void SetUserID(string userID)
{
IQonversionWrapper instance = getFinalInstance();
Debug.Log("INSTAAAANCE SETUSERID:" + instance);
instance.SetUserID(userID);
}

Expand All @@ -72,7 +69,7 @@ public static void AddAttributionData(string conversionData, AttributionSource a
private class PurchasesWrapperNoop : IQonversionWrapper
{

public void Launch(string projectKey)
public void Launch(string projectKey, bool observerMode)
{
}

Expand Down
6 changes: 5 additions & 1 deletion Runtime/Scripts/QonversionLauncher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,18 @@ public class QonversionLauncher : MonoBehaviour
[SerializeField]
protected bool m_DebugMode;

[Tooltip("Observer Mode: https://documentation.qonversion.io/docs/observer-mode")]
[SerializeField]
protected bool m_ObserverMode;

private void Start()
{
if (m_DebugMode)
{
Qonversion.SetDebugMode();
}

Qonversion.Launch(m_ApplicationAccessKey);
Qonversion.Launch(m_ApplicationAccessKey, m_ObserverMode);
}
}
}
2 changes: 1 addition & 1 deletion Runtime/iOS/Plugins/QonversionBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ void _setDebugMode() {
[Qonversion setDebugMode];
}

void _launchWithKey(const char* key, const char* userID)
void _launchWithKey(const char* key)
{
[Qonversion launchWithKey:[UtilityBridge сonvertCStringToNSString:key]];
}
Expand Down
2 changes: 1 addition & 1 deletion Runtime/iOS/QonversionWrapperIOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal class QonversionWrapperIOS : IQonversionWrapper
private static extern void _addAttributionData(string conversionData, int provider);
#endif

public void Launch(string projectKey)
public void Launch(string projectKey, bool observerMode)
{
#if UNITY_IOS
_launchWithKey(projectKey);
Expand Down
Binary file modified img/UnityQonversionLauncher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8fa2633

Please sign in to comment.