Skip to content

Commit

Permalink
Merge pull request #98 from qonversion/release/3.5.0
Browse files Browse the repository at this point in the history
Release 3.5.0
  • Loading branch information
SpertsyanKM authored Aug 26, 2022
2 parents 1131dfb + cfcb9c8 commit 7ab2498
Show file tree
Hide file tree
Showing 19 changed files with 243 additions and 7 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/prerelease_github.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Pre-release Github

on:
push:
branches:
- "main"

jobs:
pre-release:
runs-on: macos-latest

steps:
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "latest"
prerelease: true
title: "Development Build"
files: |
LICENSE.txt
*.jar
50 changes: 50 additions & 0 deletions .github/workflows/release_pull_requests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Release pull requests
on:
push:
tags:
- prerelease/*

jobs:
prerelease:
runs-on: macos-latest

steps:
- uses: actions/checkout@v2
name: Checkout all
with:
fetch-depth: 0

- uses: olegtarasov/get-tag@v2.1
id: tagName
with:
tagRegex: 'prerelease\/(\d*\.\d*\.\d*)'

- name: Bump version
run: |
fastlane bump version:${{ steps.tagName.outputs.tag }}
- name: Create pull request
uses: peter-evans/create-pull-request@v3
with:
title: Release ${{ steps.tagName.outputs.tag }}
body: Release PR
labels: autocreated
branch: release/${{ steps.tagName.outputs.tag }}
base: develop

- uses: actions/checkout@v2
with:
ref: main

- name: Reset main branch
run: |
git fetch origin release/${{ steps.tagName.outputs.tag }}:release/${{ steps.tagName.outputs.tag }}
git reset --hard release/${{ steps.tagName.outputs.tag }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
title: Release ${{ steps.tagName.outputs.tag }}
body: Release PR
labels: autocreated
branch: release/${{ steps.tagName.outputs.tag }}
base: main
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.2.4" />
<androidPackage spec="io.qonversion.android.sdk:sdk:3.3.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.18.3" />
<iosPod name="Qonversion" version="2.20.0" />
</iosPods>
</dependencies>
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import com.qonversion.android.sdk.QonversionPermissionsCallback;
import com.qonversion.android.sdk.dto.QLaunchResult;
import com.qonversion.android.sdk.dto.QPermission;
import com.qonversion.android.sdk.dto.QPermissionsCacheLifetime;

import android.preference.PreferenceManager;

Expand Down Expand Up @@ -289,6 +290,15 @@ public static synchronized void removeUpdatedPurchasesDelegate() {
updatedPurchasesListener = null;
}

public static synchronized void setPermissionsCacheLifetime(String lifetimeKey) {
try {
QPermissionsCacheLifetime lifetime = QPermissionsCacheLifetime.valueOf(lifetimeKey);
Qonversion.setPermissionsCacheLifetime(lifetime);
} catch (IllegalArgumentException e) {
Log.e(TAG, "Failed to map QPermissionsCacheLifetime. " + e.getLocalizedMessage());
}
}

public static synchronized void setNotificationsToken(String token) {
Qonversion.setNotificationsToken(token);
}
Expand Down
6 changes: 6 additions & 0 deletions Runtime/Android/QonversionWrapperAndroid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,5 +193,11 @@ public void AddPromoPurchasesDelegate()
public void RemovePromoPurchasesDelegate()
{
}

public void SetPermissionsCacheLifetime(PermissionsCacheLifetime lifetime)
{
string lifetimeName = Enum.GetName(typeof(PermissionsCacheLifetime), lifetime);
CallQonversion("setPermissionsCacheLifetime", lifetimeName);
}
}
}
1 change: 1 addition & 0 deletions Runtime/Scripts/IQonversionWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ internal interface IQonversionWrapper
bool HandleNotification(string notification);
void AddAutomationsDelegate();
void PresentCodeRedemptionSheet();
void SetPermissionsCacheLifetime(PermissionsCacheLifetime lifetime);
}
}
14 changes: 14 additions & 0 deletions Runtime/Scripts/Models/PermissionsCacheLifetime.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace QonversionUnity
{
public enum PermissionsCacheLifetime
{
WEEK,
TWO_WEEKS,
MONTH,
TWO_MONTHS,
THREE_MONTHS,
SIX_MONTHS,
YEAR,
UNLIMITED
}
}
11 changes: 11 additions & 0 deletions Runtime/Scripts/Models/PermissionsCacheLifetime.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Runtime/Scripts/Models/UserProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public enum UserProperty
AdjustAdId,
KochavaDeviceId,
CustomUserId,
FacebookAttribution
FacebookAttribution,
FirebaseAppInstanceId
}
}
17 changes: 15 additions & 2 deletions Runtime/Scripts/Qonversion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class Qonversion : MonoBehaviour
private const string OnOfferingsMethodName = "OnOfferings";
private const string OnEligibilitiesMethodName = "OnEligibilities";

private const string SdkVersion = "3.4.4";
private const string SdkVersion = "3.5.0";
private const string SdkSource = "unity";

private static IQonversionWrapper _Instance;
Expand Down Expand Up @@ -527,6 +527,19 @@ public static void CheckTrialIntroEligibilityForProductIds(IList<string> product
IQonversionWrapper instance = getFinalInstance();
instance.CheckTrialIntroEligibilityForProductIds(productIdsJson, OnEligibilitiesMethodName);
}

/// <summary>
/// Permissions cache is used when there are problems with the Qonversion API
/// or internet connection. If so, Qonversion will return the last successfully loaded
/// permissions. The current method allows you to configure how long that cache may be used.
/// The default value is <see cref="PermissionsCacheLifetime.MONTH>.
/// </summary>
/// <param name="lifetime">Desired permissions cache lifetime duration.</param>
public static void SetPermissionsCacheLifetime(PermissionsCacheLifetime lifetime)
{
IQonversionWrapper instance = getFinalInstance();
instance.SetPermissionsCacheLifetime(lifetime);
}

/// <summary>
/// Set push token to Qonversion to enable Qonversion push notifications
Expand Down Expand Up @@ -797,4 +810,4 @@ private static OnPurchaseResultReceived ConvertPermissionsCallbackToPurchaseResu
};
}
}
}
}
5 changes: 5 additions & 0 deletions Runtime/Scripts/QonversionWrapperNoop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,10 @@ public void PresentCodeRedemptionSheet()
{

}

public void SetPermissionsCacheLifetime(PermissionsCacheLifetime lifetime)
{

}
}
}
1 change: 1 addition & 0 deletions Runtime/iOS/Plugins/Common/UtilityBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@
+ (NSDictionary *)convertActionResult:(QONActionResult *)actionResult;
+ (NSDictionary *)convertError:(NSError *)error;
+ (NSDictionary *)convertAutomationsEvent:(QONAutomationsEvent *)event;
+ (NSNumber *)convertPermissionsCacheLifetime:(NSString *)lifetimeKey;

@end
17 changes: 17 additions & 0 deletions Runtime/iOS/Plugins/Common/UtilityBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ + (NSNumber *)convertProperty:(NSString *)propertyStr {
@"AdjustAdId": @(QNPropertyAdjustUserID),
@"KochavaDeviceId": @(QNPropertyKochavaDeviceID),
@"CustomUserId": @(QNPropertyUserID),
@"FirebaseAppInstanceId": @(QNPropertyFirebaseAppInstanceId),
};

NSNumber *propertyIndex = propertiesDict[propertyStr];
Expand Down Expand Up @@ -397,4 +398,20 @@ + (NSDictionary *)convertAutomationsEvent:(QONAutomationsEvent *)event {
return [result copy];
}

+ (NSNumber *)convertPermissionsCacheLifetime:(NSString *)lifetimeKey {
NSDictionary *lifetimesDict = @{
@"WEEK": @(QNPermissionsCacheLifetimeWeek),
@"TWO_WEEKS": @(QNPermissionsCacheLifetimeTwoWeeks),
@"MONTH": @(QNPermissionsCacheLifetimeMonth),
@"TWO_MONTHS": @(QNPermissionsCacheLifetimeTwoMonth),
@"THREE_MONTHS": @(QNPermissionsCacheLifetimeThreeMonth),
@"SIX_MONTHS": @(QNPermissionsCacheLifetimeSixMonth),
@"YEAR": @(QNPermissionsCacheLifetimeYear),
@"UNLIMITED": @(QNPermissionsCacheLifetimeUnlimited),
};

NSNumber *lifetimeIndex = lifetimesDict[lifetimeKey];
return lifetimeIndex;
}

@end
9 changes: 9 additions & 0 deletions Runtime/iOS/Plugins/QonversionBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,15 @@ void _removeUpdatedPurchasesDelegate() {
purchasesDelegate = nil;
}

void _setPermissionsCacheLifetime(const char* lifetimeName) {
NSString *lifetimeNameStr = [UtilityBridge сonvertCStringToNSString:lifetimeName];
NSNumber *lifetimeIndex = [UtilityBridge convertPermissionsCacheLifetime:lifetimeNameStr];

if (lifetimeIndex) {
[Qonversion setPermissionsCacheLifetime:lifetimeIndex.integerValue];
}
}

void _setNotificationsToken(const char* token) {
NSString *hexString = [UtilityBridge сonvertCStringToNSString:token];
NSData *tokenData = [UtilityBridge convertHexToData:hexString];
Expand Down
13 changes: 12 additions & 1 deletion Runtime/iOS/QonversionWrapperIOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ internal class QonversionWrapperIOS : IQonversionWrapper

[DllImport("__Internal")]
private static extern void _presentCodeRedemptionSheet();

[DllImport("__Internal")]
private static extern void _setPermissionsCacheLifetime(string lifetimeKey);
#endif

public void StoreSdkInfo(string version, string versionKey, string source, string sourceKey)
Expand Down Expand Up @@ -131,8 +134,8 @@ public void SetUserProperty(string key, string value)

public void SetProperty(UserProperty key, string value)
{
string propertyName = Enum.GetName(typeof(UserProperty), key);
#if UNITY_IOS
string propertyName = Enum.GetName(typeof(UserProperty), key);
_setProperty(propertyName, value);
#endif
}
Expand Down Expand Up @@ -284,6 +287,14 @@ public void AddAutomationsDelegate()
{
#if UNITY_IOS
_subscribeAutomationsDelegate();
#endif
}

public void SetPermissionsCacheLifetime(PermissionsCacheLifetime lifetime)
{
#if UNITY_IOS
string lifetimeName = Enum.GetName(typeof(PermissionsCacheLifetime), lifetime);
_setPermissionsCacheLifetime(lifetimeName);
#endif
}
}
Expand Down
30 changes: 30 additions & 0 deletions fastlane/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
fastlane documentation
----

# Installation

Make sure you have the latest version of the Xcode command line tools installed:

```sh
xcode-select --install
```

For _fastlane_ installation instructions, see [Installing _fastlane_](https://docs.fastlane.tools/#installing-fastlane)

# Available Actions

### bump

```sh
[bundle exec] fastlane bump
```



----

This README.md is auto-generated and will be re-generated every time [_fastlane_](https://fastlane.tools) is run.

More information about _fastlane_ can be found on [fastlane.tools](https://fastlane.tools).

The documentation of _fastlane_ can be found on [docs.fastlane.tools](https://docs.fastlane.tools).
28 changes: 28 additions & 0 deletions fastlane/fastfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
def update_package_json(new_version)
path = "../package.json"
regex = /"version": ".*",/
result_value = "\"version\": \"#{new_version}\","

update_file(path, regex, result_value)
end

def update_constant(new_version)
path = "../Runtime/Scripts/Qonversion.cs"
regex = /private const string SdkVersion = ".*";/
result_value = "private const string SdkVersion = \"#{new_version}\";"

update_file(path, regex, result_value)
end

def update_file(path, regex, result_value)
file = File.read(path)
new_content = file.gsub(regex, result_value)
File.open(path, 'w') { |line| line.puts new_content }
end

lane :bump do |options|
new_version = options[:version]

update_package_json(new_version)
update_constant(new_version)
end
8 changes: 8 additions & 0 deletions fastlane/report.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite name="fastlane.lanes">



</testsuite>
</testsuites>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "com.qonversion.unity",
"displayName": "Qonversion",
"version": "3.4.4",
"version": "3.5.0",
"unity": "2018.3",
"description": "Empower your mobile app marketing and product decisions with precise subscription data.",
"author": {
Expand Down

0 comments on commit 7ab2498

Please sign in to comment.