-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bf6b75d
commit 2bccc7c
Showing
113 changed files
with
102,264 additions
and
245 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
6 changes: 4 additions & 2 deletions
6
...r/Editor/NeftaCustomAdapter.Editor.asmdef → Assets/Nefta/Editor/Nefta.Editor.asmdef
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
using System; | ||
using System.IO; | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
namespace Nefta.Editor | ||
{ | ||
[CustomEditor(typeof(NeftaConfiguration), false)] | ||
public class NeftaConfigurationInspector : UnityEditor.Editor | ||
{ | ||
private NeftaConfiguration _configuration; | ||
private bool _isLoggingEnabled; | ||
|
||
private static PluginImporter GetImporter(bool debug) | ||
{ | ||
var guid = AssetDatabase.FindAssets(debug ? "NeftaCustomAdapter-debug" : "NeftaCustomAdapter-release")[0]; | ||
var path = AssetDatabase.GUIDToAssetPath(guid); | ||
return (PluginImporter) AssetImporter.GetAtPath(path); | ||
} | ||
|
||
public void OnEnable() | ||
{ | ||
_configuration = (NeftaConfiguration)target; | ||
|
||
var importer = GetImporter(true); | ||
var isDebugPluginEnabled = importer.GetCompatibleWithPlatform(BuildTarget.Android); | ||
if (isDebugPluginEnabled != _configuration._isLoggingEnabled) | ||
{ | ||
_configuration._isLoggingEnabled = isDebugPluginEnabled; | ||
EditorUtility.SetDirty(_configuration); | ||
AssetDatabase.SaveAssetIfDirty(_configuration); | ||
} | ||
} | ||
|
||
public void OnDisable() | ||
{ | ||
_configuration = null; | ||
} | ||
|
||
public override void OnInspectorGUI() | ||
{ | ||
base.OnInspectorGUI(); | ||
if (_isLoggingEnabled != _configuration._isLoggingEnabled) | ||
{ | ||
_isLoggingEnabled = _configuration._isLoggingEnabled; | ||
|
||
var importer = GetImporter(true); | ||
importer.SetCompatibleWithPlatform(BuildTarget.Android, _isLoggingEnabled); | ||
importer.SaveAndReimport(); | ||
|
||
importer = GetImporter(false); | ||
importer.SetCompatibleWithPlatform(BuildTarget.Android, !_isLoggingEnabled); | ||
importer.SaveAndReimport(); | ||
} | ||
} | ||
|
||
private static NeftaConfiguration GetNeftaConfiguration() | ||
{ | ||
NeftaConfiguration configuration = null; | ||
|
||
string[] guids = AssetDatabase.FindAssets("t:NeftaConfiguration"); | ||
if (guids.Length > 0) | ||
{ | ||
var path = AssetDatabase.GUIDToAssetPath(guids[0]); | ||
configuration = AssetDatabase.LoadAssetAtPath<NeftaConfiguration>(path); | ||
} | ||
|
||
return configuration; | ||
} | ||
|
||
[MenuItem("Ads Mediation/Select Nefta Configuration", false, int.MaxValue)] | ||
private static void SelectNeftaConfiguration() | ||
{ | ||
var configuration = GetNeftaConfiguration(); | ||
if (configuration == null) | ||
{ | ||
configuration = CreateInstance<NeftaConfiguration>(); | ||
|
||
var directory = "Assets/Resources"; | ||
var assetPath = $"{directory}/{NeftaConfiguration.FileName}.asset"; | ||
if (!Directory.Exists(directory)) | ||
{ | ||
Directory.CreateDirectory(directory); | ||
} | ||
AssetDatabase.CreateAsset(configuration, assetPath); | ||
AssetDatabase.SaveAssets(); | ||
AssetDatabase.Refresh(); | ||
} | ||
Selection.objects = new UnityEngine.Object[] { configuration }; | ||
} | ||
|
||
[MenuItem("Ads Mediation/Export Nefta Custom Adapter SDK", false, int.MaxValue)] | ||
private static void ExportAdSdkPackage() | ||
{ | ||
var packageName = $"NeftaIS_SDK_{Application.version}.unitypackage"; | ||
var assetPaths = new string[] { "Assets/Nefta" }; | ||
|
||
var importer = GetImporter(true); | ||
importer.SetCompatibleWithPlatform(BuildTarget.Android, true); | ||
importer.SaveAndReimport(); | ||
|
||
importer = GetImporter(false); | ||
importer.SetCompatibleWithPlatform(BuildTarget.Android, false); | ||
importer.SaveAndReimport(); | ||
|
||
try | ||
{ | ||
AssetDatabase.ExportPackage(assetPaths, packageName, ExportPackageOptions.Recurse); | ||
Debug.Log($"Finished exporting {packageName}"); | ||
} | ||
catch (Exception e) | ||
{ | ||
Debug.LogError($"Error exporting {packageName}: {e.Message}"); | ||
} | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"name": "Nefta" | ||
} |
File renamed without changes.
8 changes: 5 additions & 3 deletions
8
...ustomAdapter/Editor/NeftaConfiguration.cs → Assets/Nefta/NeftaConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// ISNeftaCustomAdapter.h | ||
// UnityFramework | ||
// | ||
// Created by Tomaz Treven on 14/11/2023. | ||
// | ||
|
||
#ifndef ISNeftaCustomAdapter_h | ||
#define ISNeftaCustomAdapter_h | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
#import <IronSource/IronSource.h> | ||
|
||
#import <NeftaSDK/NeftaSDK-Swift.h> | ||
|
||
@interface ISNeftaCustomAdapter : ISBaseNetworkAdapter | ||
|
||
+ (void)ApplyRenderer:(UIViewController *)viewController; | ||
- (void)Load:(NSString *)pId delgate:(id<ISAdapterAdDelegate>)delegate; | ||
- (BOOL)IsReady:(NSString *)pId; | ||
- (void)Show:(NSString *)pId; | ||
- (void)Close:(NSString *)pId; | ||
@end | ||
|
||
#endif /* ISNeftaCustomAdapter_h */ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
// | ||
// ISNeftaCustomAdapter.m | ||
// Unity-iPhone | ||
// | ||
// Created by Tomaz Treven on 14/11/2023. | ||
// | ||
|
||
#import "ISNeftaCustomAdapter.h" | ||
|
||
@implementation ISNeftaCustomAdapter | ||
|
||
static NeftaPlugin_iOS *_plugin; | ||
static NSMutableDictionary<NSString *, id<ISAdapterAdDelegate>> *_listeners; | ||
static dispatch_semaphore_t _semaphore; | ||
|
||
- (void)setAdapterDebug:(BOOL)adapterDebug { | ||
[NeftaPlugin_iOS EnableLogging: adapterDebug]; | ||
} | ||
|
||
- (void)init:(ISAdData *)adData delegate:(id<ISNetworkInitializationDelegate>)delegate { | ||
@synchronized (NeftaPlugin_iOS.Version) { | ||
if (_semaphore == nil) { | ||
_semaphore = dispatch_semaphore_create(1); | ||
} | ||
|
||
dispatch_semaphore_wait(_semaphore, DISPATCH_TIME_FOREVER); | ||
if (_listeners != nil) { | ||
dispatch_semaphore_signal(_semaphore); | ||
[delegate onInitDidSucceed]; | ||
return; | ||
} | ||
|
||
NSString *appId = [adData getString: @"appId"]; | ||
if (appId == nil || appId.length == 0) { | ||
dispatch_semaphore_signal(_semaphore); | ||
[delegate onInitDidFailWithErrorCode:ISAdapterErrorMissingParams errorMessage:@"Missing appId"]; | ||
return; | ||
} | ||
|
||
dispatch_async(dispatch_get_main_queue(), ^{ | ||
_plugin = [NeftaPlugin_iOS InitWithAppId: appId]; | ||
|
||
_listeners = [[NSMutableDictionary alloc] init]; | ||
|
||
_plugin.OnLoadFail = ^(Placement *placement, NSString *error) { | ||
id<ISAdapterAdDelegate> listener = _listeners[placement._id]; | ||
[listener adDidFailToLoadWithErrorType:ISAdapterErrorTypeInternal errorCode:2 errorMessage:error]; | ||
[_listeners removeObjectForKey: placement._id]; | ||
}; | ||
|
||
_plugin.OnLoad = ^(Placement *placement) { | ||
id<ISAdapterAdDelegate> listener = _listeners[placement._id]; | ||
if (placement._type == TypesBanner) { | ||
dispatch_async(dispatch_get_main_queue(), ^{ | ||
[_plugin ShowMainWithId: placement._id]; | ||
[((id<ISBannerAdDelegate>)listener) adDidLoadWithView: [_plugin GetViewForPlacement: placement]]; | ||
}); | ||
} else { | ||
[listener adDidLoad]; | ||
} | ||
}; | ||
|
||
_plugin.OnShow = ^(Placement *placement, NSInteger width, NSInteger height) { | ||
id<ISAdapterAdDelegate> listener = _listeners[placement._id]; | ||
if (placement._type == TypesBanner) { | ||
id<ISBannerAdDelegate> bannerListener = (id<ISBannerAdDelegate>) listener; | ||
[bannerListener adDidOpen]; | ||
[bannerListener adWillPresentScreen]; | ||
} else { | ||
id<ISAdapterAdInteractionDelegate> interactionListener = (id<ISAdapterAdInteractionDelegate>) listener; | ||
[interactionListener adDidOpen]; | ||
[interactionListener adDidShowSucceed]; | ||
[interactionListener adDidBecomeVisible]; | ||
} | ||
}; | ||
|
||
_plugin.OnClick = ^(Placement *placement) { | ||
id<ISAdapterAdDelegate> listener = _listeners[placement._id]; | ||
[listener adDidClick]; | ||
}; | ||
|
||
_plugin.OnReward = ^(Placement *placement) { | ||
id<ISRewardedVideoAdDelegate> listener = (id<ISRewardedVideoAdDelegate>) _listeners[placement._id]; | ||
if (listener != nil) { | ||
[listener adRewarded]; | ||
} | ||
}; | ||
|
||
_plugin.OnClose = ^(Placement *placement) { | ||
id<ISAdapterAdDelegate> listener = _listeners[placement._id]; | ||
if (placement._type == TypesBanner) { | ||
[((id<ISBannerAdDelegate>)listener) adDidDismissScreen]; | ||
} else { | ||
id<ISAdapterAdInteractionDelegate> interactionListener = (id<ISAdapterAdInteractionDelegate>) listener; | ||
[interactionListener adDidEnd]; | ||
[interactionListener adDidClose]; | ||
} | ||
[_listeners removeObjectForKey: placement._id]; | ||
}; | ||
|
||
[_plugin EnableAds: true]; | ||
|
||
dispatch_semaphore_signal(_semaphore); | ||
[delegate onInitDidSucceed]; | ||
}); | ||
} | ||
} | ||
|
||
- (NSString *) networkSDKVersion { | ||
return NeftaPlugin_iOS.Version; | ||
} | ||
|
||
- (NSString *) adapterVersion { | ||
return @"1.2.4"; | ||
} | ||
|
||
+ (void)ApplyRenderer:(UIViewController *)viewController { | ||
[_plugin PrepareRendererWithViewController: viewController]; | ||
} | ||
|
||
- (void)Load:(NSString *)pId delgate:(id<ISAdapterAdDelegate>)delegate { | ||
dispatch_semaphore_wait(_semaphore, DISPATCH_TIME_FOREVER); | ||
_listeners[pId] = delegate; | ||
[_plugin LoadWithId: pId]; | ||
dispatch_semaphore_signal(_semaphore); | ||
} | ||
|
||
- (BOOL)IsReady:(NSString *)pId { | ||
return [_plugin IsReadyWithId: pId]; | ||
} | ||
|
||
- (void)Show:(NSString *)pId { | ||
[_plugin ShowWithId: pId]; | ||
} | ||
|
||
- (void)Close:(NSString *)pId { | ||
[_plugin CloseWithId: pId]; | ||
} | ||
@end |
Oops, something went wrong.