Skip to content

Commit 98a7a65

Browse files
author
Unity Ads Travis
committed
Release 2.0.8
1 parent 8843a34 commit 98a7a65

Some content is hidden

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

58 files changed

+225
-1023
lines changed

Gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
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', '~> 1.3.3'
4+
gem 'xcodeproj', '~> 1.4.2'
55
gem 'trollop', '~> 2.1'
6+
gem 'plist', '~> 3.2'

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
release:
2-
./build-framework.sh -c RELEASE
2+
./generate-project.rb -c library
3+
xcodebuild -project UnityAdsStaticLibrary.xcodeproj -configuration Release > /dev/null
34

45
zip: release
56
cd build/Release-iphoneos && zip -9r builds.zip UnityAds.framework

UnityAds/Api/UADSApiDeviceInfo.m

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,19 @@ + (void)WebViewExposed_getSupportedOrientations:(UADSWebViewCallback *)callback
130130
[callback invoke:[NSNumber numberWithInt:[UADSClientProperties getSupportedOrientations]], nil];
131131
}
132132

133+
+ (void)WebViewExposed_getStatusBarWidth:(UADSWebViewCallback *)callback {
134+
NSNumber *width = [NSNumber numberWithFloat:[UIApplication sharedApplication].statusBarFrame.size.width];
135+
[callback invoke:width, nil];
136+
}
137+
138+
+ (void)WebViewExposed_getStatusBarHeight:(UADSWebViewCallback *)callback {
139+
NSNumber *height = [NSNumber numberWithFloat: [UIApplication sharedApplication].statusBarFrame.size.height];
140+
[callback invoke:height, nil];
141+
}
142+
143+
+ (void)WebViewExposed_isStatusBarHidden:(UADSWebViewCallback *)callback {
144+
NSNumber *isHidden = [NSNumber numberWithBool:[UIApplication sharedApplication].statusBarHidden];
145+
[callback invoke:isHidden, nil];
146+
}
147+
133148
@end

UnityAds/Api/UADSApiNotification.m

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
11
#import "UADSApiNotification.h"
22
#import "UADSWebViewCallback.h"
33
#import "UADSNotificationObserver.h"
4+
#import <AVFoundation/AVFoundation.h>
45

56
@implementation UADSApiNotification
67

78
+ (void)WebViewExposed_addNotificationObserver:(NSString *)name userInfoKeys:(NSArray *)keys callback:(UADSWebViewCallback *)callback {
8-
[UADSNotificationObserver addObserver:name userInfoKeys:keys];
9+
[UADSNotificationObserver addObserver:name userInfoKeys:keys targetObject:nil];
910
[callback invoke:nil];
1011
}
1112

1213
+ (void)WebViewExposed_removeNotificationObserver:(NSString *)name callback:(UADSWebViewCallback *)callback {
13-
[UADSNotificationObserver removeObserver:name];
14+
[UADSNotificationObserver removeObserver:name targetObject:nil];
15+
[callback invoke:nil];
16+
}
17+
18+
+ (void)WebViewExposed_addAVNotificationObserver:(NSString *)name userInfoKeys:(NSArray *)keys callback:(UADSWebViewCallback *)callback {
19+
[UADSNotificationObserver addObserver:name userInfoKeys:keys targetObject:[AVAudioSession sharedInstance]];
20+
[callback invoke:nil];
21+
}
22+
23+
+ (void)WebViewExposed_removeAVNotificationObserver:(NSString *)name callback:(UADSWebViewCallback *)callback {
24+
[UADSNotificationObserver removeObserver:name targetObject:[AVAudioSession sharedInstance]];
1425
[callback invoke:nil];
1526
}
1627

UnityAds/Api/UADSApiVideoPlayer.m

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44

55

66
typedef NS_ENUM(NSInteger, UnityAdsVideoPlayerError) {
7-
kUnityAdsVideoViewNull
7+
kUnityAdsVideoViewNull,
8+
kUnityAdsVideoViewReflectionError
89
};
910

1011
NSString *NSStringFromVideoPlayerError(UnityAdsVideoPlayerError error) {
1112
switch (error) {
1213
case kUnityAdsVideoViewNull:
1314
return @"VIDEOVIEW_NULL";
15+
case kUnityAdsVideoViewReflectionError:
16+
return @"REFLECTION_ERROR";
1417
}
1518
}
1619

@@ -132,4 +135,24 @@ + (void)WebViewExposed_getCurrentPosition:(UADSWebViewCallback *)callback {
132135
}
133136
}
134137

138+
+ (void)WebViewExposed_setAutomaticallyWaitsToMinimizeStalling:(NSNumber *)waits callback:(UADSWebViewCallback *)callback {
139+
if ([[UADSApiAdUnit getAdUnit] videoPlayer]) {
140+
SEL waitsSelector = NSSelectorFromString(@"setAutomaticallyWaitsToMinimizeStalling:");
141+
if ([[[UADSApiAdUnit getAdUnit] videoPlayer] respondsToSelector:waitsSelector]) {
142+
IMP waitsImp = [[[UADSApiAdUnit getAdUnit] videoPlayer] methodForSelector:waitsSelector];
143+
if (waitsImp) {
144+
void (*waitsFunc)(id, SEL, BOOL) = (void *)waitsImp;
145+
waitsFunc([[UADSApiAdUnit getAdUnit] videoPlayer], waitsSelector, [waits boolValue]);
146+
[callback invoke:nil];
147+
return;
148+
}
149+
}
150+
151+
[callback error:NSStringFromVideoPlayerError(kUnityAdsVideoViewReflectionError) arg1:nil];
152+
}
153+
else {
154+
[callback error:NSStringFromVideoPlayerError(kUnityAdsVideoViewNull) arg1:nil];
155+
}
156+
}
157+
135158
@end

UnityAds/Cache/UADSCacheOperation.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ - (void)main {
4848
dispatch_async(dispatch_get_main_queue(), ^{
4949
[[UADSWebViewApp getCurrentApp] sendEvent:NSStringFromCacheEvent(kUnityAdsDownloadError)
5050
category:NSStringFromWebViewEventCategory(kUnityAdsWebViewEventCategoryCache)
51-
param1:self.target, [NSNumber numberWithLongLong:fileSize], [NSNumber numberWithLongLong:self.expectedContentSize], exception.name, exception.reason, nil];
51+
param1:weakSelf.target, [NSNumber numberWithLongLong:fileSize], [NSNumber numberWithLongLong:weakSelf.expectedContentSize], exception.name, exception.reason, nil];
5252
});
5353
[self stopObserving];
5454
return;
@@ -63,7 +63,7 @@ - (void)main {
6363
dispatch_async(dispatch_get_main_queue(), ^{
6464
[[UADSWebViewApp getCurrentApp] sendEvent:NSStringFromCacheEvent(kUnityAdsDownloadError)
6565
category:NSStringFromWebViewEventCategory(kUnityAdsWebViewEventCategoryCache)
66-
param1:self.target, [NSNumber numberWithLongLong:fileSize], [NSNumber numberWithLongLong:self.expectedContentSize], exception.name, exception.reason, nil];
66+
param1:weakSelf.target, [NSNumber numberWithLongLong:fileSize], [NSNumber numberWithLongLong:weakSelf.expectedContentSize], exception.name, exception.reason, nil];
6767
});
6868
[self stopObserving];
6969
return;
@@ -72,7 +72,7 @@ - (void)main {
7272

7373
[self.request setProgressBlock:^(NSString *url, long long bytes, long long totalBytes) {
7474
long currentTime = ([[NSDate date] timeIntervalSince1970] * 1000);
75-
if (![weakSelf isCancelled] && self.progressEventInterval > 0 && self.lastProgressEvent + self.progressEventInterval <= currentTime) {
75+
if (![weakSelf isCancelled] && self.progressEventInterval > 0 && weakSelf.lastProgressEvent + weakSelf.progressEventInterval <= currentTime) {
7676
[[UADSWebViewApp getCurrentApp] sendEvent:NSStringFromCacheEvent(kUnityAdsDownloadProgress)
7777
category:NSStringFromWebViewEventCategory(kUnityAdsWebViewEventCategoryCache)
7878
param1:weakSelf.source, [NSNumber numberWithLongLong:bytes], [NSNumber numberWithLongLong:weakSelf.expectedContentSize], nil];

UnityAds/Notification/UADSNotificationObserver.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
@interface UADSNotificationObserver : NSObject
44

5-
+ (void)addObserver:(NSString *)name userInfoKeys:(NSArray *)keys;
5+
+ (void)addObserver:(NSString *)name userInfoKeys:(NSArray *)keys targetObject:(id)targetObject;
66

7-
+ (void)removeObserver:(NSString *)name;
7+
+ (void)removeObserver:(NSString *)name targetObject:(id)targetObject;
88

99
+ (void)unregisterNotificationObserver;
1010

UnityAds/Notification/UADSNotificationObserver.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,24 @@
77

88
@implementation UADSNotificationObserver
99

10-
+ (void)addObserver:(NSString *)name userInfoKeys:(NSArray *)keys {
11-
[self removeObserver:name];
10+
+ (void)addObserver:(NSString *)name userInfoKeys:(NSArray *)keys targetObject:(id)targetObject {
11+
[self removeObserver:name targetObject:nil];
1212
if (!notificationKeyDictionary) {
1313
notificationKeyDictionary = [[NSMutableDictionary alloc]init];
1414
}
1515
[notificationKeyDictionary removeObjectForKey:name];
1616
if (keys) {
1717
[notificationKeyDictionary setObject:keys forKey:name];
1818
}
19-
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(nsNotificationReceived:) name:name object:nil];
19+
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(nsNotificationReceived:) name:name object:targetObject];
2020
}
2121

22-
+ (void)removeObserver:(NSString *)name {
23-
[[NSNotificationCenter defaultCenter] removeObserver:self name:name object:nil];
22+
+ (void)removeObserver:(NSString *)name targetObject:(id)targetObject {
23+
[[NSNotificationCenter defaultCenter] removeObserver:self name:name object:targetObject];
2424
}
2525

2626
+ (void)unregisterNotificationObserver {
27-
[[NSNotificationCenter defaultCenter]removeObserver:self];
27+
[[NSNotificationCenter defaultCenter] removeObserver:self];
2828
}
2929

3030
+ (void)nsNotificationReceived:(NSNotification *)notification {

UnityAds/Properties/UADSSdkProperties.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
FOUNDATION_EXPORT NSString * const kUnityAdsCacheDirName;
66
FOUNDATION_EXPORT NSString * const kUnityAdsLocalCacheFilePrefix;
77
FOUNDATION_EXPORT NSString * const kUnityAdsLocalStorageFilePrefix;
8+
FOUNDATION_EXPORT NSString * const kUnityAdsWebviewBranchInfoDictionaryKey;
89
FOUNDATION_EXPORT NSString * const kUnityAdsVersionName;
910
FOUNDATION_EXPORT int const kUnityAdsVersionCode;
1011
FOUNDATION_EXPORT NSString * const kUnityAdsFlavorDebug;
@@ -26,4 +27,4 @@ FOUNDATION_EXPORT NSString * const kUnityAdsFlavorRelease;
2627
+ (NSString *)getCacheDirectory;
2728
+ (void)setShowTimeout:(int)timeout;
2829
+ (int)getShowTimeout;
29-
@end
30+
@end

UnityAds/Properties/UADSSdkProperties.m

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
NSString * const kUnityAdsCacheDirName = @"UnityAdsCache";
44
NSString * const kUnityAdsLocalCacheFilePrefix = @"UnityAdsCache-";
55
NSString * const kUnityAdsLocalStorageFilePrefix = @"UnityAdsStorage-";
6-
NSString * const kUnityAdsVersionName = @"2.0.7";
6+
NSString * const kUnityAdsWebviewBranchInfoDictionaryKey = @"UADSWebviewBranch";
7+
NSString * const kUnityAdsVersionName = @"2.0.8";
78
NSString * const kUnityAdsFlavorDebug = @"debug";
89
NSString * const kUnityAdsFlavorRelease = @"release";
9-
int const kUnityAdsVersionCode = 2007;
10+
int const kUnityAdsVersionCode = 2008;
1011

1112
@implementation UADSSdkProperties
1213

@@ -69,18 +70,15 @@ + (NSString *)getConfigUrl {
6970
return configUrl;
7071
}
7172

72-
#define STRINGIZE(x) #x
73-
#define STRINGIZE2(x) STRINGIZE(x)
74-
7573
+ (NSString *)getDefaultConfigUrl:(NSString *)flavor {
7674
NSString *defaultConfigUrl = @"https://config.unityads.unity3d.com/webview/";
77-
78-
79-
#ifdef UADSWEBVIEW_BRANCH
80-
NSString *versionString = @STRINGIZE2(UADSWEBVIEW_BRANCH);
81-
#else
8275
NSString *versionString = [UADSSdkProperties getVersionName];
83-
#endif
76+
77+
// If there is a string object for the key UADSWebviewBranch in the Info.plist of the hosting application,
78+
// then point the SDK to the webview deployed at that path.
79+
if ([[[NSBundle mainBundle] objectForInfoDictionaryKey:kUnityAdsWebviewBranchInfoDictionaryKey] isKindOfClass:[NSString class]]) {
80+
versionString = [[NSBundle mainBundle] objectForInfoDictionaryKey:kUnityAdsWebviewBranchInfoDictionaryKey];
81+
}
8482

8583
defaultConfigUrl = [defaultConfigUrl stringByAppendingFormat:@"%@/%@/config.json", versionString, flavor];
8684

0 commit comments

Comments
 (0)