Skip to content

Commit

Permalink
Merge pull request #328 from qonversion/release/3.1.0
Browse files Browse the repository at this point in the history
Release 3.1.0
  • Loading branch information
suriksarkisyan authored Jan 23, 2023
2 parents 0ba80fa + e9e8afa commit 64c83a7
Show file tree
Hide file tree
Showing 26 changed files with 315 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Framework/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>3.0.4</string>
<string>3.1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
2 changes: 2 additions & 0 deletions Framework/QonversionFramework.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

#import <Qonversion/QONAutomations.h>
#import <Qonversion/QONAutomationsDelegate.h>
#import <Qonversion/QONScreenCustomizationDelegate.h>
#import <Qonversion/QONScreenPresentationConfiguration.h>
#import <Qonversion/QONActionResult.h>

#import <Qonversion/QONUser.h>
1 change: 1 addition & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ let sources: [String] = ["Qonversion/Automations/Constants",
"Qonversion/Automations/Services/QONAutomationsScreenProcessor",
"Qonversion/Automations/Services/QONAutomationsService",
"Qonversion/Automations/Views",
"Qonversion/Automations/Views/QONAutomationsNavigationController",
"Qonversion/Automations/Views/QONAutomationsViewController",
"Qonversion/Automations/Services/QONNotificationsService",
"Qonversion/IDFA",
Expand Down
2 changes: 1 addition & 1 deletion Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: cd1911d751c59f56b7f0243af0b5eba4ce54bf26

COCOAPODS: 1.11.2
COCOAPODS: 1.11.3
4 changes: 2 additions & 2 deletions Qonversion.podspec
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Pod::Spec.new do |s|
excluded_files = ['Sources/Qonversion/Automations', 'Sources/Qonversion/Public/QONAutomations*.{h,m}', 'Sources/Qonversion/Public/QONActionResult.{h,m}']
excluded_files = ['Sources/Qonversion/Automations', 'Sources/Qonversion/Public/QONAutomations*.{h,m}', 'Sources/Qonversion/Public/QONActionResult.{h,m}', 'Sources/Qonversion/Public/QONScreen*.{h,m}']
idfa_exclude_files = ['Sources/Qonversion/IDFA']
s.name = 'Qonversion'
s.version = '3.0.4'
s.version = '3.1.0'
s.summary = 'qonversion.io'
s.description = <<-DESC
Deep Analytics for iOS Subscriptions
Expand Down
28 changes: 28 additions & 0 deletions Qonversion.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
700EC173291277130032E205 /* QONExperimentGroup+Protected.h in Headers */ = {isa = PBXBuildFile; fileRef = 700EC171291277130032E205 /* QONExperimentGroup+Protected.h */; };
702394912923EBF3003126D5 /* QONNotificationsService.h in Headers */ = {isa = PBXBuildFile; fileRef = 7023948F2923EBF3003126D5 /* QONNotificationsService.h */; };
702394922923EBF3003126D5 /* QONNotificationsService.m in Sources */ = {isa = PBXBuildFile; fileRef = 702394902923EBF3003126D5 /* QONNotificationsService.m */; };
702BF8B629531A68000B6C3E /* QONScreenCustomizationDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 702BF8B529531A68000B6C3E /* QONScreenCustomizationDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
70ADE70F2951CC7200CB4D2E /* QONScreenPresentationConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 70ADE70D2951CC7200CB4D2E /* QONScreenPresentationConfiguration.h */; settings = {ATTRIBUTES = (Public, ); }; };
70ADE7102951CC7200CB4D2E /* QONScreenPresentationConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = 70ADE70E2951CC7200CB4D2E /* QONScreenPresentationConfiguration.m */; };
70B9A9F1297AB8A700BD30FD /* QONAutomationsNavigationController.h in Headers */ = {isa = PBXBuildFile; fileRef = 70B9A9EF297AB8A700BD30FD /* QONAutomationsNavigationController.h */; };
70B9A9F2297AB8A700BD30FD /* QONAutomationsNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 70B9A9F0297AB8A700BD30FD /* QONAutomationsNavigationController.m */; };
70D0E2B8291A9BE3004E8DE8 /* QONConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 70D0E2B6291A9BE3004E8DE8 /* QONConfiguration.h */; settings = {ATTRIBUTES = (Public, ); }; };
70D0E2B9291A9BE3004E8DE8 /* QONConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = 70D0E2B7291A9BE3004E8DE8 /* QONConfiguration.m */; };
70D0E2BB291AA21C004E8DE8 /* QONLaunchMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 70D0E2BA291AA21C004E8DE8 /* QONLaunchMode.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -287,6 +292,11 @@
700EC171291277130032E205 /* QONExperimentGroup+Protected.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "QONExperimentGroup+Protected.h"; sourceTree = "<group>"; };
7023948F2923EBF3003126D5 /* QONNotificationsService.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = QONNotificationsService.h; sourceTree = "<group>"; };
702394902923EBF3003126D5 /* QONNotificationsService.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = QONNotificationsService.m; sourceTree = "<group>"; };
702BF8B529531A68000B6C3E /* QONScreenCustomizationDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = QONScreenCustomizationDelegate.h; sourceTree = "<group>"; };
70ADE70D2951CC7200CB4D2E /* QONScreenPresentationConfiguration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = QONScreenPresentationConfiguration.h; sourceTree = "<group>"; };
70ADE70E2951CC7200CB4D2E /* QONScreenPresentationConfiguration.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = QONScreenPresentationConfiguration.m; sourceTree = "<group>"; };
70B9A9EF297AB8A700BD30FD /* QONAutomationsNavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = QONAutomationsNavigationController.h; sourceTree = "<group>"; };
70B9A9F0297AB8A700BD30FD /* QONAutomationsNavigationController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = QONAutomationsNavigationController.m; sourceTree = "<group>"; };
70D0E2B6291A9BE3004E8DE8 /* QONConfiguration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = QONConfiguration.h; sourceTree = "<group>"; };
70D0E2B7291A9BE3004E8DE8 /* QONConfiguration.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = QONConfiguration.m; sourceTree = "<group>"; };
70D0E2BA291AA21C004E8DE8 /* QONLaunchMode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = QONLaunchMode.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -682,6 +692,15 @@
path = QONNotificationsService;
sourceTree = "<group>";
};
70B9A9EE297AB86400BD30FD /* QONAutomationsNavigationController */ = {
isa = PBXGroup;
children = (
70B9A9EF297AB8A700BD30FD /* QONAutomationsNavigationController.h */,
70B9A9F0297AB8A700BD30FD /* QONAutomationsNavigationController.m */,
);
path = QONAutomationsNavigationController;
sourceTree = "<group>";
};
891DEA7E2703AF1D0079B439 /* Mappers */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -716,6 +735,9 @@
70F07B1A28AD085600A45D41 /* QONEntitlementsCacheLifetime.h */,
895731B926DD03A2009507A6 /* QONUser.h */,
895731BA26DD03A2009507A6 /* QONAutomationsDelegate.h */,
70ADE70D2951CC7200CB4D2E /* QONScreenPresentationConfiguration.h */,
70ADE70E2951CC7200CB4D2E /* QONScreenPresentationConfiguration.m */,
702BF8B529531A68000B6C3E /* QONScreenCustomizationDelegate.h */,
895731BB26DD03A2009507A6 /* QONOfferings.m */,
895731BC26DD03A2009507A6 /* QONIntroEligibility.h */,
895731BD26DD03A2009507A6 /* QONExperimentInfo.m */,
Expand Down Expand Up @@ -883,6 +905,7 @@
895731FD26DD03A3009507A6 /* Views */ = {
isa = PBXGroup;
children = (
70B9A9EE297AB86400BD30FD /* QONAutomationsNavigationController */,
895731FE26DD03A3009507A6 /* QONAutomationsViewController */,
);
path = Views;
Expand Down Expand Up @@ -1328,6 +1351,7 @@
buildActionMask = 2147483647;
files = (
895732F026DD03A3009507A6 /* QNErrorsMapper.h in Headers */,
70B9A9F1297AB8A700BD30FD /* QONAutomationsNavigationController.h in Headers */,
895732E026DD03A3009507A6 /* QONOfferings+Protected.h in Headers */,
895732FD26DD03A3009507A6 /* QNStoreKitService.h in Headers */,
895732E626DD03A3009507A6 /* QONLaunchResult+Protected.h in Headers */,
Expand All @@ -1341,6 +1365,7 @@
8957328126DD03A3009507A6 /* QONEntitlement.h in Headers */,
8957330526DD03A3009507A6 /* QNIdentityServiceInterface.h in Headers */,
895732FE26DD03A3009507A6 /* QNAPIClient.h in Headers */,
702BF8B629531A68000B6C3E /* QONScreenCustomizationDelegate.h in Headers */,
895732BA26DD03A3009507A6 /* QNKeychainStorageInterface.h in Headers */,
8957330926DE5531009507A6 /* QNKeyedArchiver.h in Headers */,
8957329926DD03A3009507A6 /* Qonversion.h in Headers */,
Expand Down Expand Up @@ -1388,6 +1413,7 @@
895732DF26DD03A3009507A6 /* QONUser+Protected.h in Headers */,
8957329126DD03A3009507A6 /* QONAutomations.h in Headers */,
895732ED26DD03A3009507A6 /* QNUserInfoMapper.h in Headers */,
70ADE70F2951CC7200CB4D2E /* QONScreenPresentationConfiguration.h in Headers */,
8957327C26DD03A3009507A6 /* QONAutomationsDelegate.h in Headers */,
8957330126DD03A3009507A6 /* QNUserInfoServiceInterface.h in Headers */,
895732C926DD03A3009507A6 /* QNInternalConstants.h in Headers */,
Expand Down Expand Up @@ -1677,7 +1703,9 @@
895732AE26DD03A3009507A6 /* QONAutomationsActionsHandler.m in Sources */,
895732D126DD03A3009507A6 /* QNUserInfo.m in Sources */,
895732AA26DD03A3009507A6 /* QONAutomationsEventsMapper.m in Sources */,
70B9A9F2297AB8A700BD30FD /* QONAutomationsNavigationController.m in Sources */,
895732CB26DD03A3009507A6 /* QNUtils.m in Sources */,
70ADE7102951CC7200CB4D2E /* QONScreenPresentationConfiguration.m in Sources */,
895732A626DD03A3009507A6 /* QONAutomationsScreen.m in Sources */,
895732A926DD03A3009507A6 /* QONAutomationsMapper.m in Sources */,
895732F226DD03A3009507A6 /* QNMapper.m in Sources */,
Expand Down
7 changes: 7 additions & 0 deletions Sample/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class ViewController: UIViewController {
navigationController?.isNavigationBarHidden = true

Qonversion.Automations.shared().setDelegate(self)
Qonversion.Automations.shared().setScreenCustomizationDelegate(self)

subscriptionTitleLabel.text = ""
mainProductSubscriptionButton.layer.cornerRadius = 20.0
Expand Down Expand Up @@ -244,3 +245,9 @@ extension ViewController: Qonversion.AutomationsDelegate {
return self
}
}

extension ViewController: Qonversion.ScreenCustomizationDelegate {
func presentationConfigurationForScreen(_ screenId: String) -> Qonversion.ScreenPresentationConfiguration {
return Qonversion.ScreenPresentationConfiguration(presentationStyle: .push, animated: true)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
static NSString *const kRestoreAction = @"restore";
static NSString *const kNavigationAction = @"navigate";
static NSString *const kCloseAction = @"close";
static NSString *const kCloseAllAction = @"closeAllQScreens";

@interface QONAutomationsActionsHandler()

Expand All @@ -41,9 +42,10 @@ - (instancetype)init {
kLinkAction: @(QONActionResultTypeURL),
kDeeplinkAction: @(QONActionResultTypeDeeplink),
kCloseAction: @(QONActionResultTypeClose),
kCloseAllAction: @(QONActionResultTypeCloseAll),
kPurchaseAction: @(QONActionResultTypePurchase),
kRestoreAction: @(QONActionResultTypeRestore),
kNavigationAction: @(QONActionResultTypeNavigation),
kNavigationAction: @(QONActionResultTypeNavigation)
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)didFinishLaunch;

- (void)setAutomationsDelegate:(id<QONAutomationsDelegate> _Nullable)automationsDelegate;
- (void)setScreenCustomizationDelegate:(id<QONScreenCustomizationDelegate>)screenCustomizationDelegate;
- (void)showAutomationWithID:(NSString *)automationID completion:(nullable QONShowScreenCompletionHandler)completion;
- (BOOL)handlePushNotification:(NSDictionary *)userInfo;
- (void)showAutomationIfExists;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@
#import "QNInternalConstants.h"
#import "QNDevice.h"
#import "QONNotificationsService.h"
#import "QONScreenCustomizationDelegate.h"
#import "QONAutomationsNavigationController.h"

@interface QONAutomationsFlowCoordinator() <QONAutomationsViewControllerDelegate>

@property (nonatomic, weak) id<QONAutomationsDelegate> automationsDelegate;
@property (nonatomic, weak) id<QONScreenCustomizationDelegate> screenCustomizationDelegate;
@property (nonatomic, strong) QONAutomationsFlowAssembly *assembly;
@property (nonatomic, strong) QONAutomationsService *automationsService;
@property (nonatomic, strong) QONAutomationsEventsMapper *eventsMapper;
Expand Down Expand Up @@ -72,6 +75,10 @@ - (void)setAutomationsDelegate:(id<QONAutomationsDelegate>)automationsDelegate {
_automationsDelegate = automationsDelegate;
}

- (void)setScreenCustomizationDelegate:(id<QONScreenCustomizationDelegate>)screenCustomizationDelegate {
_screenCustomizationDelegate = screenCustomizationDelegate;
}

- (BOOL)handlePushNotification:(NSDictionary *)userInfo {
BOOL shouldShowAutomation = [userInfo[@"qonv.pick_screen"] boolValue];
if (shouldShowAutomation) {
Expand Down Expand Up @@ -145,18 +152,28 @@ - (void)showAutomationWithID:(NSString *)automationID completion:(nullable QONSh
[weakSelf.automationsService trackScreenShownWithID:automationID];
QONAutomationsViewController *viewController = [weakSelf.assembly configureAutomationsViewControllerWithScreen:screen delegate:self];

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
navigationController.navigationBarHidden = YES;

UIViewController *presentationViewController;

if ([weakSelf.automationsDelegate respondsToSelector:@selector(controllerForNavigation)]) {
presentationViewController = [weakSelf.automationsDelegate controllerForNavigation];
} else {
presentationViewController = [weakSelf topLevelViewController];
}
navigationController.modalPresentationStyle = UIModalPresentationFullScreen;
[presentationViewController presentViewController:navigationController animated:YES completion:nil];

QONScreenPresentationConfiguration *configuration = [QONScreenPresentationConfiguration defaultConfiguration];
if ([weakSelf.screenCustomizationDelegate respondsToSelector:@selector(presentationConfigurationForScreen:)]) {
configuration = [weakSelf.screenCustomizationDelegate presentationConfigurationForScreen:screen.screenID];
}

if (configuration.presentationStyle == QONScreenPresentationStylePush) {
[presentationViewController.navigationController pushViewController:viewController animated:configuration.animated];
} else {
QONAutomationsNavigationController *navigationController = [[QONAutomationsNavigationController alloc] initWithRootViewController:viewController];
navigationController.navigationBarHidden = YES;
UIModalPresentationStyle style = configuration.presentationStyle == QONScreenPresentationStylePopover ? UIModalPresentationPopover : UIModalPresentationFullScreen;
navigationController.modalPresentationStyle = style;
[presentationViewController presentViewController:navigationController animated:configuration.animated completion:nil];
}

run_block_on_main(completion, true, nil);
} else if (error) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// QONAutomationsNavigationController.h
// Qonversion
//
// Created by Suren Sarkisyan on 20.01.2023.
// Copyright © 2023 Qonversion Inc. All rights reserved.
//

#import <Foundation/Foundation.h>

#if TARGET_OS_IOS

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@interface QONAutomationsNavigationController : UINavigationController

@end

NS_ASSUME_NONNULL_END

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// QONAutomationsNavigationController.m
// Qonversion
//
// Created by Suren Sarkisyan on 20.01.2023.
// Copyright © 2023 Qonversion Inc. All rights reserved.
//

#import "QONAutomationsNavigationController.h"

#if TARGET_OS_IOS

@interface QONAutomationsNavigationController ()

@end

@implementation QONAutomationsNavigationController

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationPortrait;
}

- (BOOL)shouldAutorotate {
return NO;
}

@end

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ - (void)viewDidLoad {
self.activityIndicator.hidesWhenStopped = YES;
[self.view addSubview:self.activityIndicator];

self.webView.scrollView.showsVerticalScrollIndicator = NO;

self.webView.scrollView.delegate = self;

[self.delegate automationsDidShowScreen:self.screen.screenID];
Expand Down Expand Up @@ -121,6 +123,9 @@ - (void)handleAction:(WKNavigationAction *)navigationAction {
case QONActionResultTypeClose:
[self handleCloseAction:action];
break;
case QONActionResultTypeCloseAll:
[self handleCloseAllAction:action];
break;
case QONActionResultTypePurchase: {
[self handlePurchaseAction:action];
break;
Expand Down Expand Up @@ -151,6 +156,14 @@ - (void)handleLinkAction:(QONActionResult *)action {
}

- (void)handleCloseAction:(QONActionResult *)action {
if (self.navigationController.viewControllers.count > 1) {
[self.navigationController popViewControllerAnimated:YES];
} else {
[self finishAndCloseAutomationsWithActionResult:action];
}
}

- (void)handleCloseAllAction:(QONActionResult *)action {
[self finishAndCloseAutomationsWithActionResult:action];
}

Expand Down Expand Up @@ -242,9 +255,29 @@ - (void)finishAndCloseAutomationsWithActionResult:(QONActionResult *)actionResul
}

- (void)closeAutomationsWithActionResult:(QONActionResult *)actionResult {
[self dismissViewControllerAnimated:YES completion:^{
[self.delegate automationsFinished];
}];
if (self.navigationController.presentingViewController) {
[self dismissViewControllerAnimated:YES completion:^{
[self.delegate automationsFinished];
}];
} else {
UIViewController *vcToPop = [self firstNonQonversionViewController];

[self.navigationController popToViewController:vcToPop animated:YES];
}
}

- (UIViewController *)firstNonQonversionViewController {
NSArray *currentViewControllers = [self.navigationController.viewControllers copy];
UIViewController *firstNonQonversionVC = [currentViewControllers firstObject];
for (NSUInteger i = currentViewControllers.count - 1; i > 0; i--) {
UIViewController *controller = currentViewControllers[i];
if (![controller isKindOfClass:[QONAutomationsViewController class]]) {
firstNonQonversionVC = controller;
break;
}
}

return firstNonQonversionVC;
}

#pragma mark - UIScrollViewDelegate
Expand Down
3 changes: 2 additions & 1 deletion Sources/Qonversion/Public/QONActionResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ typedef NS_ENUM(NSInteger, QONActionResultType) {
QONActionResultTypeNavigation = 3,
QONActionResultTypePurchase = 4,
QONActionResultTypeRestore = 5,
QONActionResultTypeClose = 6
QONActionResultTypeClose = 6,
QONActionResultTypeCloseAll = 7
} NS_SWIFT_NAME(Qonversion.ActionResultType);

NS_SWIFT_NAME(Qonversion.ActionResult)
Expand Down
3 changes: 3 additions & 0 deletions Sources/Qonversion/Public/QONActionResult.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ - (NSString *)prettyType {
case QONActionResultTypeClose:
result = @"close"; break;

case QONActionResultTypeCloseAll:
result = @"close all"; break;

default:
break;
}
Expand Down
Loading

0 comments on commit 64c83a7

Please sign in to comment.