Skip to content

Commit

Permalink
Release 2.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Unity Ads Travis committed Nov 27, 2017
1 parent 8dbbe6a commit 3e3a741
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 31 deletions.
28 changes: 19 additions & 9 deletions UnityAds/AdUnit/UADSViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -186,25 +186,35 @@ - (void)handleViewPlacement:(UIView *)view {
}

- (void)createVideoPlayer {
AVURLAsset *asset = nil;
AVPlayerItem *item = [AVPlayerItem playerItemWithAsset:asset];
[self setVideoPlayer:[[UADSAVPlayer alloc] initWithPlayerItem:item]];
[self.videoView setPlayer:self.videoPlayer];
if (![self videoPlayer]) {
AVURLAsset *asset = nil;
AVPlayerItem *item = [AVPlayerItem playerItemWithAsset:asset];
[self setVideoPlayer:[[UADSAVPlayer alloc] initWithPlayerItem:item]];
[self.videoView setPlayer:self.videoPlayer];
}
}

- (void)createVideoView {
[self setVideoView:[[UADSVideoView alloc] initWithFrame:[self getRect]]];
[self.videoView setVideoFillMode:AVLayerVideoGravityResizeAspect];
if (![self videoView]) {
[self setVideoView:[[UADSVideoView alloc] initWithFrame:[self getRect]]];
[self.videoView setVideoFillMode:AVLayerVideoGravityResizeAspect];
}
}

- (void)destroyVideoView {
[self.videoView removeFromSuperview];
if ([self videoView]) {
[self.videoView removeFromSuperview];
}

self.videoView = NULL;
}

- (void)destroyVideoPlayer {
[self.videoPlayer stop];
[self.videoPlayer stopObserving];
if ([self videoPlayer]) {
[self.videoPlayer stop];
[self.videoPlayer stopObserving];
}

self.videoPlayer = NULL;
}

Expand Down
38 changes: 37 additions & 1 deletion UnityAds/Api/UADSApiCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,43 @@ + (void)WebViewExposed_getFileContent:(NSString *)fileId encoding:(NSString *)en
}
}

+ (void)WebViewExposed_isCaching:(UADSWebViewCallback *)callback {
+ (void)WebViewExposed_setFileContent:(NSString *)fileId encoding:(NSString *)encoding content:(NSString *)content callback:(UADSWebViewCallback *)callback {
NSString *tagetFilePath = [UADSApiCache fileIdToFilename:fileId];
NSData *fileContents = nil;

fileContents = [content dataUsingEncoding:NSUTF8StringEncoding];

if (encoding) {
if ([encoding isEqualToString:@"UTF-8"]) {
// UTF-8 handled by default
}
else if ([encoding isEqualToString:@"Base64"]) {
fileContents = [[NSData alloc] initWithBase64EncodedString:content options:0];
}
else {
[callback error:NSStringFromCacheError(kUnityAdsUnsupportedEncoding) arg1:fileId, tagetFilePath, encoding, nil];
return;
}
}

@try {
if (![[NSFileManager defaultManager] fileExistsAtPath:tagetFilePath]) {
[[NSFileManager defaultManager] createFileAtPath:tagetFilePath contents:nil attributes:nil];
}
if (![[NSFileManager defaultManager] isWritableFileAtPath:tagetFilePath]) {
[callback error:NSStringFromCacheError(kUnityAdsFileIOError) arg1:fileId, tagetFilePath, encoding, nil];
return;
}
[fileContents writeToFile:tagetFilePath atomically:YES];
}
@catch (NSException *exception) {
[callback error:NSStringFromCacheError(kUnityAdsFileIOError) arg1:fileId, tagetFilePath, exception.reason, nil];
return;
}
[callback invoke:nil];
}

+ (void)WebViewExposed_isCaching:(UADSWebViewCallback *)callback {
[callback invoke:[NSNumber numberWithBool:[UADSCacheQueue hasOperations]], nil];
}

Expand Down
5 changes: 2 additions & 3 deletions UnityAds/Configuration/UADSInitialize.m
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,8 @@ - (instancetype)execute {
NSString *localWebViewFile = [UADSSdkProperties getLocalWebViewFile];

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

if (!localWebViewHash || (localWebViewHash && [localWebViewHash isEqualToString:self.configuration.webViewHash])) {
Expand Down
3 changes: 2 additions & 1 deletion UnityAds/MetaData/UADSMediationMetaData.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
- (void)setName:(NSString *)mediationNetworkName;
- (void)setVersion:(NSString *)mediationSdkVersion;
- (void)setOrdinal:(int)mediationOrdinal;
- (void)setMissedImpressionOrdinal:(int)missedImpressionOrdinal;

@end
@end
6 changes: 5 additions & 1 deletion UnityAds/MetaData/UADSMediationMetaData.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ - (void)setOrdinal:(int)mediationOrdinal {
[self set:@"ordinal" value:[NSNumber numberWithInt:mediationOrdinal]];
}

@end
- (void)setMissedImpressionOrdinal:(int)missedImpressionOrdinal {
[self set:@"missedImpressionOrdinal" value:[NSNumber numberWithInt:missedImpressionOrdinal]];
}

@end
17 changes: 6 additions & 11 deletions UnityAds/Properties/UADSClientProperties.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ + (NSString *)getGameId {
}

+ (NSArray<NSString*>*)getSupportedOrientationsPlist {
return [NSBundle.mainBundle.infoDictionary objectForKey:@"UISupportedInterfaceOrientations"];
NSArray<NSString*> *supportedOrientations = @[];
if ([NSBundle.mainBundle.infoDictionary objectForKey:@"UISupportedInterfaceOrientations"] != nil) {
supportedOrientations = [supportedOrientations arrayByAddingObjectsFromArray:[NSBundle.mainBundle.infoDictionary objectForKey:@"UISupportedInterfaceOrientations"]];
}
return supportedOrientations;
}

+ (int)getSupportedOrientations {
Expand All @@ -32,16 +36,7 @@ + (NSString *)getAppVersion {
}

+ (BOOL)isAppDebuggable {
static BOOL output = NO;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
// Check simulator, TestFlight builds and not AppStore apps which should have mobileprovision file
if (UADSDevice.isSimulator ||
[NSBundle.mainBundle.appStoreReceiptURL.lastPathComponent isEqualToString:@"sandboxReceipt"] ||
[NSData dataWithContentsOfFile:[NSBundle.mainBundle pathForResource:@"embedded" ofType:@"mobileprovision"]])
output = YES;
});
return output;
return NO;
}

+ (void)setCurrentViewController:(UIViewController *)viewController {
Expand Down
4 changes: 2 additions & 2 deletions UnityAds/Properties/UADSSdkProperties.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
NSString * const kUnityAdsLocalCacheFilePrefix = @"UnityAdsCache-";
NSString * const kUnityAdsLocalStorageFilePrefix = @"UnityAdsStorage-";
NSString * const kUnityAdsWebviewBranchInfoDictionaryKey = @"UADSWebviewBranch";
NSString * const kUnityAdsVersionName = @"2.1.1";
NSString * const kUnityAdsVersionName = @"2.1.2";
NSString * const kUnityAdsFlavorDebug = @"debug";
NSString * const kUnityAdsFlavorRelease = @"release";
int const kUnityAdsVersionCode = 2101;
int const kUnityAdsVersionCode = 2102;

@implementation UADSSdkProperties

Expand Down
4 changes: 2 additions & 2 deletions UnityAdsExample/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ - (IBAction)toggleTestMode:(id)sender {
}

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

- (IBAction)interstitialButtonTapped:(id)sender {
if ([UnityAds isReady]) {
if ([UnityAds isReady:self.interstitialPlacementId]) {
self.interstitialButton.enabled = NO;
UADSPlayerMetaData *playerMetaData = [[UADSPlayerMetaData alloc] init];
[playerMetaData setServerId:@"rikshot"];
Expand Down
2 changes: 1 addition & 1 deletion UnityAdsTests/ClientPropertiesTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ - (void)testSetDelegate {
}

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

- (void)testSetGameId {
Expand Down

0 comments on commit 3e3a741

Please sign in to comment.