Skip to content

Commit

Permalink
Release 2.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Unity Ads Travis committed Aug 29, 2017
1 parent def0f30 commit 8dbbe6a
Show file tree
Hide file tree
Showing 43 changed files with 911 additions and 300 deletions.
11 changes: 0 additions & 11 deletions .slather.yml

This file was deleted.

1 change: 1 addition & 0 deletions Modules/module.modulemap
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
framework module UnityAds {
umbrella header "UnityAds.h"
header "UnityAdsExtended.h"
header "UnityAdsUnityDelegate.h"

export *
module * { export * }
Expand Down
3 changes: 2 additions & 1 deletion UnityAds/AdUnit/UADSViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
@property (nonatomic, assign) int supportedOrientations;
@property (nonatomic, assign) BOOL statusBarHidden;
@property (nonatomic, assign) BOOL autorotate;
@property (nonatomic, assign) BOOL transparent;

- (instancetype)initWithViews:(NSArray *)views supportedOrientations:(NSNumber *)supportedOrientations statusBarHidden:(BOOL)statusBarHidden shouldAutorotate:(BOOL)shouldAutorotate;
- (instancetype)initWithViews:(NSArray *)views supportedOrientations:(NSNumber *)supportedOrientations statusBarHidden:(BOOL)statusBarHidden shouldAutorotate:(BOOL)shouldAutorotate isTransparent:(BOOL)isTransparent;
- (void)setViews:(NSArray<NSString*>*)views;
- (void)setTransform:(float)transform;
- (void)setViewFrame:(NSString *)view x:(int)x y:(int)y width:(int)width height:(int)height;
Expand Down
13 changes: 11 additions & 2 deletions UnityAds/AdUnit/UADSViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ @interface UADSViewController ()

@implementation UADSViewController

- (instancetype)initWithViews:(NSArray *)views supportedOrientations:(NSNumber *)supportedOrientations statusBarHidden:(BOOL)statusBarHidden shouldAutorotate:(BOOL)shouldAutorotate {
- (instancetype)initWithViews:(NSArray *)views supportedOrientations:(NSNumber *)supportedOrientations statusBarHidden:(BOOL)statusBarHidden shouldAutorotate:(BOOL)shouldAutorotate isTransparent:(BOOL)isTransparent {
self = [super init];

if (self) {
[self setTransparent:isTransparent];
[self setCurrentViews:views];
[self setStatusBarHidden:statusBarHidden];
[self setSupportedOrientations:[supportedOrientations intValue]];
Expand All @@ -27,7 +28,7 @@ - (instancetype)initWithViews:(NSArray *)views supportedOrientations:(NSNumber *

- (void)viewDidLoad {
[super viewDidLoad];
[self.view setBackgroundColor:[UIColor blackColor]];
[self.view setBackgroundColor:[self isTransparent] ? [UIColor clearColor] : [UIColor blackColor]];

[[UADSWebViewApp getCurrentApp] sendEvent:NSStringFromAdUnitEvent(kUnityAdsViewControllerDidLoad) category:NSStringFromWebViewEventCategory(kUnityAdsWebViewEventCategoryAdunit) param1:nil];
}
Expand Down Expand Up @@ -98,6 +99,10 @@ - (void)setStatusBarHidden:(BOOL)statusBarHidden {
[self setNeedsStatusBarAppearanceUpdate];
}

- (void)setTransparent:(BOOL)isTransparent {
_transparent = isTransparent;
}

- (void)setTransform:(float)transform {
self.view.transform = CGAffineTransformMakeRotation(transform);
}
Expand All @@ -106,6 +111,10 @@ - (BOOL)prefersStatusBarHidden {
return self.statusBarHidden;
}

- (BOOL)isTransparent {
return _transparent;
}

- (void)setViews:(NSArray<NSString*>*)views {
NSMutableArray<NSString*>* actualViews = NULL;

Expand Down
21 changes: 15 additions & 6 deletions UnityAds/Api/UADSApiAdUnit.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,27 @@ + (void)WebViewExposed_open:(NSArray *)views supportedOrientations:(NSNumber *)s
}

+ (void)WebViewExposed_open:(NSArray *)views supportedOrientations:(NSNumber *)supportedOrientations statusBarHidden:(NSNumber *)statusBarHidden callback:(UADSWebViewCallback *)callback {
[UADSApiAdUnit WebViewExposed_open:views supportedOrientations:supportedOrientations statusBarHidden:[NSNumber numberWithInt:0] shouldAutorotate:[NSNumber numberWithBool:YES] callback:callback];

[callback invoke:nil];
[UADSApiAdUnit WebViewExposed_open:views supportedOrientations:supportedOrientations statusBarHidden:statusBarHidden shouldAutorotate:[NSNumber numberWithBool:YES] callback:callback];
}

+ (void)WebViewExposed_open:(NSArray *)views supportedOrientations:(NSNumber *)supportedOrientations statusBarHidden:(NSNumber *)statusBarHidden shouldAutorotate:(NSNumber *)shouldAutorotate callback:(UADSWebViewCallback *)callback {

[UADSApiAdUnit WebViewExposed_open:views supportedOrientations:supportedOrientations statusBarHidden:statusBarHidden shouldAutorotate:shouldAutorotate isTransparent:[NSNumber numberWithBool:NO] callback:callback];
}

+ (void)WebViewExposed_open:(NSArray *)views supportedOrientations:(NSNumber *)supportedOrientations statusBarHidden:(NSNumber *)statusBarHidden shouldAutorotate:(NSNumber *)shouldAutorotate isTransparent:(NSNumber *)isTransparent callback:(UADSWebViewCallback *)callback {
[UADSApiAdUnit WebViewExposed_open:views supportedOrientations:supportedOrientations statusBarHidden:statusBarHidden shouldAutorotate:shouldAutorotate isTransparent:isTransparent withAnimation:[NSNumber numberWithBool:YES] callback:callback];
}

+ (void)WebViewExposed_open:(NSArray *)views supportedOrientations:(NSNumber *)supportedOrientations statusBarHidden:(NSNumber *)statusBarHidden shouldAutorotate:(NSNumber *)shouldAutorotate isTransparent:(NSNumber *)isTransparent withAnimation:(NSNumber *)animated callback:(UADSWebViewCallback *)callback {
dispatch_async(dispatch_get_main_queue(), ^(void) {
UADSLogDebug(@"PRESENTING VIEWCONTROLLER");
UADSViewController *adUnit = [[UADSViewController alloc] initWithViews:views supportedOrientations:supportedOrientations statusBarHidden:[statusBarHidden boolValue] shouldAutorotate:[shouldAutorotate boolValue]];
UADSViewController *adUnit = [[UADSViewController alloc] initWithViews:views supportedOrientations:supportedOrientations statusBarHidden:[statusBarHidden boolValue] shouldAutorotate:[shouldAutorotate boolValue] isTransparent:[isTransparent boolValue]];
[adUnit setModalPresentationCapturesStatusBarAppearance:true];
[[UADSClientProperties getCurrentViewController] presentViewController:adUnit animated:YES completion:NULL];
if (floor(NSFoundationVersionNumber) >= NSFoundationVersionNumber_iOS_8_0 && [isTransparent boolValue]) {
adUnit.modalPresentationStyle = UIModalPresentationOverCurrentContext;
[UADSClientProperties getCurrentViewController].modalPresentationStyle = UIModalPresentationCurrentContext;
}
[[UADSClientProperties getCurrentViewController] presentViewController:adUnit animated:[animated boolValue] completion:NULL];
adUnitViewController = adUnit;
});

Expand Down
7 changes: 5 additions & 2 deletions UnityAds/Api/UADSApiDeviceInfo.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@

#import "UADSVolumeChange.h"

@interface UADSApiDeviceInfo : NSObject
@end
@end

@interface UADSVolumeChangeListener : NSObject <UADSVolumeChangeDelegate>
@end
37 changes: 37 additions & 0 deletions UnityAds/Api/UADSApiDeviceInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@
#import "UADSConnectivityUtils.h"
#import "UADSClientProperties.h"
#import "UADSDeviceError.h"
#import "UADSVolumeChange.h"
#import "UADSWebViewApp.h"
#import "UADSWebViewEventCategory.h"

static UADSVolumeChangeListener *volumeChangeListener = NULL;

@implementation UADSVolumeChangeListener
- (void)onVolumeChanged:(float)volume {
if ([UADSWebViewApp getCurrentApp]) {
[[UADSWebViewApp getCurrentApp] sendEvent:@"VOLUME_CHANGED"
category:NSStringFromWebViewEventCategory(kUnityAdsWebViewEventCategoryDeviceInfo)
param1:[NSNumber numberWithFloat:volume], [NSNumber numberWithFloat:[UADSDevice getDeviceMaxVolume]], nil];
}
}
@end

@implementation UADSApiDeviceInfo

Expand Down Expand Up @@ -159,4 +174,26 @@ + (void)WebViewExposed_getGLVersion:(UADSWebViewCallback *)callback {
[callback invoke:[UADSDevice getGLVersion], nil];
}

+ (void)WebViewExposed_getDeviceMaxVolume:(UADSWebViewCallback *)callback {
[callback invoke:[NSNumber numberWithFloat:[UADSDevice getDeviceMaxVolume]], nil];
}

+ (void)WebViewExposed_registerVolumeChangeListener:(UADSWebViewCallback *)callback {
if (!volumeChangeListener) {
volumeChangeListener = [[UADSVolumeChangeListener alloc] init];
[UADSVolumeChange registerDelegate:volumeChangeListener];
}

[callback invoke:nil];
}

+ (void)WebViewExposed_unregisterVolumeChangeListener:(UADSWebViewCallback *)callback {
if (volumeChangeListener) {
[UADSVolumeChange unregisterDelegate:volumeChangeListener];
volumeChangeListener = NULL;
}

[callback invoke:nil];
}

@end
13 changes: 13 additions & 0 deletions UnityAds/Api/UADSApiListener.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#import "UADSClientProperties.h"
#import "NSString+UnityAdsError.h"
#import "UnityAdsExtended.h"
#import "UnityAdsUnityDelegate.h"
#import "UADSPlacement.h"

UnityAdsFinishState UnityAdsFinishStateFromNSString (NSString* state) {
Expand Down Expand Up @@ -88,6 +89,18 @@ + (void)WebViewExposed_sendPlacementStateChangedEvent:(NSString *)placementId ol
[callback invoke:nil];
}

+ (void)WebViewExposed_sendInitiatePurchaseEvent:(NSString *)eventString callback:(UADSWebViewCallback *)callback {
dispatch_async(dispatch_get_main_queue(), ^{
if ([UADSClientProperties getDelegate] && [[UADSClientProperties getDelegate] conformsToProtocol:@protocol(UnityAdsUnityDelegate)]) {
if ([(id<UnityAdsUnityDelegate>)[UADSClientProperties getDelegate] respondsToSelector:@selector(unityAdsDidInitiatePurchase:)]) {
[(id<UnityAdsUnityDelegate>)[UADSClientProperties getDelegate] unityAdsDidInitiatePurchase:eventString];
}
}
});

[callback invoke:nil];
}

+ (void)WebViewExposed_sendErrorEvent:(NSString *)errorString message:(NSString *)message callback:(UADSWebViewCallback *)callback {
dispatch_async(dispatch_get_main_queue(), ^{
if ([UADSClientProperties getDelegate]) {
Expand Down
7 changes: 7 additions & 0 deletions UnityAds/Api/UADSApiSdk.m
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ + (void)WebViewExposed_setShowTimeout:(NSNumber *)timeout callback:(UADSWebViewC
}

+ (void)WebViewExposed_reinitialize:(UADSWebViewCallback *)callback {
UADSWebViewApp *currentWebViewApp = [UADSWebViewApp getCurrentApp];

if (currentWebViewApp != nil) {
[currentWebViewApp setWebAppLoaded:false];
[currentWebViewApp setWebAppInitialized:false];
}

[UADSSdkProperties setReinitialized:true];
[UADSInitialize initialize:[[UADSWebViewApp getCurrentApp] configuration]];
}
Expand Down
4 changes: 2 additions & 2 deletions UnityAds/Api/UADSApiStorage.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ + (void)WebViewExposed_set:(NSString *)type key:(NSString *)key value:(id)value
UADSStorage *storage = [UADSStorageManager getStorage:storageType];

if (storage && key && value) {
BOOL success = [storage setValue:value forKey:key];
BOOL success = [storage set:key value:value];
if (success) {
[callback invoke:
key,
Expand Down Expand Up @@ -149,4 +149,4 @@ + (UnityAdsStorageType)getStorageTypeFromString:(NSString *)typeString {
return (UnityAdsStorageType)typeValue;
}

@end
@end
5 changes: 5 additions & 0 deletions UnityAds/Categories/NSDictionary+Merge.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@interface NSDictionary (Merge)

+ (NSDictionary*)dictionaryByMerging:(NSDictionary *)primary secondary:(NSDictionary *)secondary;

@end
28 changes: 28 additions & 0 deletions UnityAds/Categories/NSDictionary+Merge.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#import "NSDictionary+Merge.h"

@implementation NSDictionary (Merge)

+ (NSDictionary*)dictionaryByMerging:(NSDictionary *)primary secondary:(NSDictionary *)secondary {
if (!primary) {
return secondary;
}

if (!secondary) {
return primary;
}

NSMutableDictionary *newDictionary = [[NSMutableDictionary alloc] initWithDictionary:secondary];

[primary enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
if ([newDictionary valueForKey:key] && [[newDictionary valueForKey:key] isKindOfClass:[NSDictionary class]] && [obj isKindOfClass:[NSDictionary class]]) {
[newDictionary setValue:[NSDictionary dictionaryByMerging:obj secondary:[newDictionary valueForKey:key]] forKey:key];
}
else {
[newDictionary setValue:obj forKey:key];
}
}];

return newDictionary;
}

@end
2 changes: 2 additions & 0 deletions UnityAds/Configuration/UADSInitialize.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#import "UADSDevice.h"
#import "UADSConnectivityUtils.h"
#import "UADSWKWebViewApp.h"
#import "UADSVolumeChange.h"

@implementation UADSInitialize

Expand Down Expand Up @@ -112,6 +113,7 @@ - (instancetype)execute {
});
[UADSStorageManager init];
[UADSNotificationObserver unregisterNotificationObserver];
[UADSVolumeChange clearAllDelegates];

id nextState = [[UADSInitializeStateConfig alloc] initWithConfiguration:self.configuration retries:0 retryDelay:5];
return nextState;
Expand Down
5 changes: 4 additions & 1 deletion UnityAds/Connectivity/UADSConnectivityUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
@implementation UADSConnectivityUtils

+ (void)initCarrierInfo {
netinfo = [CTTelephonyNetworkInfo new];
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
netinfo = [CTTelephonyNetworkInfo new];
});
}

+ (NSInteger)getNetworkType {
Expand Down
2 changes: 2 additions & 0 deletions UnityAds/Device/UADSDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,6 @@

+ (NSString *)getGLVersion;

+ (float)getDeviceMaxVolume;

@end
11 changes: 9 additions & 2 deletions UnityAds/Device/UADSDevice.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
@implementation UADSDevice

+ (void)initCarrierUpdates {
uadsTelephonyInfo = [CTTelephonyNetworkInfo new];
uadsTelephonyInfo.subscriberCellularProviderDidUpdateNotifier = ^(CTCarrier *carrier) { };
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
uadsTelephonyInfo = [CTTelephonyNetworkInfo new];
uadsTelephonyInfo.subscriberCellularProviderDidUpdateNotifier = ^(CTCarrier *carrier) { };
});
}

+ (NSString *)getOsVersion {
Expand Down Expand Up @@ -338,5 +341,9 @@ + (NSString *)getGLVersion {
}
}

+ (float)getDeviceMaxVolume {
return 1.0f;
}

@end

13 changes: 3 additions & 10 deletions UnityAds/Device/UADSStorage.h
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@

#import "UADSJsonStorage.h"

typedef NS_ENUM(NSInteger, UnityAdsStorageType) {
kUnityAdsStorageTypePublic = 1,
kUnityAdsStorageTypePrivate = 2
};

@interface UADSStorage : NSObject
@interface UADSStorage : UADSJsonStorage

@property (nonatomic, assign) NSString *targetFileName;
@property (nonatomic, assign) UnityAdsStorageType type;
@property (nonatomic, strong) NSMutableDictionary *storageContents;

- (instancetype)initWithLocation:(NSString *)fileLocation type:(UnityAdsStorageType)type;
- (BOOL)setValue:(id)value forKey:(NSString *)key;
- (id)getValueForKey:(NSString *)key;
- (BOOL)deleteKey:(NSString *)key;
- (NSArray *)getKeys:(NSString *)key recursive:(BOOL)recursive;
- (void)sendEvent:(NSString *)eventType values:(NSDictionary *)values;

// FILE HANDLING
Expand All @@ -24,7 +19,5 @@ typedef NS_ENUM(NSInteger, UnityAdsStorageType) {
- (BOOL)writeStorage;
- (BOOL)storageFileExists;
- (BOOL)clearStorage;
- (void)clearData;
- (BOOL)hasData;

@end
@end
Loading

0 comments on commit 8dbbe6a

Please sign in to comment.