Skip to content

Commit ea20f50

Browse files
author
Unity Ads Travis
committed
Release 2.0.6
1 parent d38a90d commit ea20f50

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+459
-2649
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,6 @@ UnityAdsTests/index.html
7575
UnityAds.framework
7676

7777
.DS_Store
78+
79+
# Bundler for Ruby gems
80+
Gemfile.lock

.travis.yml

-24
This file was deleted.

Gemfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
source 'https://rubygems.org'
22
# xcodeproj has an issue with newest Xcode, fix is not a release gem at this moment
33
# Use github master until fix is released in gem.
4-
gem 'xcodeproj', :git => 'https://github.com/CocoaPods/Xcodeproj'
4+
gem 'xcodeproj', '~> 1.3.3'
5+
gem 'trollop', '~> 2.1'

Gemfile.lock

-34
This file was deleted.

UnityAds/AdUnit/UADSAdUnitError.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#import <Foundation/Foundation.h>
22

33
typedef NS_ENUM(NSInteger, UnityAdsAdUnitError) {
4-
kUnityAdsViewControllerNull
4+
kUnityAdsViewControllerNull,
5+
kUnityAdsViewControllerNoRotationZ,
6+
kUnityAdsViewControllerUnknownView,
7+
kUnityAdsViewControllerTargetViewNull
58
};
69

710
NSString *NSStringFromAdUnitError(UnityAdsAdUnitError);

UnityAds/AdUnit/UADSAdUnitError.m

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
#import "UADSAdUnitError.h"
22

33
static NSString *unityAdsViewControllerNull = @"VIEW_CONTROLLER_NULL";
4+
static NSString *unityAdsViewControllerNoRotationZ = @"VIEW_CONTROLLER_NO_ROTATION_Z";
5+
static NSString *unityAdsViewControllerUnknownView = @"VIEW_CONTROLLER_UNKNOWN_VIEW";
6+
static NSString *unityAdsViewControllerTargetViewNull = @"VIEW_CONTROLLER_TARGET_VIEW_NULL";
47

58
NSString *NSStringFromAdUnitError(UnityAdsAdUnitError error) {
69
switch (error) {
710
case kUnityAdsViewControllerNull:
811
return unityAdsViewControllerNull;
12+
case kUnityAdsViewControllerNoRotationZ:
13+
return unityAdsViewControllerNoRotationZ;
14+
case kUnityAdsViewControllerUnknownView:
15+
return unityAdsViewControllerUnknownView;
16+
case kUnityAdsViewControllerTargetViewNull:
17+
return unityAdsViewControllerTargetViewNull;
918
}
10-
}
19+
}

UnityAds/AdUnit/UADSViewController.h

+2
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,7 @@
1313

1414
- (instancetype)initWithViews:(NSArray *)views supportedOrientations:(NSNumber *)supportedOrientations statusBarHidden:(BOOL)statusBarHidden shouldAutorotate:(BOOL)shouldAutorotate;
1515
- (void)setViews:(NSArray<NSString*>*)views;
16+
- (void)setTransform:(float)transform;
17+
- (void)setViewFrame:(NSString *)view x:(int)x y:(int)y width:(int)width height:(int)height;
1618

1719
@end

UnityAds/AdUnit/UADSViewController.m

+22
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,24 @@ - (void)viewDidDisappear:(BOOL)animated {
6363
[[UADSWebViewApp getCurrentApp] sendEvent:NSStringFromAdUnitEvent(kUnityAdsViewControllerDidDisappear) category:NSStringFromWebViewEventCategory(kUnityAdsWebViewEventCategoryAdunit) param1:nil];
6464
}
6565

66+
- (void)setViewFrame:(NSString *)view x:(int)x y:(int)y width:(int)width height:(int)height {
67+
UIView *targetView = NULL;
68+
69+
if ([view isEqualToString:@"adunit"]) {
70+
targetView = self.view;
71+
}
72+
else if ([view isEqualToString:@"videoplayer"]) {
73+
targetView = self.videoView;
74+
}
75+
else if ([view isEqualToString:@"webview"]) {
76+
targetView = [[UADSWebViewApp getCurrentApp] webView];
77+
}
78+
79+
if (targetView) {
80+
[targetView setFrame:CGRectMake(x, y, width, height)];
81+
}
82+
}
83+
6684
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
6785
return self.supportedOrientations;
6886
}
@@ -81,6 +99,10 @@ - (void)setStatusBarHidden:(BOOL)statusBarHidden {
8199
[self setNeedsStatusBarAppearanceUpdate];
82100
}
83101

102+
- (void)setTransform:(float)transform {
103+
self.view.transform = CGAffineTransformMakeRotation(transform);
104+
}
105+
84106
- (BOOL)prefersStatusBarHidden {
85107
return self.statusBarHidden;
86108
}

UnityAds/Api/UADSApiAdUnit.m

+76-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#import "UADSWebViewCallback.h"
33
#import "UADSClientProperties.h"
44
#import "UADSAdUnitError.h"
5+
#import "UADSWebViewApp.h"
56

67
@implementation UADSApiAdUnit
78

@@ -135,4 +136,78 @@ + (void)WebViewExposed_getShouldAutorotate:(UADSWebViewCallback *)callback {
135136
}
136137
}
137138

138-
@end
139+
+ (void)WebViewExposed_setTransform:(NSNumber *)transform callback:(UADSWebViewCallback *)callback {
140+
if ([UADSApiAdUnit getAdUnit]) {
141+
dispatch_async(dispatch_get_main_queue(), ^(void) {
142+
[[UADSApiAdUnit getAdUnit] setTransform:[transform floatValue]];
143+
[callback invoke:transform, nil];
144+
});
145+
}
146+
else {
147+
[callback error:NSStringFromAdUnitError(kUnityAdsViewControllerNull) arg1:nil];
148+
}
149+
}
150+
151+
+ (void)WebViewExposed_setViewFrame:(NSString *)view x:(NSNumber *)x y:(NSNumber *)y width:(NSNumber *)width height:(NSNumber *)height callback:(UADSWebViewCallback *)callback {
152+
if ([UADSApiAdUnit getAdUnit]) {
153+
dispatch_async(dispatch_get_main_queue(), ^{
154+
[[UADSApiAdUnit getAdUnit] setViewFrame:view x:[x intValue] y:[y intValue] width:[width intValue] height:[height intValue]];
155+
});
156+
[callback invoke:nil];
157+
}
158+
else {
159+
[callback error:NSStringFromAdUnitError(kUnityAdsViewControllerNull) arg1:nil];
160+
}
161+
}
162+
163+
+ (void)WebViewExposed_getTransform:(UADSWebViewCallback *)callback {
164+
if ([UADSApiAdUnit getAdUnit]) {
165+
if ([[UADSApiAdUnit getAdUnit].view valueForKeyPath:@"layer.transform.rotation.z"]) {
166+
[callback invoke:[(NSNumber *)[UADSApiAdUnit getAdUnit].view valueForKeyPath:@"layer.transform.rotation.z"], nil];
167+
}
168+
else {
169+
[callback error:NSStringFromAdUnitError(kUnityAdsViewControllerNoRotationZ) arg1:nil];
170+
}
171+
}
172+
else {
173+
[callback error:NSStringFromAdUnitError(kUnityAdsViewControllerNull) arg1:nil];
174+
}
175+
}
176+
177+
+ (void)WebViewExposed_getViewFrame:(NSString *)view callback:(UADSWebViewCallback *)callback {
178+
if ([UADSApiAdUnit getAdUnit]) {
179+
UIView *targetView = NULL;
180+
181+
if ([view isEqualToString:@"adunit"]) {
182+
targetView = [UADSApiAdUnit getAdUnit].view;
183+
}
184+
else if ([view isEqualToString:@"videoplayer"]) {
185+
targetView = [UADSApiAdUnit getAdUnit].videoView;
186+
}
187+
else if ([view isEqualToString:@"webview"]) {
188+
targetView = [[UADSWebViewApp getCurrentApp] webView];
189+
}
190+
else {
191+
[callback error:NSStringFromAdUnitError(kUnityAdsViewControllerUnknownView) arg1:nil];
192+
return;
193+
}
194+
195+
if (targetView) {
196+
CGRect targetFrame = targetView.frame;
197+
[callback invoke:[NSNumber numberWithFloat:targetFrame.origin.x],
198+
[NSNumber numberWithFloat:targetFrame.origin.y],
199+
[NSNumber numberWithFloat:targetFrame.size.width],
200+
[NSNumber numberWithFloat:targetFrame.size.height],
201+
nil];
202+
}
203+
else {
204+
[callback error:NSStringFromAdUnitError(kUnityAdsViewControllerTargetViewNull) arg1:nil];
205+
return;
206+
}
207+
}
208+
else {
209+
[callback error:NSStringFromAdUnitError(kUnityAdsViewControllerNull) arg1:nil];
210+
}
211+
}
212+
213+
@end

UnityAds/Api/UADSApiDeviceInfo.m

+11-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#import "UADSWebViewCallback.h"
33
#import "UADSDevice.h"
44
#import "UADSConnectivityUtils.h"
5+
#import "UADSClientProperties.h"
6+
57

68
@implementation UADSApiDeviceInfo
79

@@ -120,4 +122,12 @@ + (void)WebViewExposed_isSimulator:(UADSWebViewCallback *)callback {
120122
[callback invoke:[NSNumber numberWithBool:[UADSDevice isSimulator]], nil];
121123
}
122124

123-
@end
125+
+ (void)WebViewExposed_getSupportedOrientationsPlist:(UADSWebViewCallback *)callback {
126+
[callback invoke:[UADSClientProperties getSupportedOrientationsPlist], nil];
127+
}
128+
129+
+ (void)WebViewExposed_getSupportedOrientations:(UADSWebViewCallback *)callback {
130+
[callback invoke:[NSNumber numberWithInt:[UADSClientProperties getSupportedOrientations]], nil];
131+
}
132+
133+
@end

UnityAds/Api/UADSApiListener.m

+19-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#import "UADSWebViewCallback.h"
33
#import "UADSClientProperties.h"
44
#import "NSString+UnityAdsError.h"
5+
#import "UnityAdsExtended.h"
56

67
UnityAdsFinishState UnityAdsFinishStateFromNSString (NSString* state) {
78
if (state) {
@@ -75,6 +76,23 @@ + (void)WebViewExposed_sendFinishEvent:(NSString *)placementId result:(NSString
7576
}
7677
}
7778

79+
+ (void)WebViewExposed_sendClickEvent:(NSString *)placementId callback:(UADSWebViewCallback *)callback {
80+
if ([UADSClientProperties getDelegate] && [[UADSClientProperties getDelegate] conformsToProtocol:@protocol(UnityAdsExtendedDelegate)]) {
81+
if ([(id<UnityAdsExtendedDelegate>)[UADSClientProperties getDelegate] respondsToSelector:@selector(unityAdsDidClick:)]) {
82+
dispatch_async(dispatch_get_main_queue(), ^{
83+
[(id<UnityAdsExtendedDelegate>)[UADSClientProperties getDelegate] unityAdsDidClick:placementId];
84+
});
85+
[callback invoke:nil];
86+
}
87+
else {
88+
[callback error:NSStringFromListenerError(kUnityAdsCouldNotFindSelector) arg1:nil];
89+
}
90+
}
91+
else {
92+
[callback error:NSStringFromListenerError(kUnityAdsDelegateNull) arg1:nil];
93+
}
94+
}
95+
7896
+ (void)WebViewExposed_sendErrorEvent:(NSString *)errorString message:(NSString *)message callback:(UADSWebViewCallback *)callback {
7997
if ([UADSClientProperties getDelegate]) {
8098
if ([[UADSClientProperties getDelegate] respondsToSelector:@selector(unityAdsDidError:withMessage:)]) {
@@ -92,4 +110,4 @@ + (void)WebViewExposed_sendErrorEvent:(NSString *)errorString message:(NSString
92110
}
93111
}
94112

95-
@end
113+
@end

UnityAds/Api/UADSApiSdk.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,4 @@ + (void)WebViewExposed_reinitialize:(UADSWebViewCallback *)callback {
7272
[UADSInitialize initialize:[[UADSWebViewApp getCurrentApp] configuration]];
7373
}
7474

75-
@end
75+
@end

UnityAds/Api/UADSApiVideoPlayer.m

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ + (void)WebViewExposed_getProgressEventInterval:(UADSWebViewCallback *)callback
3535
}
3636
}
3737

38-
+ (void)WebViewExposed_prepare:(NSString *)url initialVolume:(NSNumber *)initialVolume callback:(UADSWebViewCallback *)callback {
38+
+ (void)WebViewExposed_prepare:(NSString *)url initialVolume:(NSNumber *)initialVolume timeout:(NSNumber *)timeout callback:(UADSWebViewCallback *)callback {
3939
if ([[UADSApiAdUnit getAdUnit] videoPlayer]) {
4040
dispatch_async(dispatch_get_main_queue(), ^{
41-
[[[UADSApiAdUnit getAdUnit] videoPlayer] prepare:url initialVolume:[initialVolume floatValue]];
41+
[[[UADSApiAdUnit getAdUnit] videoPlayer] prepare:url initialVolume:[initialVolume floatValue] timeout:[timeout integerValue]];
4242
});
4343

4444
[callback invoke:nil];
@@ -132,4 +132,4 @@ + (void)WebViewExposed_getCurrentPosition:(UADSWebViewCallback *)callback {
132132
}
133133
}
134134

135-
@end
135+
@end

UnityAds/AppSheet/UADSAppSheetViewController.m

+1-6
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,11 @@ - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
77
}
88

99
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
10-
if ([[[[UIDevice currentDevice] systemVersion] substringToIndex:1]intValue]
11-
>= 8 && [[UIDevice currentDevice] userInterfaceIdiom] != UIUserInterfaceIdiomPad) {
12-
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
13-
}
1410
return UIInterfaceOrientationMaskAll;
1511
}
1612

1713
- (BOOL)shouldAutorotate {
18-
return [[[[UIDevice currentDevice] systemVersion] substringToIndex:1]intValue] < 8
19-
|| [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad;
14+
return YES;
2015
}
2116

2217
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {

0 commit comments

Comments
 (0)