Skip to content

Commit 3e3a741

Browse files
author
Unity Ads Travis
committed
Release 2.1.2
1 parent 8dbbe6a commit 3e3a741

File tree

9 files changed

+76
-31
lines changed

9 files changed

+76
-31
lines changed

UnityAds/AdUnit/UADSViewController.m

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -186,25 +186,35 @@ - (void)handleViewPlacement:(UIView *)view {
186186
}
187187

188188
- (void)createVideoPlayer {
189-
AVURLAsset *asset = nil;
190-
AVPlayerItem *item = [AVPlayerItem playerItemWithAsset:asset];
191-
[self setVideoPlayer:[[UADSAVPlayer alloc] initWithPlayerItem:item]];
192-
[self.videoView setPlayer:self.videoPlayer];
189+
if (![self videoPlayer]) {
190+
AVURLAsset *asset = nil;
191+
AVPlayerItem *item = [AVPlayerItem playerItemWithAsset:asset];
192+
[self setVideoPlayer:[[UADSAVPlayer alloc] initWithPlayerItem:item]];
193+
[self.videoView setPlayer:self.videoPlayer];
194+
}
193195
}
194196

195197
- (void)createVideoView {
196-
[self setVideoView:[[UADSVideoView alloc] initWithFrame:[self getRect]]];
197-
[self.videoView setVideoFillMode:AVLayerVideoGravityResizeAspect];
198+
if (![self videoView]) {
199+
[self setVideoView:[[UADSVideoView alloc] initWithFrame:[self getRect]]];
200+
[self.videoView setVideoFillMode:AVLayerVideoGravityResizeAspect];
201+
}
198202
}
199203

200204
- (void)destroyVideoView {
201-
[self.videoView removeFromSuperview];
205+
if ([self videoView]) {
206+
[self.videoView removeFromSuperview];
207+
}
208+
202209
self.videoView = NULL;
203210
}
204211

205212
- (void)destroyVideoPlayer {
206-
[self.videoPlayer stop];
207-
[self.videoPlayer stopObserving];
213+
if ([self videoPlayer]) {
214+
[self.videoPlayer stop];
215+
[self.videoPlayer stopObserving];
216+
}
217+
208218
self.videoPlayer = NULL;
209219
}
210220

UnityAds/Api/UADSApiCache.m

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,43 @@ + (void)WebViewExposed_getFileContent:(NSString *)fileId encoding:(NSString *)en
104104
}
105105
}
106106

107-
+ (void)WebViewExposed_isCaching:(UADSWebViewCallback *)callback {
107+
+ (void)WebViewExposed_setFileContent:(NSString *)fileId encoding:(NSString *)encoding content:(NSString *)content callback:(UADSWebViewCallback *)callback {
108+
NSString *tagetFilePath = [UADSApiCache fileIdToFilename:fileId];
109+
NSData *fileContents = nil;
110+
111+
fileContents = [content dataUsingEncoding:NSUTF8StringEncoding];
112+
113+
if (encoding) {
114+
if ([encoding isEqualToString:@"UTF-8"]) {
115+
// UTF-8 handled by default
116+
}
117+
else if ([encoding isEqualToString:@"Base64"]) {
118+
fileContents = [[NSData alloc] initWithBase64EncodedString:content options:0];
119+
}
120+
else {
121+
[callback error:NSStringFromCacheError(kUnityAdsUnsupportedEncoding) arg1:fileId, tagetFilePath, encoding, nil];
122+
return;
123+
}
124+
}
125+
126+
@try {
127+
if (![[NSFileManager defaultManager] fileExistsAtPath:tagetFilePath]) {
128+
[[NSFileManager defaultManager] createFileAtPath:tagetFilePath contents:nil attributes:nil];
129+
}
130+
if (![[NSFileManager defaultManager] isWritableFileAtPath:tagetFilePath]) {
131+
[callback error:NSStringFromCacheError(kUnityAdsFileIOError) arg1:fileId, tagetFilePath, encoding, nil];
132+
return;
133+
}
134+
[fileContents writeToFile:tagetFilePath atomically:YES];
135+
}
136+
@catch (NSException *exception) {
137+
[callback error:NSStringFromCacheError(kUnityAdsFileIOError) arg1:fileId, tagetFilePath, exception.reason, nil];
138+
return;
139+
}
140+
[callback invoke:nil];
141+
}
142+
143+
+ (void)WebViewExposed_isCaching:(UADSWebViewCallback *)callback {
108144
[callback invoke:[NSNumber numberWithBool:[UADSCacheQueue hasOperations]], nil];
109145
}
110146

UnityAds/Configuration/UADSInitialize.m

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,8 @@ - (instancetype)execute {
171171
NSString *localWebViewFile = [UADSSdkProperties getLocalWebViewFile];
172172

173173
if ([[NSFileManager defaultManager] fileExistsAtPath:localWebViewFile]) {
174-
NSFileHandle *fileHandle = [NSFileHandle fileHandleForReadingAtPath:localWebViewFile];
175-
NSData *fileData = [fileHandle readDataToEndOfFile];
176-
NSString *fileString = [[NSString alloc] initWithData:fileData encoding:NSUTF8StringEncoding];
174+
NSData *fileData = [NSData dataWithContentsOfFile:localWebViewFile options:NSDataReadingUncached error:nil];
175+
NSString *fileString = [[NSString alloc] initWithBytesNoCopy:(void *)[fileData bytes] length:[fileData length] encoding:NSUTF8StringEncoding freeWhenDone:NO];
177176
NSString *localWebViewHash = [fileString sha256];
178177

179178
if (!localWebViewHash || (localWebViewHash && [localWebViewHash isEqualToString:self.configuration.webViewHash])) {

UnityAds/MetaData/UADSMediationMetaData.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
- (void)setName:(NSString *)mediationNetworkName;
66
- (void)setVersion:(NSString *)mediationSdkVersion;
77
- (void)setOrdinal:(int)mediationOrdinal;
8+
- (void)setMissedImpressionOrdinal:(int)missedImpressionOrdinal;
89

9-
@end
10+
@end

UnityAds/MetaData/UADSMediationMetaData.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,8 @@ - (void)setOrdinal:(int)mediationOrdinal {
1919
[self set:@"ordinal" value:[NSNumber numberWithInt:mediationOrdinal]];
2020
}
2121

22-
@end
22+
- (void)setMissedImpressionOrdinal:(int)missedImpressionOrdinal {
23+
[self set:@"missedImpressionOrdinal" value:[NSNumber numberWithInt:missedImpressionOrdinal]];
24+
}
25+
26+
@end

UnityAds/Properties/UADSClientProperties.m

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ + (NSString *)getGameId {
1616
}
1717

1818
+ (NSArray<NSString*>*)getSupportedOrientationsPlist {
19-
return [NSBundle.mainBundle.infoDictionary objectForKey:@"UISupportedInterfaceOrientations"];
19+
NSArray<NSString*> *supportedOrientations = @[];
20+
if ([NSBundle.mainBundle.infoDictionary objectForKey:@"UISupportedInterfaceOrientations"] != nil) {
21+
supportedOrientations = [supportedOrientations arrayByAddingObjectsFromArray:[NSBundle.mainBundle.infoDictionary objectForKey:@"UISupportedInterfaceOrientations"]];
22+
}
23+
return supportedOrientations;
2024
}
2125

2226
+ (int)getSupportedOrientations {
@@ -32,16 +36,7 @@ + (NSString *)getAppVersion {
3236
}
3337

3438
+ (BOOL)isAppDebuggable {
35-
static BOOL output = NO;
36-
static dispatch_once_t onceToken;
37-
dispatch_once(&onceToken, ^{
38-
// Check simulator, TestFlight builds and not AppStore apps which should have mobileprovision file
39-
if (UADSDevice.isSimulator ||
40-
[NSBundle.mainBundle.appStoreReceiptURL.lastPathComponent isEqualToString:@"sandboxReceipt"] ||
41-
[NSData dataWithContentsOfFile:[NSBundle.mainBundle pathForResource:@"embedded" ofType:@"mobileprovision"]])
42-
output = YES;
43-
});
44-
return output;
39+
return NO;
4540
}
4641

4742
+ (void)setCurrentViewController:(UIViewController *)viewController {

UnityAds/Properties/UADSSdkProperties.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
NSString * const kUnityAdsLocalCacheFilePrefix = @"UnityAdsCache-";
55
NSString * const kUnityAdsLocalStorageFilePrefix = @"UnityAdsStorage-";
66
NSString * const kUnityAdsWebviewBranchInfoDictionaryKey = @"UADSWebviewBranch";
7-
NSString * const kUnityAdsVersionName = @"2.1.1";
7+
NSString * const kUnityAdsVersionName = @"2.1.2";
88
NSString * const kUnityAdsFlavorDebug = @"debug";
99
NSString * const kUnityAdsFlavorRelease = @"release";
10-
int const kUnityAdsVersionCode = 2101;
10+
int const kUnityAdsVersionCode = 2102;
1111

1212
@implementation UADSSdkProperties
1313

UnityAdsExample/ViewController.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ - (IBAction)toggleTestMode:(id)sender {
5555
}
5656

5757
- (IBAction)incentivizedButtonTapped:(id)sender {
58-
if ([UnityAds isReady]) {
58+
if ([UnityAds isReady:self.incentivizedPlacementId]) {
5959
self.incentivizedButton.enabled = NO;
6060
UADSPlayerMetaData *playerMetaData = [[UADSPlayerMetaData alloc] init];
6161
[playerMetaData setServerId:@"rikshot"];
@@ -70,7 +70,7 @@ - (IBAction)incentivizedButtonTapped:(id)sender {
7070
}
7171

7272
- (IBAction)interstitialButtonTapped:(id)sender {
73-
if ([UnityAds isReady]) {
73+
if ([UnityAds isReady:self.interstitialPlacementId]) {
7474
self.interstitialButton.enabled = NO;
7575
UADSPlayerMetaData *playerMetaData = [[UADSPlayerMetaData alloc] init];
7676
[playerMetaData setServerId:@"rikshot"];

UnityAdsTests/ClientPropertiesTest.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ - (void)testSetDelegate {
4343
}
4444

4545
- (void)testIsAppDebuggable {
46-
XCTAssertTrue([UADSClientProperties isAppDebuggable], "App should be debuggable");
46+
XCTAssertFalse([UADSClientProperties isAppDebuggable], "App should not be debuggable");
4747
}
4848

4949
- (void)testSetGameId {

0 commit comments

Comments
 (0)