Skip to content

Commit

Permalink
Release 3.4.8
Browse files Browse the repository at this point in the history
  • Loading branch information
UnitySteven committed Aug 6, 2020
1 parent 077dc1c commit 0bb6959
Show file tree
Hide file tree
Showing 19 changed files with 425 additions and 6 deletions.
4 changes: 2 additions & 2 deletions UnityAds.podspec
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Pod::Spec.new do |s|
s.name = 'UnityAds'
s.version = '3.4.6'
s.version = '3.4.8'
s.license = { :type => 'Apache License, Version 2.0', :file => 'LICENSE' }
s.author = { 'UnityAds' => '[email protected]' }
s.homepage = 'https://unity3d.com/services/ads'
s.summary = 'Monetize your entire player base and reach new audiences with video ads.'
s.platform = :ios
s.source = { :http => 'https://github.com/Unity-Technologies/unity-ads-ios/releases/download/3.4.6/UnityAds.framework.zip' }
s.source = { :http => 'https://github.com/Unity-Technologies/unity-ads-ios/releases/download/3.4.8/UnityAds.framework.zip' }
s.ios.deployment_target = '9.0'
s.ios.vendored_frameworks = 'UnityAds.framework'
s.ios.xcconfig = { 'OTHER_LDFLAGS' => '-framework UnityAds' }
Expand Down
14 changes: 13 additions & 1 deletion UnityAdsExample/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,19 @@
</array>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key><true/>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>SKAdNetworkItems</key>
<array>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>4DZT52R2T5.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>example.skadnetwork</string>
</dict>
</array>
</dict>
</plist>
7 changes: 7 additions & 0 deletions UnityAdsTests/ClientPropertiesTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ - (void)testSetGameId {
XCTAssertEqualObjects([USRVClientProperties getGameId], @"54321");
}

- (void)testGetAdNetworkIds {
NSArray* ids = [USRVClientProperties getAdNetworkIdsPlist];
NSArray* expected = @[@"4DZT52R2T5.skadnetwork", @"example.skadnetwork"];

XCTAssertTrue([expected isEqualToArray:ids], @"Both arrays should be equal: %@ %@", ids, expected);
}

/* TEST DELEGATE */

- (void)unityAdsReady:(NSString *)placementId {
Expand Down
40 changes: 40 additions & 0 deletions UnityAdsTests/DeviceTests.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#import <XCTest/XCTest.h>
#import "UnityAdsTests-Bridging-Header.h"
#import <sys/utsname.h>
#import "NSString+Hash.h"

@interface DeviceTests : XCTestCase
@end
Expand Down Expand Up @@ -166,4 +167,43 @@ - (void)testGetCPUCount {
XCTAssertTrue([USRVDevice getCPUCount] > 0, @"Device CPU count should be greater than 0");
}

- (void)testGetDeviceName {
NSString *deviceName = [USRVDevice getDeviceName];
XCTAssertEqualObjects(deviceName, [[[UIDevice currentDevice] name] unityads_sha256], @"Device name should be correct");
}

- (void)testGetIdentifierForVendor {
NSString *identifierForVendor = [USRVDevice getVendorIdentifier];
NSLog(@"IDFV: %@", identifierForVendor);
XCTAssertNotNil(identifierForVendor, "Identifier for vendor should not be nil");
}

- (void)testGetSystemBootTime {
NSNumber *systemBootTime = [USRVDevice getSystemBootTime];
NSLog(@"System Boot Time: %d", [systemBootTime intValue]);
XCTAssertTrue(systemBootTime > 0, "Sytem Boot Time should be a positive integer and not equal to 0");
}

- (void)testGetSystemBootTimeReturnsSame {
NSNumber *systemBootTime1 = [USRVDevice getSystemBootTime];
NSNumber *systemBootTime2 = [USRVDevice getSystemBootTime];

XCTAssertEqual(systemBootTime1, systemBootTime2, "Sytem Boot Time should be equal");
}

- (void)testGetLocaleList {
NSArray<NSString*> *localeList = [USRVDevice getLocaleList];

XCTAssertGreaterThanOrEqual([localeList count], 1, @"Locale list should have at least 1 item in it");

if ([USRVDevice isSimulator]) {
XCTAssertEqualObjects(localeList[0], @"en", @"Locale list should be correct");
}
}

- (void)testGetCurrentUITheme {
NSNumber *currentTheme = [USRVDevice getCurrentUITheme];
XCTAssertEqual(currentTheme, [NSNumber numberWithInt:1], @"Current theme should be light");
}

@end
24 changes: 24 additions & 0 deletions UnityServices/Core/Api/USRVApiDeviceInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ + (void)WebViewExposed_getSupportedOrientationsPlist:(USRVWebViewCallback *)call
[callback invoke:[USRVClientProperties getSupportedOrientationsPlist], nil];
}

+ (void)WebViewExposed_getAdNetworkIdsPlist:(USRVWebViewCallback *)callback {
[callback invoke:[USRVClientProperties getAdNetworkIdsPlist], nil];
}

+ (void)WebViewExposed_getSupportedOrientations:(USRVWebViewCallback *)callback {
[callback invoke:[NSNumber numberWithInt:[USRVClientProperties getSupportedOrientations]], nil];
}
Expand Down Expand Up @@ -222,4 +226,24 @@ + (void)WebViewExposed_getCPUCount:(USRVWebViewCallback *)callback {
[callback invoke:[NSNumber numberWithUnsignedInteger:[USRVDevice getCPUCount]], nil];
}

+ (void)WebViewExposed_getVendorIdentifier:(USRVWebViewCallback *)callback {
[callback invoke:[USRVDevice getVendorIdentifier], nil];
}

+ (void)WebViewExposed_getDeviceName:(USRVWebViewCallback *)callback {
[callback invoke:[USRVDevice getDeviceName], nil];
}

+ (void)WebViewExposed_getSystemBootTime:(USRVWebViewCallback *)callback {
[callback invoke:[USRVDevice getSystemBootTime], nil];
}

+ (void)WebViewExposed_getLocaleList:(USRVWebViewCallback *)callback {
[callback invoke:[USRVDevice getLocaleList], nil];
}

+ (void)WebViewExposed_getCurrentUITheme:(USRVWebViewCallback *)callback {
[callback invoke:[USRVDevice getCurrentUITheme], nil];
}

@end
2 changes: 2 additions & 0 deletions UnityServices/Core/Api/USRVApiTrackingManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@interface USRVApiTrackingManager : NSObject
@end
22 changes: 22 additions & 0 deletions UnityServices/Core/Api/USRVApiTrackingManager.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#import "USRVApiTrackingManager.h"
#import "USRVWebViewCallback.h"
#import "USRVTrackingManagerProxy.h"

@implementation USRVApiTrackingManager

+(void)WebViewExposed_getTrackingAuthorizationStatus:(USRVWebViewCallback *)callback {
NSUInteger status = [[USRVTrackingManagerProxy sharedInstance] trackingAuthorizationStatus];
[callback invoke:[NSNumber numberWithUnsignedLong:status], nil];
}

+(void)WebViewExposed_requestTrackingAuthorization:(USRVWebViewCallback *)callback {
[[USRVTrackingManagerProxy sharedInstance] requestTrackingAuthorization];
[callback invoke:nil];
}

+(void)WebViewExposed_available:(USRVWebViewCallback *)callback {
BOOL available = [[USRVTrackingManagerProxy sharedInstance] available];
[callback invoke:[NSNumber numberWithBool:available], nil];
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ @implementation USRVCoreModuleConfiguration
@"USRVApiSensorInfo",
@"USRVApiPermissions",
@"USRVApiMainBundle",
@"USRVApiWebAuth"
@"USRVApiWebAuth",
@"USRVApiTrackingManager",
@"USRVApiSKAdNetwork"
];
}

Expand Down
9 changes: 9 additions & 0 deletions UnityServices/Core/Device/USRVDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,13 @@

+ (void)checkIsMuted;

+ (NSString *)getVendorIdentifier;

+ (NSString*)getDeviceName;

+ (NSNumber*)getSystemBootTime;

+ (NSArray<NSString*>*)getLocaleList;

+ (NSNumber*)getCurrentUITheme;
@end
43 changes: 43 additions & 0 deletions UnityServices/Core/Device/USRVDevice.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
#import <sys/utsname.h>
#import <mach/mach.h>
#import <objc/runtime.h>
#import <sys/sysctl.h>

#import "USRVDevice.h"
#import "USRVConnectivityUtils.h"
#import "NSString+Hash.h"

static CTTelephonyNetworkInfo *uadsTelephonyInfo;
static NSNumber *uadsBootTime = nil;

@implementation USRVDevice

Expand Down Expand Up @@ -421,4 +424,44 @@ + (void)checkIsMuted {
return;
}

+ (NSString *)getVendorIdentifier {
NSString *vendorIdentifier = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
return vendorIdentifier ?: @"00000000-0000-0000-0000-000000000000";
}

+ (NSString*)getDeviceName {
return [[[UIDevice currentDevice] name] unityads_sha256];
}

+ (NSNumber*)getSystemBootTime {
if (uadsBootTime == nil) {
struct timeval bootTime;
size_t len = sizeof(bootTime);
int mib[2] = {CTL_KERN, KERN_BOOTTIME};

if(sysctl(mib, sizeof(mib) / sizeof(*mib), &bootTime, &len, NULL, 0) >= 0) {
uadsBootTime = [NSNumber numberWithLong:bootTime.tv_sec];
}
}

if (uadsBootTime == nil) {
return [NSNumber numberWithLong:-1];
}

return uadsBootTime;
}

+ (NSArray<NSString*>*)getLocaleList {
return [NSLocale preferredLanguages];
}

+ (NSNumber*)getCurrentUITheme {
if (@available(iOS 12.0, *)) {
id value = [UIScreen.mainScreen.traitCollection valueForKey:@"userInterfaceStyle"];
return [NSNumber numberWithInt:[value intValue]];
}

return [NSNumber numberWithInt:1];
}

@end
1 change: 1 addition & 0 deletions UnityServices/Core/Properties/USRVClientProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
+ (void)setGameId:(NSString *)gid;
+ (NSString *)getGameId;
+ (NSArray<NSString*>*)getSupportedOrientationsPlist;
+ (NSArray<NSString *>*)getAdNetworkIdsPlist;
+ (int)getSupportedOrientations;
+ (NSString *)getAppName;
+ (NSString *)getAppVersion;
Expand Down
17 changes: 17 additions & 0 deletions UnityServices/Core/Properties/USRVClientProperties.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,23 @@ + (NSString *)getGameId {
return supportedOrientations;
}

+ (NSArray<NSString *> *)getAdNetworkIdsPlist {
NSMutableArray<NSString *> * adNetworkIds = [[NSMutableArray alloc] init];
NSArray* adNetworkItems = [NSBundle.mainBundle.infoDictionary objectForKey:@"SKAdNetworkItems"];
if (adNetworkItems != nil) {
adNetworkIds = [[NSMutableArray alloc] initWithCapacity:[adNetworkItems count]];

for (int i = 0; i < adNetworkItems.count; i++) {
NSString* adNetworkId = [[adNetworkItems objectAtIndex:i] objectForKey:@"SKAdNetworkIdentifier"];

if (adNetworkId != nil) {
[adNetworkIds addObject:adNetworkId];
}
}
}
return adNetworkIds;
}

+ (int)getSupportedOrientations {
return (int) [[UIApplication sharedApplication] supportedInterfaceOrientationsForWindow:[[UIApplication sharedApplication] keyWindow]];
}
Expand Down
4 changes: 2 additions & 2 deletions UnityServices/Core/Properties/USRVSdkProperties.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
NSString * const kUnityServicesLocalCacheFilePrefix = @"UnityAdsCache-";
NSString * const kUnityServicesLocalStorageFilePrefix = @"UnityAdsStorage-";
NSString * const kUnityServicesWebviewBranchInfoDictionaryKey = @"UADSWebviewBranch";
NSString * const kUnityServicesVersionName = @"3.4.6";
NSString * const kUnityServicesVersionName = @"3.4.8";
NSString * const kUnityServicesFlavorDebug = @"debug";
NSString * const kUnityServicesFlavorRelease = @"release";
NSString * const kChinaIsoAlpha2Code = @"CN";
NSString * const kChinaIsoAlpha3Code = @"CHN";
int const kUnityServicesVersionCode = 3460;
int const kUnityServicesVersionCode = 3480;

@implementation USRVSdkProperties

Expand Down
2 changes: 2 additions & 0 deletions UnityServices/Core/SKAdNetwork/USRVApiSKAdNetwork.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@interface USRVApiSKAdNetwork : NSObject
@end
23 changes: 23 additions & 0 deletions UnityServices/Core/SKAdNetwork/USRVApiSKAdNetwork.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#import "USRVApiSKAdNetwork.h"
#import "USRVWebViewCallback.h"
#import "USRVSKAdNetworkProxy.h"

@implementation USRVApiSKAdNetwork


+(void)WebViewExposed_available:(USRVWebViewCallback *)callback {
BOOL available = [[USRVSKAdNetworkProxy sharedInstance] available];
[callback invoke:[NSNumber numberWithBool:available], nil];
}

+(void)WebViewExposed_updateConversionValue:(NSInteger)conversionValue callback:(USRVWebViewCallback *)callback {
[[USRVSKAdNetworkProxy sharedInstance] updateConversionValue:conversionValue];
[callback invoke:nil];
}

+(void)WebViewExposed_registerAppForAdNetworkAttribution:(USRVWebViewCallback *)callback {
[[USRVSKAdNetworkProxy sharedInstance] registerAppForAdNetworkAttribution];
[callback invoke:nil];
}

@end
11 changes: 11 additions & 0 deletions UnityServices/Core/SKAdNetwork/USRVSKAdNetworkProxy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#import <Foundation/Foundation.h>
#import "USRVWebViewApp.h"

@interface USRVSKAdNetworkProxy : NSObject

+(USRVSKAdNetworkProxy*)sharedInstance;
-(BOOL)available;
-(void)updateConversionValue:(NSInteger)conversionValue;
-(void)registerAppForAdNetworkAttribution;

@end
Loading

0 comments on commit 0bb6959

Please sign in to comment.