Skip to content

Commit

Permalink
Video playback improvements
Browse files Browse the repository at this point in the history
Added xcprivacy
Added BE configurable timeouts
Added utcOffset to events
Added heartbeat game event
  • Loading branch information
TrevenNefta committed Apr 8, 2024
1 parent 291d22d commit 0743cde
Show file tree
Hide file tree
Showing 28 changed files with 7,226 additions and 3,981 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
134 changes: 93 additions & 41 deletions Assets/Nefta/Plugins/iOS/ISNeftaCustomAdapter.m
Expand Up @@ -7,10 +7,29 @@

#import "ISNeftaCustomAdapter.h"


@interface MListener : NSObject
@property (nonatomic, strong) NSString* placementId;
@property (nonatomic) int state;
@property (nonatomic, strong) id<ISAdapterAdDelegate> listener;
-(instancetype)initWithId:(NSString *)placementId listener:(id<ISAdapterAdDelegate>)listener;
@end
@implementation MListener
-(instancetype)initWithId:(NSString *)placementId listener:(id<ISAdapterAdDelegate>)listener {
self = [super init];
if (self) {
_placementId = placementId;
_state = 0;
_listener = listener;
}
return self;
}
@end

@implementation ISNeftaCustomAdapter

static NeftaPlugin_iOS *_plugin;
static NSMutableDictionary<NSString *, id<ISAdapterAdDelegate>> *_listeners;
static NSMutableArray *_listeners;
static dispatch_semaphore_t _semaphore;

- (void)setAdapterDebug:(BOOL)adapterDebug {
Expand Down Expand Up @@ -40,65 +59,96 @@ - (void)init:(ISAdData *)adData delegate:(id<ISNetworkInitializationDelegate>)de
dispatch_async(dispatch_get_main_queue(), ^{
_plugin = [NeftaPlugin_iOS InitWithAppId: appId];

_listeners = [[NSMutableDictionary alloc] init];
_listeners = [NSMutableArray array];

_plugin.OnLoadFail = ^(Placement *placement, NSString *error) {
id<ISAdapterAdDelegate> listener = _listeners[placement._id];
[listener adDidFailToLoadWithErrorType:ISAdapterErrorTypeInternal errorCode:2 errorMessage:error];
[_listeners removeObjectForKey: placement._id];
for (int i = 0; i < _listeners.count; i++) {
MListener *ml = _listeners[i];
if ([ml.placementId isEqualToString: placement._id] && ml.state == 0) {
[ml.listener adDidFailToLoadWithErrorType:ISAdapterErrorTypeInternal errorCode:2 errorMessage:error];
[_listeners removeObject: ml];
return;
}
}
};

_plugin.OnLoad = ^(Placement *placement) {
id<ISAdapterAdDelegate> listener = _listeners[placement._id];
if (placement._type == TypesBanner) {
dispatch_async(dispatch_get_main_queue(), ^{
placement._isManualPosition = true;
[_plugin ShowMainWithId: placement._id];
UIView* v = [_plugin GetViewForPlacement: placement show: false];
v.frame = CGRectMake(0, 0, placement._width, placement._height);
[((id<ISBannerAdDelegate>)listener) adDidLoadWithView: v];
});
} else {
[listener adDidLoad];
for (int i = 0; i < _listeners.count; i++) {
MListener *ml = _listeners[i];
if ([ml.placementId isEqualToString: placement._id] && ml.state == 0) {
ml.state = 1;
if (placement._type == TypesBanner) {
placement._isManualPosition = true;
[_plugin ShowMainWithId: placement._id];
UIView* v = [_plugin GetViewForPlacement: placement show: false];
v.frame = CGRectMake(0, 0, placement._width, placement._height);
[((id<ISBannerAdDelegate>)ml.listener) adDidLoadWithView: v];
} else {
[ml.listener adDidLoad];
}
return;
}
}
};

_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];
for (int i = 0; i < _listeners.count; i++) {
MListener *ml = _listeners[i];
if ([ml.placementId isEqualToString: placement._id] && ml.state == 0) {
ml.state = 2;
if (placement._type == TypesBanner) {
id<ISBannerAdDelegate> bannerListener = (id<ISBannerAdDelegate>) ml.listener;
[bannerListener adDidOpen];
[bannerListener adWillPresentScreen];
} else {
id<ISAdapterAdInteractionDelegate> interactionListener = (id<ISAdapterAdInteractionDelegate>) ml.listener;
[interactionListener adDidOpen];
[interactionListener adDidShowSucceed];
[interactionListener adDidBecomeVisible];
}
return;
}
}
};

_plugin.OnClick = ^(Placement *placement) {
id<ISAdapterAdDelegate> listener = _listeners[placement._id];
[listener adDidClick];
for (int i = 0; i < _listeners.count; i++) {
MListener *ml = _listeners[i];
if ([ml.placementId isEqualToString: placement._id] && ml.state == 2) {
id<ISAdapterAdDelegate> listener = ml.listener;
[listener adDidClick];
return;
}
}
};

_plugin.OnReward = ^(Placement *placement) {
id<ISRewardedVideoAdDelegate> listener = (id<ISRewardedVideoAdDelegate>) _listeners[placement._id];
if (listener != nil) {
[listener adRewarded];
for (int i = 0; i < _listeners.count; i++) {
MListener *ml = _listeners[i];
if ([ml.placementId isEqualToString: placement._id] && ml.state == 2) {
MListener *ml = _listeners[i];
id<ISRewardedVideoAdDelegate> listener = (id<ISRewardedVideoAdDelegate>) ml.listener;
[listener adRewarded];
return;
}
}
};

_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];
for (int i = 0; i < _listeners.count; i++) {
MListener *ml = _listeners[i];
if ([ml.placementId isEqualToString: placement._id] && ml.state == 2) {
if (placement._type == TypesBanner) {
[((id<ISBannerAdDelegate>)ml.listener) adDidDismissScreen];
} else {
id<ISAdapterAdInteractionDelegate> interactionListener = (id<ISAdapterAdInteractionDelegate>) ml.listener;
[interactionListener adDidEnd];
[interactionListener adDidClose];
}
[_listeners removeObject: ml];
return;
}
}
[_listeners removeObjectForKey: placement._id];
};

[_plugin EnableAds: true];
Expand All @@ -114,7 +164,7 @@ - (NSString *) networkSDKVersion {
}

- (NSString *) adapterVersion {
return @"1.2.6";
return @"1.2.7";
}

+ (void)ApplyRenderer:(UIViewController *)viewController {
Expand All @@ -123,7 +173,9 @@ + (void)ApplyRenderer:(UIViewController *)viewController {

- (void)Load:(NSString *)pId delgate:(id<ISAdapterAdDelegate>)delegate {
dispatch_semaphore_wait(_semaphore, DISPATCH_TIME_FOREVER);
_listeners[pId] = delegate;

MListener *listener = [[MListener alloc] initWithId: pId listener: delegate];
[_listeners addObject: listener];
[_plugin LoadWithId: pId];
dispatch_semaphore_signal(_semaphore);
}
Expand Down
16 changes: 8 additions & 8 deletions Assets/Nefta/Plugins/iOS/NeftaSDK.xcframework/Info.plist
Expand Up @@ -7,41 +7,41 @@
<dict>
<key>BinaryPath</key>
<string>NeftaSDK.framework/NeftaSDK</string>
<key>DebugSymbolsPath</key>
<string>dSYMs</string>
<key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-simulator</string>
<string>ios-arm64</string>
<key>LibraryPath</key>
<string>NeftaSDK.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
<dict>
<key>BinaryPath</key>
<string>NeftaSDK.framework/NeftaSDK</string>
<key>DebugSymbolsPath</key>
<string>dSYMs</string>
<key>LibraryIdentifier</key>
<string>ios-arm64</string>
<string>ios-arm64_x86_64-simulator</string>
<key>LibraryPath</key>
<string>NeftaSDK.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
</array>
<key>CFBundlePackageType</key>
<string>XFWK</string>
<key>Version</key>
<string>3.2.6</string>
<string>3.2.7</string>
<key>XCFrameworkFormatVersion</key>
<string>1.0</string>
</dict>
Expand Down
Expand Up @@ -413,8 +413,10 @@ typedef SWIFT_ENUM(NSInteger, SpendMethod, open) {
};

typedef SWIFT_ENUM(NSInteger, SessionCategory, open) {
SessionCategoryAccountConnected = 0,
SessionCategoryAccountUpgraded = 1,
SessionCategorySessionStart = 0,
SessionCategoryAccountConnected = 1,
SessionCategoryAccountUpgraded = 2,
SessionCategoryHeartbeat = 3,
};

@class Placement;
Expand Down Expand Up @@ -506,7 +508,6 @@ SWIFT_CLASS("_TtC8NeftaSDK9Placement")
@property (nonatomic) NSUInteger _bidTime;
@property (nonatomic) NSUInteger _loadTime;
@property (nonatomic) NSUInteger _showTime;
@property (nonatomic) NSUInteger _timeSinceFailedLoad;
@property (nonatomic) BOOL _isHidden;
@property (nonatomic) BOOL _isManualPosition;
- (BOOL)IsBidding SWIFT_WARN_UNUSED_RESULT;
Expand Down

0 comments on commit 0743cde

Please sign in to comment.