22#import " UADSWebViewCallback.h"
33#import " UADSClientProperties.h"
44#import " UADSAdUnitError.h"
5+ #import " UADSWebViewApp.h"
56
67@implementation UADSApiAdUnit
78
@@ -135,4 +136,78 @@ + (void)WebViewExposed_getShouldAutorotate:(UADSWebViewCallback *)callback {
135136 }
136137}
137138
138- @end
139+ + (void )WebViewExposed_setTransform : (NSNumber *)transform callback : (UADSWebViewCallback *)callback {
140+ if ([UADSApiAdUnit getAdUnit ]) {
141+ dispatch_async (dispatch_get_main_queue (), ^(void ) {
142+ [[UADSApiAdUnit getAdUnit ] setTransform: [transform floatValue ]];
143+ [callback invoke: transform, nil ];
144+ });
145+ }
146+ else {
147+ [callback error: NSStringFromAdUnitError(kUnityAdsViewControllerNull ) arg1: nil ];
148+ }
149+ }
150+
151+ + (void )WebViewExposed_setViewFrame : (NSString *)view x : (NSNumber *)x y : (NSNumber *)y width : (NSNumber *)width height : (NSNumber *)height callback : (UADSWebViewCallback *)callback {
152+ if ([UADSApiAdUnit getAdUnit ]) {
153+ dispatch_async (dispatch_get_main_queue (), ^{
154+ [[UADSApiAdUnit getAdUnit ] setViewFrame: view x: [x intValue ] y: [y intValue ] width: [width intValue ] height: [height intValue ]];
155+ });
156+ [callback invoke: nil ];
157+ }
158+ else {
159+ [callback error: NSStringFromAdUnitError(kUnityAdsViewControllerNull ) arg1: nil ];
160+ }
161+ }
162+
163+ + (void )WebViewExposed_getTransform : (UADSWebViewCallback *)callback {
164+ if ([UADSApiAdUnit getAdUnit ]) {
165+ if ([[UADSApiAdUnit getAdUnit ].view valueForKeyPath: @" layer.transform.rotation.z" ]) {
166+ [callback invoke: [(NSNumber *)[UADSApiAdUnit getAdUnit ].view valueForKeyPath: @" layer.transform.rotation.z" ], nil ];
167+ }
168+ else {
169+ [callback error: NSStringFromAdUnitError(kUnityAdsViewControllerNoRotationZ ) arg1: nil ];
170+ }
171+ }
172+ else {
173+ [callback error: NSStringFromAdUnitError(kUnityAdsViewControllerNull ) arg1: nil ];
174+ }
175+ }
176+
177+ + (void )WebViewExposed_getViewFrame : (NSString *)view callback : (UADSWebViewCallback *)callback {
178+ if ([UADSApiAdUnit getAdUnit ]) {
179+ UIView *targetView = NULL ;
180+
181+ if ([view isEqualToString: @" adunit" ]) {
182+ targetView = [UADSApiAdUnit getAdUnit ].view ;
183+ }
184+ else if ([view isEqualToString: @" videoplayer" ]) {
185+ targetView = [UADSApiAdUnit getAdUnit ].videoView ;
186+ }
187+ else if ([view isEqualToString: @" webview" ]) {
188+ targetView = [[UADSWebViewApp getCurrentApp ] webView ];
189+ }
190+ else {
191+ [callback error: NSStringFromAdUnitError(kUnityAdsViewControllerUnknownView ) arg1: nil ];
192+ return ;
193+ }
194+
195+ if (targetView) {
196+ CGRect targetFrame = targetView.frame ;
197+ [callback invoke: [NSNumber numberWithFloat: targetFrame.origin.x],
198+ [NSNumber numberWithFloat: targetFrame.origin.y],
199+ [NSNumber numberWithFloat: targetFrame.size.width],
200+ [NSNumber numberWithFloat: targetFrame.size.height],
201+ nil ];
202+ }
203+ else {
204+ [callback error: NSStringFromAdUnitError(kUnityAdsViewControllerTargetViewNull ) arg1: nil ];
205+ return ;
206+ }
207+ }
208+ else {
209+ [callback error: NSStringFromAdUnitError(kUnityAdsViewControllerNull ) arg1: nil ];
210+ }
211+ }
212+
213+ @end
0 commit comments