Skip to content

Commit

Permalink
Package: 1.3.0 Release (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonSznol authored Mar 25, 2024
1 parent 027493f commit 040d10f
Show file tree
Hide file tree
Showing 16 changed files with 116 additions and 19 deletions.
3 changes: 2 additions & 1 deletion com.adsbynimbus.nimbus/Editor/AndroidBuildDependencies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

namespace Nimbus.Editor {
public static class AndroidBuildDependencies {
private const string SdkVersion = "2.10.0";
private const string SdkVersion = "2.18.0";

public static string BuildDependencies() {
var builder = new StringBuilder();

builder.AppendLine("");
builder.AppendLine("dependencies {");
builder.AppendLine($@"implementation ""com.adsbynimbus.android:nimbus:{SdkVersion}""");
Expand Down
4 changes: 2 additions & 2 deletions com.adsbynimbus.nimbus/Editor/IOSBuildDependencies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Nimbus.Editor {
public class IOSBuildDependencies {
private const string SdkVersion = "2.10.0";
private const string SdkVersion = "2.20.0";
private readonly List<string> _dependencies = new List<string> {
"'NimbusKit'",
"'NimbusRenderVideoKit'",
Expand All @@ -13,7 +13,7 @@ public class IOSBuildDependencies {
public string BuildDependencies() {
var builder = new StringBuilder();

builder.AppendLine(@"platform :ios, '14.0'
builder.AppendLine(@"platform :ios, '12.0'
use_frameworks!
source 'https://cdn.cocoapods.org/'
");
Expand Down
14 changes: 13 additions & 1 deletion com.adsbynimbus.nimbus/Runtime/Plugins/iOS/NimbusBinding.mm
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,26 @@ int _getConnectionType() {
const char* _getSystemVersion() {
return strdup([[NimbusHelper getSystemVersion] UTF8String]);
}


int _getAtts() {
return (int)[NimbusHelper getAtts];
}

const char* _getVendorId() {
return strdup([[NimbusHelper getVendorId] UTF8String]);
}

void _setCoppa(bool flag) {
[NimbusHelper setCoppaWithFlag: flag];
}

bool _isLimitAdTrackingEnabled() {
return [NimbusHelper isLimitAdTrackingEnabled];
}

const char* _getVersion() {
return strdup([[NimbusHelper getVersion] UTF8String]);
}

const char* _getPlistJSON() {
return strdup([[NimbusHelper getPlistJSON] UTF8String]);
Expand Down
18 changes: 17 additions & 1 deletion com.adsbynimbus.nimbus/Runtime/Plugins/iOS/NimbusHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,22 @@ import AppTrackingTransparency
@objc public class func getSystemVersion() -> String {
UIDevice.current.systemVersion
}

@objc public class func getVendorId() -> String? {
UIDevice.current.identifierForVendor?.uuidString
}

@objc public class func getVersion() -> String? {
Nimbus.shared.version
}

@objc public class func getAtts() -> Int {
if #available(iOS 14.0, *) {
return Int(ATTrackingManager.trackingAuthorizationStatus.rawValue)
} else {
return -1
}
}

@objc public class func setCoppa(flag: Bool) {
Nimbus.shared.coppa = flag;
Expand All @@ -55,4 +71,4 @@ import AppTrackingTransparency
}
return String(data: jsonData, encoding: .ascii)
}
}
}
10 changes: 7 additions & 3 deletions com.adsbynimbus.nimbus/Runtime/Plugins/iOS/NimbusManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ import NimbusRequestAPSKit
) {
Nimbus.shared.initialize(publisher: publisher, apiKey: apiKey)
Nimbus.shared.logLevel = enableUnityLogs ? .debug : .off
let videoRenderer = NimbusVideoAdRenderer()
videoRenderer.showMuteButton = true
Nimbus.shared.renderers = [
.forAuctionType(.static): NimbusStaticAdRenderer(),
.forAuctionType(.video): NimbusVideoAdRenderer()
.forAuctionType(.video): videoRenderer,
]
}

Expand Down Expand Up @@ -97,9 +99,11 @@ import NimbusRequestAPSKit

if isBlocking {
adView = NimbusAdView(adPresentingViewController: viewController)
adView?.delegate = self
adView?.volume = 100
guard let adView = adView else { return }
adView.delegate = self
adView.volume = 100
adView.isBlocking = true
adView.showsSKOverlay = true

let companionAd: NimbusCompanionAd
if UIDevice.current.orientation.isLandscape {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ internal override Device GetDevice() {
var ctx = CastToJavaObject(_currentActivity, "android.content.Context");
_deviceCache.Ua = _nimbus.CallStatic<string>("getUserAgent", ctx);
_deviceCache.ConnectionType =
(ConnectionType)_connectionTypeHelper.CallStatic<byte>("getConnectionType", ctx);
(ConnectionType)_connectionTypeHelper.CallStatic<sbyte>("getConnectionType", ctx);

var _adInfo = _nimbus.CallStatic<AndroidJavaObject>("getAdIdInfo");
_deviceCache.Lmt = _adInfo.Call<bool>("isLimitAdTrackingEnabled") ? 1 : 0;
Expand All @@ -116,6 +116,10 @@ internal override void SetCoppaFlag(bool flag) {
_nimbus.SetStatic("COPPA", flag);
}

internal override string GetVersion() {
return _nimbus.GetStatic<string>("version");
}

private static AndroidJavaObject CastToJavaObject(AndroidJavaObject source, string className) {
var clazz = new AndroidJavaClass("java.lang.Class");
var destClass = clazz.CallStatic<AndroidJavaObject>("forName", className);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,9 @@ internal override List<IInterceptor> Interceptors() {
internal override void SetCoppaFlag(bool flag) {
Debug.unityLogger.Log($"Mock Coppa flag set {flag}");
}

internal override string GetVersion() {
return "1.3.0";
}
}
}
20 changes: 20 additions & 0 deletions com.adsbynimbus.nimbus/Runtime/Scripts/Nimbus.Internal/IOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ private static extern void _renderAd(int adUnitInstanceId, string bidResponse, b
[DllImport("__Internal")]
private static extern string _getPlistJSON();

[DllImport("__Internal")]
private static extern int _getAtts();

[DllImport("__Internal")]
private static extern string _getVendorId();

[DllImport("__Internal")]
private static extern string _getVersion();

private Device _deviceCache;
private string _sessionId;

Expand Down Expand Up @@ -127,12 +136,19 @@ internal override Device GetDevice() {
Make = "apple",
Model = _getDeviceModel(),
Osv = _getSystemVersion(),
Ext = new DeviceExt {
Ifv = _getVendorId()
},
};

_deviceCache.ConnectionType = (ConnectionType)_getConnectionType();
_deviceCache.Lmt = _isLimitAdTrackingEnabled() ? 1 : 0;
_deviceCache.Ifa = _getAdvertisingId();
_deviceCache.Ua = _getUserAgent();
var atts = _getAtts();
if (atts > -1) {
_deviceCache.Ext.Atts = atts;
}

return _deviceCache;
}
Expand All @@ -145,6 +161,10 @@ internal override void SetCoppaFlag(bool flag) {
_setCoppa(flag);
}

internal override string GetVersion() {
return _getVersion();
}

private static string GetPlistJson() {
return _getPlistJSON();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@ namespace Nimbus.Internal.Network {
public class NimbusClient {
private const string ProductionPath = "/rta/v1";
private const string TestingPath = "/rta/test";

private static readonly HttpClient Client = new HttpClient();
private readonly string _nimbusEndpoint = "https://{0}.adsbynimbus.com{1}";
private CancellationTokenSource _ctx;

public NimbusClient(CancellationTokenSource ctx, NimbusSDKConfiguration configuration) {
public readonly string platformSdkv;

public NimbusClient(CancellationTokenSource ctx, NimbusSDKConfiguration configuration, string platformSdkVersion) {
platformSdkv = platformSdkVersion;
Client.DefaultRequestHeaders.Add("Nimbus-Api-Key", configuration.apiKey);
Client.DefaultRequestHeaders.Add("Nimbus-Sdkv", "2.1.0");
Client.DefaultRequestHeaders.Add("Nimbus-Unity-Sdkv", "1.1.1");
Client.DefaultRequestHeaders.Add("Nimbus-Sdkv", platformSdkv);
Client.DefaultRequestHeaders.Add("Nimbus-Unity-Sdkv", "1.3.0");
Client.DefaultRequestHeaders.Add("X-Openrtb-Version", "2.5");
Client.Timeout = TimeSpan.FromSeconds(10);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ public abstract class NimbusAPI {
internal abstract Device GetDevice();
internal abstract void SetCoppaFlag(bool flag);
internal abstract List<IInterceptor> Interceptors();
internal abstract string GetVersion();
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Threading.Tasks;
using Newtonsoft.Json;
using OpenRTB.Response;
Expand Down Expand Up @@ -112,7 +113,20 @@ internal void FireMobileAdEvents(AdEventTypes e) {

internal async void LoadJsonResponseAsync(Task<string> jsonBody) {
await Task.Run(async () => {
var response = await jsonBody;
var response = "";
try {
response = await jsonBody;
} catch (Exception e) { }

if (String.IsNullOrEmpty(response)) {
var networkError = new ErrResponse();
networkError.Id = "";
networkError.StatusCode = 0;
networkError.Message = "Unknown network error occurred";
ErrResponse = networkError;
_adEvents.FireOnAdErrorEvent(this);
return;
}
if (response.Contains("message")) {
ErrResponse = JsonConvert.DeserializeObject<ErrResponse>(response);
_adEvents.FireOnAdErrorEvent(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Nimbus.Internal.RequestBuilder {
public static class BannerExtension {
private static readonly Api[] DefaultApis = { Api.Mraid1, Api.Mraid2, Api.Mraid3 };
private static readonly Api[] DefaultApis = { Api.Mraid1, Api.Mraid2, Api.Mraid3, Api.Omid };

public static Banner Interstitial(this Banner banner) {
var size = Input.deviceOrientation == DeviceOrientation.Portrait
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ public static BidRequest SetRewardedVideoFlag(this BidRequest bidRequest, bool r
return bidRequest;
}

public static BidRequest SetOMInformation(this BidRequest bidRequest, string sdkVersion) {
var source = new Source();
source.Ext = new SourceExt();
source.Ext.Omidpn = "Adsbynimbus";
source.Ext.Omidpv = sdkVersion;
bidRequest.Source = source;
return bidRequest;
}

internal static bool IsHybridBidRequest(this BidRequest bidRequest) {
if (bidRequest.Imp.IsNullOrEmpty()) return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public static class VideoExtension {
Protocols.Vast2, Protocols.Vast3, Protocols.Vast2Wrapper, Protocols.Vast3Wrapper
};

private static readonly Api[] DefaultApis = { Api.Omid };

#if UNITY_EDITOR || UNITY_ANDROID
private static readonly string[] DefaultMimes =
{ "application/x-mpegurl", "video/mp4", "video/3gpp", "video/x-flv" };
Expand All @@ -21,6 +23,7 @@ public static Video Interstitial(this Video video) {
video.Pos = Position.Fullscreen;
video.Protocols = DefaultProtocols;
video.Mimes = DefaultMimes;
video.Api = DefaultApis;
return video;
}

Expand All @@ -32,6 +35,7 @@ public static Video SetupDefaults(this Video video, Position position, float flo
video.Pos = position;
video.Protocols = DefaultProtocols;
video.Mimes = DefaultMimes;
video.Api = DefaultApis;
return video;
}

Expand Down
13 changes: 9 additions & 4 deletions com.adsbynimbus.nimbus/Runtime/Scripts/NimbusManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private void Awake() {
_regulations = new GlobalRtbRegulation();
_nimbusPlatformAPI.InitializeSDK(_configuration);
_ctx = new CancellationTokenSource();
_nimbusClient = new NimbusClient(_ctx, _configuration);
_nimbusClient = new NimbusClient(_ctx, _configuration, _nimbusPlatformAPI.GetVersion());
Instance = this;
DontDestroyOnLoad(gameObject);
}
Expand Down Expand Up @@ -485,8 +485,12 @@ private async Task<string> MakeRequestAsyncWithInterceptor(BidRequest bidRequest
#endif

private NimbusAdUnit RequestForNimbusAdUnit(BidRequest bidRequest, AdUnitType adUnitType) {
var responseJson =
MakeRequestAsyncWithInterceptor(bidRequest, adUnitType, AdUnitHelper.IsAdTypeFullScreen(adUnitType));
Task<string> responseJson;
try {
responseJson = MakeRequestAsyncWithInterceptor(bidRequest, adUnitType, AdUnitHelper.IsAdTypeFullScreen(adUnitType));
} catch (Exception e) {
responseJson = Task.FromException<string>(e);
}
var adUnit = new NimbusAdUnit(adUnitType, NimbusEvents);
adUnit.LoadJsonResponseAsync(responseJson);
return adUnit;
Expand All @@ -497,7 +501,8 @@ private BidRequest SetUniversalRtbData(BidRequest bidRequest, string position) {
SetSessionId(_nimbusPlatformAPI.GetSessionID()).
SetDevice(_nimbusPlatformAPI.GetDevice()).
SetTest(_configuration.enableSDKInTestMode).
SetReportingPosition(position);
SetReportingPosition(position).
SetOMInformation(_nimbusClient.platformSdkv);
SetTestData(bidRequest);
SetRegulations(bidRequest);
return bidRequest;
Expand Down
2 changes: 1 addition & 1 deletion com.adsbynimbus.nimbus/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.adsbynimbus.nimbus",
"version": "1.1.1",
"version": "1.3.0",
"displayName": "Ads By Nimbus",
"description": "This package allows for Unity games to access ads driven by Nimbus",
"unity": "2020.3",
Expand Down

0 comments on commit 040d10f

Please sign in to comment.