com.azerion.bluestack 3.0.0-preview2 → 3.0.0-preview3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Editor/BlueStackDependencies.xml +2 -2
- package/Example/Scripts/NativeAdManager.cs +2 -2
- package/Plugins/Android/bluestack-unity-android-bridge-2.0.0-preview1.aar +0 -0
- package/Plugins/iOS/BSUInterface.h +12 -4
- package/Plugins/iOS/BSUInterface.m +27 -5
- package/Plugins/iOS/BSUNativeAd.h +7 -1
- package/Plugins/iOS/BSUNativeAd.m +43 -3
- package/Plugins/iOS/BSUTypes.h +6 -0
- package/Runtime/API/Banner/BannerAd.cs +2 -1
- package/Runtime/API/InterstitialAd.cs +2 -1
- package/Runtime/API/NativeAd/NativeAd.cs +24 -8
- package/Runtime/API/NativeAd/NativeAdInteractionHandler.cs +38 -18
- package/Runtime/API/NativeAd/NativeAdInteractionUtils.cs +2 -4
- package/Runtime/API/NativeAd/NativeAdObject.cs +82 -46
- package/Runtime/API/Rewarded/RewardedVideoAd.cs +2 -1
- package/Runtime/Internal/NativeAd/INativeAdClient.cs +7 -1
- package/Runtime/Platforms/Android/BlueStackClient.cs +1 -2
- package/Runtime/Platforms/Android/NativeAdClient.cs +33 -6
- package/Runtime/Platforms/Unity/NativeAdClient.cs +27 -1
- package/Runtime/Platforms/iOS/Externs.cs +11 -2
- package/Runtime/Platforms/iOS/NativeAdClient.cs +53 -4
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<dependencies>
|
|
2
2
|
<androidPackages>
|
|
3
|
-
<androidPackage spec="com.azerion:bluestack-sdk-core:4.2.
|
|
3
|
+
<androidPackage spec="com.azerion:bluestack-sdk-core:4.2.10" />
|
|
4
4
|
</androidPackages>
|
|
5
5
|
<iosPods>
|
|
6
|
-
<iosPod name="BlueStack-SDK" version="4.
|
|
6
|
+
<iosPod name="BlueStack-SDK" version="4.3.0-preview.1" bitcodeEnabled="false"
|
|
7
7
|
addToAllTargets="false"/>
|
|
8
8
|
</iosPods>
|
|
9
9
|
</dependencies>
|
|
@@ -32,7 +32,7 @@ namespace Azerion.BlueStack.Example
|
|
|
32
32
|
get
|
|
33
33
|
{
|
|
34
34
|
#if UNITY_IOS
|
|
35
|
-
return "/" + AppId + "/
|
|
35
|
+
return "/" + AppId + "/nativeadmng";
|
|
36
36
|
#elif UNITY_ANDROID
|
|
37
37
|
return "/" + AppId + "/nativead";
|
|
38
38
|
#endif
|
|
@@ -161,7 +161,7 @@ namespace Azerion.BlueStack.Example
|
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
|
|
164
|
+
public void RequestNativeAd()
|
|
165
165
|
{
|
|
166
166
|
Debug.Log("NativeAdManager: Requesting Ad!");
|
|
167
167
|
NativeAdLoader nativeAdLoader = new NativeAdLoader(NativeAdUnitId);
|
|
Binary file
|
|
@@ -101,14 +101,22 @@ void BSUDestroyBannerAd(BSUTypeBannerRef banner);
|
|
|
101
101
|
|
|
102
102
|
// Native Ad
|
|
103
103
|
void BSUSetNativeAdCallbacks(BSUTypeNativeAdRef nativeAd,
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
104
|
+
BSUOnNativeAdDidLoadCallback
|
|
105
|
+
onDidLoadCallback,
|
|
106
|
+
BSUOnNativeAdDidFailCallback
|
|
107
|
+
onDidFailCallback,
|
|
108
|
+
BSUOnNativeAdDidRecordImpressionCallback
|
|
109
|
+
onRecordImpressionCallback,
|
|
110
|
+
BSUOnNativeAdDidPerformClickCallback
|
|
111
|
+
onPerformClickCallback,
|
|
112
|
+
BSUOnNativeAdCloseCallback
|
|
113
|
+
onCloseCallback);
|
|
108
114
|
BSUTypeNativeAdRef BSUCreateNativeAd(BSUTypeNativeAdClientRef *nativeAdClient, const char *placementId);
|
|
109
115
|
void BSULoadNativeAd(BSUTypeNativeAdRef nativeAd);
|
|
110
116
|
void BSULoadNativeAdWithPreference(BSUTypeNativeAdRef nativeAd, BSUTypePreferenceRef preferenceRef);
|
|
111
117
|
const char *BSUNativeAdGetTitle(BSUTypeNativeAdRef nativeAd);
|
|
112
118
|
const char *BSUNativeAdGetBodyText(BSUTypeNativeAdRef nativeAd);
|
|
113
119
|
const char *BSUNativeAdGetCTAText(BSUTypeNativeAdRef nativeAd);
|
|
120
|
+
void BSURecordImpression(BSUTypeNativeAdRef nativeAd);
|
|
121
|
+
void BSUPerformClick(BSUTypeNativeAdRef nativeAd);
|
|
114
122
|
void BSUDestroyNativeAd(BSUTypeNativeAdRef nativeAd);
|
|
@@ -58,7 +58,7 @@ void BSUInitializeWithCallback(BSUTypeMobileAdsClientRef *mobileAdsClientRef, co
|
|
|
58
58
|
NSString *appIdString = BSUStringFromUTF8String(appId);
|
|
59
59
|
BSUSettings *settings = (__bridge BSUSettings *)settingsRef;
|
|
60
60
|
NSLog(@"BSUInitializeWithCallback called for %@",appIdString);
|
|
61
|
-
[[BSUInitializer sharedInstance] prepareBlueStackSDKWithAppId:appIdString withSettings:settings
|
|
61
|
+
[[BSUInitializer sharedInstance] prepareBlueStackSDKWithAppId:appIdString withSettings:settings
|
|
62
62
|
withSDKCompletionHandler:^(BOOL success, NSError *error) {
|
|
63
63
|
NSLog(@"BSUInitializeWithCallback withCompletionHandler");
|
|
64
64
|
sdkInitCallback(mobileAdsClientRef, success, (__bridge BSUTypeErrorRef)error);
|
|
@@ -370,16 +370,26 @@ void BSUDestroyBannerAd(BSUTypeBannerRef banner) {
|
|
|
370
370
|
#pragma mark Native Ad
|
|
371
371
|
|
|
372
372
|
void BSUSetNativeAdCallbacks(BSUTypeNativeAdRef nativeAd,
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
373
|
+
BSUOnNativeAdDidLoadCallback
|
|
374
|
+
onDidLoadCallback,
|
|
375
|
+
BSUOnNativeAdDidFailCallback
|
|
376
|
+
onDidFailCallback,
|
|
377
|
+
BSUOnNativeAdDidRecordImpressionCallback
|
|
378
|
+
onRecordImpressionCallback,
|
|
379
|
+
BSUOnNativeAdDidPerformClickCallback
|
|
380
|
+
onPerformClickCallback,
|
|
381
|
+
BSUOnNativeAdCloseCallback
|
|
382
|
+
onCloseCallback) {
|
|
377
383
|
BSUNativeAd *internalNativeAd = (__bridge BSUNativeAd *)nativeAd;
|
|
378
384
|
internalNativeAd.onDidLoadCallback = onDidLoadCallback;
|
|
379
385
|
internalNativeAd.onDidFailCallback = onDidFailCallback;
|
|
386
|
+
internalNativeAd.onRecordImpressionCallback = onRecordImpressionCallback;
|
|
387
|
+
internalNativeAd.onPerformClickCallback = onPerformClickCallback;
|
|
388
|
+
internalNativeAd.onCloseCallback = onCloseCallback;
|
|
380
389
|
}
|
|
381
390
|
|
|
382
391
|
BSUTypeNativeAdRef BSUCreateNativeAd(BSUTypeNativeAdClientRef *nativeAdClient, const char *placementId) {
|
|
392
|
+
[[NSUserDefaults standardUserDefaults] setBool: YES forKey:@"IsCrossPlatformNativeAd"];
|
|
383
393
|
NSString *placementIdStr = BSUStringFromUTF8String(placementId);
|
|
384
394
|
BSUNativeAd *internalNativeAd = [[BSUNativeAd alloc] initWithNativeAdClientReference:nativeAdClient placementId:placementIdStr];
|
|
385
395
|
BSUObjectCache *cache = [BSUObjectCache sharedInstance];
|
|
@@ -439,6 +449,18 @@ const char *BSUNativeAdGetClickUrl(BSUTypeNativeAdRef nativeAd) {
|
|
|
439
449
|
return cStringCopy(internalNativeAd.clickUrl.UTF8String);
|
|
440
450
|
}
|
|
441
451
|
|
|
452
|
+
void BSURecordImpression(BSUTypeNativeAdRef nativeAd) {
|
|
453
|
+
BSUNativeAd *internalNativeAd = (__bridge BSUNativeAd *)nativeAd;
|
|
454
|
+
NSDictionary *emptyDictionary = [NSDictionary dictionary]; // for later implementation
|
|
455
|
+
[internalNativeAd recordImpression:emptyDictionary];
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
void BSUPerformClick(BSUTypeNativeAdRef nativeAd) {
|
|
459
|
+
BSUNativeAd *internalNativeAd = (__bridge BSUNativeAd *)nativeAd;
|
|
460
|
+
NSDictionary *emptyDictionary = [NSDictionary dictionary]; // for later implementation
|
|
461
|
+
[internalNativeAd performClick:emptyDictionary];
|
|
462
|
+
}
|
|
463
|
+
|
|
442
464
|
void BSUDestroyNativeAd(BSUTypeNativeAdRef nativeAd) {
|
|
443
465
|
BSUNativeAd *internalNativeAd = (__bridge BSUNativeAd *)nativeAd;
|
|
444
466
|
[internalNativeAd destroy];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#import <Foundation/Foundation.h>
|
|
2
2
|
#import <CoreGraphics/CoreGraphics.h>
|
|
3
3
|
#import "BSUTypes.h"
|
|
4
|
+
#import "BlueStackSDK/MNGNAtiveObject.h"
|
|
4
5
|
|
|
5
6
|
@interface BSUNativeAd : NSObject
|
|
6
7
|
|
|
@@ -10,10 +11,13 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
10
11
|
placementId:(NSString *_Nullable)placementId;
|
|
11
12
|
|
|
12
13
|
@property(nonatomic, assign) BSUTypeNativeAdClientRef * _Nonnull nativeAdClient;
|
|
14
|
+
@property(nonatomic, assign) MNGNAtiveObject *nativeAdsObject;
|
|
13
15
|
|
|
14
16
|
@property(nonatomic, assign) BSUOnNativeAdDidLoadCallback onDidLoadCallback;
|
|
15
|
-
|
|
16
17
|
@property(nonatomic, assign) BSUOnNativeAdDidFailCallback onDidFailCallback;
|
|
18
|
+
@property(nonatomic, assign) BSUOnNativeAdDidRecordImpressionCallback onRecordImpressionCallback;
|
|
19
|
+
@property(nonatomic, assign) BSUOnNativeAdDidPerformClickCallback onPerformClickCallback;
|
|
20
|
+
@property(nonatomic, assign) BSUOnNativeAdCloseCallback onCloseCallback;
|
|
17
21
|
|
|
18
22
|
@property (nonatomic, retain) NSString *title;
|
|
19
23
|
@property (nonatomic, retain) NSString *body;
|
|
@@ -27,6 +31,8 @@ NS_ASSUME_NONNULL_END
|
|
|
27
31
|
|
|
28
32
|
- (void)loadAd;
|
|
29
33
|
- (void)loadAdWithPreference:(BSUTypePreferenceRef)preferenceRef;
|
|
34
|
+
- (void)recordImpression:(nonnull NSDictionary *)args;
|
|
35
|
+
- (void)performClick:(nonnull NSDictionary *)args;
|
|
30
36
|
- (void)destroy;
|
|
31
37
|
|
|
32
38
|
@end
|
|
@@ -38,10 +38,34 @@
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
- (void)recordImpression:(nonnull NSDictionary *)args {
|
|
42
|
+
if (self.nativeAdsObject) {
|
|
43
|
+
// [self.nativeAdsObject recordImpression:args];
|
|
44
|
+
|
|
45
|
+
if (self.onRecordImpressionCallback) {
|
|
46
|
+
self.onRecordImpressionCallback(self.nativeAdClient); // TODO : Should be verified and triggered from core sdk
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
- (void)performClick:(nonnull NSDictionary *)args {
|
|
52
|
+
if (self.nativeAdsObject) {
|
|
53
|
+
// [self.nativeAdsObject performClick:args];
|
|
54
|
+
|
|
55
|
+
if (self.onPerformClickCallback) {
|
|
56
|
+
self.onPerformClickCallback(self.nativeAdClient); // TODO : Should be verified and triggered from core sdk
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
41
61
|
- (void)destroy {
|
|
42
62
|
if (self.nativeAdsFactory) {
|
|
43
63
|
[self.nativeAdsFactory releaseMemory];
|
|
44
64
|
self.nativeAdsFactory = nil;
|
|
65
|
+
|
|
66
|
+
if (self.onCloseCallback) {
|
|
67
|
+
self.onCloseCallback(self.nativeAdClient);
|
|
68
|
+
}
|
|
45
69
|
}
|
|
46
70
|
}
|
|
47
71
|
|
|
@@ -56,18 +80,19 @@
|
|
|
56
80
|
-(void)adsAdapter:(MNGAdsAdapter *)adsAdapter nativeObjectDidLoad:(MNGNAtiveObject *)nativeObject{
|
|
57
81
|
NSLog(@"adsAdapterNativeObjectDidLoad:");
|
|
58
82
|
if (self.onDidLoadCallback != nil) {
|
|
83
|
+
self.nativeAdsObject = nativeObject;
|
|
59
84
|
self.title = nativeObject.title;
|
|
60
85
|
self.body = nativeObject.body;
|
|
61
86
|
self.badge = @"Ad"; //nativeObject.badge;
|
|
62
87
|
self.callToAction = nativeObject.callToAction;
|
|
63
88
|
self.clickUrl = @"https://developers.bluestack.app/"; //nativeObject.clickUrl;
|
|
64
|
-
self.iconUrl = @"https://creative.mng-ads.com/10/10394-15539.jpg"; //nativeObject.iconUrl;
|
|
65
|
-
self.coverImageUrl = @"https://creative.mng-ads.com/10/10394-15540.jpg"; //nativeObject.coverImageUrl;
|
|
89
|
+
self.iconUrl = @"https://creative.mng-ads.com/10/10394-15539.jpg"; //nativeObject.iconUrl; //
|
|
90
|
+
self.coverImageUrl = @"https://creative.mng-ads.com/10/10394-15540.jpg"; //nativeObject.coverImageUrl; //
|
|
66
91
|
|
|
67
92
|
self.onDidLoadCallback(self.nativeAdClient);
|
|
68
93
|
}
|
|
69
94
|
|
|
70
|
-
//
|
|
95
|
+
// possibility to customize the badge title
|
|
71
96
|
// [nativeObject updateBadgeTitle:@"Publicité"];
|
|
72
97
|
// badgeView = nativeObject.badgeView;
|
|
73
98
|
// [_nativeObject registerViewForInteraction:self.nativeView withMediaView:self.backgroundImage withIconImageView:self.iconeImage withViewController:[APP_DELEGATE drawerViewController] withClickableView:self.callToActionButton];
|
|
@@ -79,4 +104,19 @@
|
|
|
79
104
|
}
|
|
80
105
|
}
|
|
81
106
|
|
|
107
|
+
#pragma mark MNGClickDelegate
|
|
108
|
+
|
|
109
|
+
-(void)adsAdapterNativeAdWasClicked:(MNGAdsAdapter *)adsAdapter nativeObjectClicked:(MNGNAtiveObject *)clickedAdView{
|
|
110
|
+
NSLog(@"BSUNativeAd: MNGClickDelegate: nativeObjectClicked!");
|
|
111
|
+
if (self.onPerformClickCallback) {
|
|
112
|
+
self.onPerformClickCallback(self.nativeAdClient);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
//- (void)adsAdapterAdWasClicked:(MNGAdsAdapter *)adsAdapter {
|
|
117
|
+
// if (self.onAdClickedCallback) {
|
|
118
|
+
// self.onAdClickedCallback(self.bannerClient);
|
|
119
|
+
// }
|
|
120
|
+
//}
|
|
121
|
+
|
|
82
122
|
@end
|
package/Plugins/iOS/BSUTypes.h
CHANGED
|
@@ -97,3 +97,9 @@ typedef void (*BSUOnNativeAdDidLoadCallback)(BSUTypeNativeAdClientRef *nativeAdC
|
|
|
97
97
|
|
|
98
98
|
typedef void (*BSUOnNativeAdDidFailCallback)(
|
|
99
99
|
BSUTypeNativeAdClientRef *nativeAdClient, BSUTypeErrorRef error);
|
|
100
|
+
|
|
101
|
+
typedef void (*BSUOnNativeAdDidRecordImpressionCallback)(BSUTypeNativeAdClientRef *nativeAdClient);
|
|
102
|
+
|
|
103
|
+
typedef void (*BSUOnNativeAdDidPerformClickCallback)(BSUTypeNativeAdClientRef *nativeAdClient);
|
|
104
|
+
|
|
105
|
+
typedef void (*BSUOnNativeAdCloseCallback)(BSUTypeNativeAdClientRef *nativeAdClient);
|
|
@@ -58,7 +58,8 @@ namespace Azerion.BlueStack.API.Banner
|
|
|
58
58
|
|
|
59
59
|
public void Load(AdSize adSize)
|
|
60
60
|
{
|
|
61
|
-
|
|
61
|
+
Preference preference = new Preference();
|
|
62
|
+
_bannerAdClient.Load(adSize, preference.getIPreferenceClient());
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
public void Load(AdSize adSize, Preference preference)
|
|
@@ -14,12 +14,13 @@ namespace Azerion.BlueStack.API
|
|
|
14
14
|
private Texture2D _imageTexture;
|
|
15
15
|
private bool _isTextureLoaded;
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
internal event EventHandler<EventArgs> OnNativeAdDidLoad;
|
|
18
|
+
internal event EventHandler<BlueStackError> OnNativeAdDidFail;
|
|
19
|
+
internal event EventHandler<EventArgs> OnNativeAdOpening;
|
|
20
|
+
internal event EventHandler<EventArgs> OnNativeAdClosed;
|
|
21
|
+
|
|
19
22
|
public event EventHandler<EventArgs> OnNativeAdImpression;
|
|
20
23
|
public event EventHandler<EventArgs> OnNativeAdClicked;
|
|
21
|
-
public event EventHandler<EventArgs> OnNativeAdOpening;
|
|
22
|
-
public event EventHandler<EventArgs> OnNativeAdClosed;
|
|
23
24
|
|
|
24
25
|
private NativeAdInteractionHandler _nativeAdInteractionHandler;
|
|
25
26
|
|
|
@@ -35,7 +36,7 @@ namespace Azerion.BlueStack.API
|
|
|
35
36
|
_nativeAdClient.Create(placementId);
|
|
36
37
|
ConfigureEvents();
|
|
37
38
|
InitializeTextures();
|
|
38
|
-
_nativeAdInteractionHandler = new NativeAdInteractionHandler();
|
|
39
|
+
_nativeAdInteractionHandler = new NativeAdInteractionHandler(_nativeAdClient);
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
private void ConfigureEvents()
|
|
@@ -48,14 +49,19 @@ namespace Azerion.BlueStack.API
|
|
|
48
49
|
SetClickUrl();
|
|
49
50
|
};
|
|
50
51
|
_nativeAdClient.OnNativeAdDidFail += (sender, args) => { OnNativeAdDidFail?.Invoke(this, args); };
|
|
52
|
+
_nativeAdClient.OnNativeAdImpression += (sender, args) => { OnNativeAdImpression?.Invoke(this, args); };
|
|
53
|
+
_nativeAdClient.OnNativeAdClicked += (sender, args) => { OnNativeAdClicked?.Invoke(this, args); };
|
|
54
|
+
_nativeAdClient.OnNativeAdClosed += (sender, args) => { OnNativeAdClosed?.Invoke(this, args); };
|
|
55
|
+
|
|
51
56
|
}
|
|
52
57
|
|
|
53
|
-
|
|
58
|
+
internal void Load()
|
|
54
59
|
{
|
|
55
|
-
|
|
60
|
+
Preference preference = new Preference();
|
|
61
|
+
_nativeAdClient.Load(preference.getIPreferenceClient());
|
|
56
62
|
}
|
|
57
63
|
|
|
58
|
-
|
|
64
|
+
internal void Load(Preference preference)
|
|
59
65
|
{
|
|
60
66
|
_nativeAdClient.Load(preference.getIPreferenceClient());
|
|
61
67
|
}
|
|
@@ -130,6 +136,16 @@ namespace Azerion.BlueStack.API
|
|
|
130
136
|
return this._imageTexture;
|
|
131
137
|
}
|
|
132
138
|
|
|
139
|
+
// public void RecordImpression()
|
|
140
|
+
// {
|
|
141
|
+
// _nativeAdClient.RecordImpression();
|
|
142
|
+
// }
|
|
143
|
+
//
|
|
144
|
+
// public void PerformClick()
|
|
145
|
+
// {
|
|
146
|
+
// _nativeAdClient.PerformClick();
|
|
147
|
+
// }
|
|
148
|
+
|
|
133
149
|
private void SetClickUrl()
|
|
134
150
|
{
|
|
135
151
|
_nativeAdInteractionHandler.SetClickUrl(_nativeAdClient.GetClickUrl());
|
|
@@ -2,24 +2,25 @@ using System;
|
|
|
2
2
|
using System.Collections.Generic;
|
|
3
3
|
using Azerion.BlueStack.Common;
|
|
4
4
|
using Azerion.BlueStack.Internal;
|
|
5
|
-
using Castle.Components.DictionaryAdapter.Xml;
|
|
6
5
|
using UnityEngine;
|
|
7
6
|
|
|
8
7
|
namespace Azerion.BlueStack.API
|
|
9
8
|
{
|
|
10
9
|
public class NativeAdInteractionHandler
|
|
11
10
|
{
|
|
11
|
+
private INativeAdClient _nativeAdClient;
|
|
12
12
|
private List<NativeAdObject> _nativeAdObjects;
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
private INativeAdInteractionHandlerClient _nativeAdInteractionHandlerClient;
|
|
15
15
|
|
|
16
16
|
// public NativeAdInteractionHandler(INativeAdInteractionHandlerClient interactionHandlerClient)
|
|
17
17
|
|
|
18
18
|
private string _clickUrl;
|
|
19
|
-
public NativeAdInteractionHandler()
|
|
19
|
+
public NativeAdInteractionHandler(INativeAdClient nativeAdClient)
|
|
20
20
|
{
|
|
21
21
|
// _nativeAdInteractionHandlerClient = interactionHandlerClient;
|
|
22
22
|
_nativeAdObjects = new List<NativeAdObject>();
|
|
23
|
+
_nativeAdClient = nativeAdClient;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
public bool RegisterImageGameObjects(GameObject gameObject)
|
|
@@ -112,17 +113,28 @@ namespace Azerion.BlueStack.API
|
|
|
112
113
|
{
|
|
113
114
|
impressionComplete = true;
|
|
114
115
|
Debug.LogWarning("Impression Complete");
|
|
115
|
-
|
|
116
|
+
|
|
116
117
|
if (sender is NativeAdObject nativeAdObject)
|
|
117
118
|
{
|
|
118
|
-
|
|
119
|
+
_nativeAdClient.RecordImpression();
|
|
120
|
+
_nativeAdClient.OnNativeAdImpression += (sender, args) =>
|
|
119
121
|
{
|
|
122
|
+
Debug.LogWarning("InteractionHandlerClient: OnNativeAdImpression!");
|
|
120
123
|
foreach (NativeAdObject adObject in _nativeAdObjects)
|
|
121
124
|
{
|
|
122
125
|
if(adObject != null)
|
|
123
126
|
adObject.StopImpressionCheck();
|
|
124
127
|
}
|
|
125
|
-
}
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
// if (_nativeAdInteractionHandlerClient.RecordImpression(NativeAdInteractionUtils.CreateImpressionSignal(nativeAdObject, _nativeAdObjects)))
|
|
131
|
+
// {
|
|
132
|
+
// foreach (NativeAdObject adObject in _nativeAdObjects)
|
|
133
|
+
// {
|
|
134
|
+
// if(adObject != null)
|
|
135
|
+
// adObject.StopImpressionCheck();
|
|
136
|
+
// }
|
|
137
|
+
// }
|
|
126
138
|
}
|
|
127
139
|
}
|
|
128
140
|
|
|
@@ -130,20 +142,28 @@ namespace Azerion.BlueStack.API
|
|
|
130
142
|
private void RecordClick(object sender, ClickEventArgs clickEventArgs)
|
|
131
143
|
{
|
|
132
144
|
// clickComplete = true;
|
|
133
|
-
Debug.Log("Record Click");
|
|
134
|
-
|
|
145
|
+
Debug.Log("Record Click!");
|
|
146
|
+
// Debug.Log("Record Click: " + NativeAdInteractionUtils.BuildVersionString(NativeUtils.Version));
|
|
147
|
+
|
|
135
148
|
if (sender is NativeAdObject nativeAdObject)
|
|
136
149
|
{
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
//
|
|
145
|
-
|
|
146
|
-
|
|
150
|
+
_nativeAdClient.OnNativeAdClicked += (sender, args) =>
|
|
151
|
+
{
|
|
152
|
+
OpenURL();
|
|
153
|
+
Debug.LogWarning("InteractionHandlerClient: OnNativeAdClicked!");
|
|
154
|
+
};
|
|
155
|
+
_nativeAdClient.PerformClick();
|
|
156
|
+
|
|
157
|
+
// Dictionary<string, string> touchEventSignal =
|
|
158
|
+
// NativeAdInteractionUtils.CreateTouchEventSignal(clickEventArgs.startClick, clickEventArgs.endClick);
|
|
159
|
+
// Dictionary<string, object> clickSignal =
|
|
160
|
+
// NativeAdInteractionUtils.CreateClickSignal(nativeAdObject, _nativeAdObjects, clickEventArgs.startClick, clickEventArgs.endClick);
|
|
161
|
+
//
|
|
162
|
+
// // _nativeAdInteractionHandlerClient.ReportTouchEvent(touchEventSignal);
|
|
163
|
+
// Debug.LogWarning("InteractionHandlerClient: ReportTouchEvent!");
|
|
164
|
+
// // _nativeAdInteractionHandlerClient.PerformClick(clickSignal);
|
|
165
|
+
// Debug.LogWarning("InteractionHandlerClient: PerformClick!");
|
|
166
|
+
// OpenURL();
|
|
147
167
|
}
|
|
148
168
|
}
|
|
149
169
|
|
|
@@ -3,8 +3,6 @@ using System.Collections.Generic;
|
|
|
3
3
|
using System.Globalization;
|
|
4
4
|
using System.Text;
|
|
5
5
|
using Azerion.BlueStack.Common;
|
|
6
|
-
using Azerion.BlueStack.Internal;
|
|
7
|
-
using Castle.Components.DictionaryAdapter.Xml;
|
|
8
6
|
using UnityEngine;
|
|
9
7
|
|
|
10
8
|
// incomplete
|
|
@@ -74,7 +72,7 @@ namespace Azerion.BlueStack.API
|
|
|
74
72
|
return hash.ToString();
|
|
75
73
|
}
|
|
76
74
|
|
|
77
|
-
private static string GetHashedString(string text, string
|
|
75
|
+
private static string GetHashedString(string text, string key = "")
|
|
78
76
|
{
|
|
79
77
|
if (String.IsNullOrEmpty(text))
|
|
80
78
|
{
|
|
@@ -85,7 +83,7 @@ namespace Azerion.BlueStack.API
|
|
|
85
83
|
using (var sha = new System.Security.Cryptography.SHA256Managed())
|
|
86
84
|
{
|
|
87
85
|
// Convert the string to a byte array first, to be processed
|
|
88
|
-
byte[] textBytes = System.Text.Encoding.UTF8.GetBytes(text +
|
|
86
|
+
byte[] textBytes = System.Text.Encoding.UTF8.GetBytes(text + key);
|
|
89
87
|
byte[] hashBytes = sha.ComputeHash(textBytes);
|
|
90
88
|
|
|
91
89
|
// Convert back to a string, removing the '-' that BitConverter adds
|
|
@@ -4,6 +4,7 @@ using System.Collections.Generic;
|
|
|
4
4
|
using System.Threading;
|
|
5
5
|
using UnityEngine;
|
|
6
6
|
using UnityEngine.EventSystems;
|
|
7
|
+
using UnityEngine.Serialization;
|
|
7
8
|
using UnityEngine.UI;
|
|
8
9
|
|
|
9
10
|
namespace Azerion.BlueStack.API
|
|
@@ -41,12 +42,12 @@ namespace Azerion.BlueStack.API
|
|
|
41
42
|
private const int _iterations = 5;
|
|
42
43
|
private float _interactionTime;
|
|
43
44
|
private float _lastInteractionTime;
|
|
44
|
-
private bool
|
|
45
|
+
private bool _isImpressionChecked;
|
|
45
46
|
private ClickInfo _clickInfo;
|
|
46
47
|
private string _objectTag;
|
|
47
48
|
private bool _is2DColliderPresent;
|
|
48
|
-
private bool _isRectTransPresent;
|
|
49
49
|
private bool _isInteractionStarted;
|
|
50
|
+
private bool _isRectTransPresent; // check again
|
|
50
51
|
internal event EventHandler<EventArgs> OnAdDisplay;
|
|
51
52
|
internal event EventHandler<ClickEventArgs> OnAdClick;
|
|
52
53
|
internal float InteractionTime
|
|
@@ -68,7 +69,7 @@ namespace Azerion.BlueStack.API
|
|
|
68
69
|
public void Start()
|
|
69
70
|
{
|
|
70
71
|
this._lastInteractionTime = 0f;
|
|
71
|
-
this.
|
|
72
|
+
this._isImpressionChecked = false;
|
|
72
73
|
}
|
|
73
74
|
|
|
74
75
|
public void Initialize(string tag, bool isClickable = false)
|
|
@@ -76,32 +77,35 @@ namespace Azerion.BlueStack.API
|
|
|
76
77
|
_objectTag = tag;
|
|
77
78
|
string exMessage;
|
|
78
79
|
|
|
79
|
-
|
|
80
|
-
Renderer rendererComponent = GetComponent<Renderer>();
|
|
81
|
-
if (rendererComponent != null)
|
|
80
|
+
if (GetComponent<Collider>() == null)
|
|
82
81
|
{
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (GetComponent<Collider>() == null)
|
|
82
|
+
if (GetComponent<Collider2D>() == null)
|
|
86
83
|
{
|
|
87
|
-
|
|
88
|
-
{
|
|
89
|
-
throw new InvalidOperationException(" No Collider or Collider2D component found.");
|
|
90
|
-
}
|
|
91
|
-
else
|
|
92
|
-
{
|
|
93
|
-
_is2DColliderPresent = true;
|
|
94
|
-
Debug.Log("2D Collider Present!!!");
|
|
95
|
-
}
|
|
84
|
+
throw new InvalidOperationException(" No Collider or Collider2D component found.");
|
|
96
85
|
}
|
|
97
86
|
else
|
|
98
87
|
{
|
|
99
|
-
|
|
88
|
+
_is2DColliderPresent = true;
|
|
89
|
+
Debug.Log("2D Collider Present!!!");
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else
|
|
93
|
+
{
|
|
94
|
+
Debug.Log("Collider Present!!!");
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Check if the GameObject has a Renderer component.
|
|
98
|
+
Renderer rendererComponent = GetComponent<Renderer>();
|
|
99
|
+
if (rendererComponent != null)
|
|
100
|
+
{
|
|
101
|
+
if (!rendererComponent.isVisible)
|
|
102
|
+
{
|
|
103
|
+
throw new InvalidOperationException(" Object is not visible.");
|
|
100
104
|
}
|
|
101
105
|
}
|
|
102
106
|
else if (IsValidUIObject())
|
|
103
107
|
{
|
|
104
|
-
|
|
108
|
+
Debug.Log("IsValidUIObject");
|
|
105
109
|
_isRectTransPresent = true;
|
|
106
110
|
}
|
|
107
111
|
else
|
|
@@ -109,11 +113,6 @@ namespace Azerion.BlueStack.API
|
|
|
109
113
|
throw new InvalidOperationException(" Not a valid Ad Object.");
|
|
110
114
|
}
|
|
111
115
|
|
|
112
|
-
if (!_isVisible)
|
|
113
|
-
{
|
|
114
|
-
throw new InvalidOperationException(" Object is not visible.");
|
|
115
|
-
}
|
|
116
|
-
|
|
117
116
|
InvokeRepeating("CheckForImpression", 0f, this.TimeInterval());
|
|
118
117
|
}
|
|
119
118
|
|
|
@@ -378,7 +377,7 @@ namespace Azerion.BlueStack.API
|
|
|
378
377
|
|
|
379
378
|
public void OnBecameVisible()
|
|
380
379
|
{
|
|
381
|
-
if (!this.
|
|
380
|
+
if (!this._isImpressionChecked)
|
|
382
381
|
{
|
|
383
382
|
InvokeRepeating("CheckForImpression", 0f, this.TimeInterval());
|
|
384
383
|
}
|
|
@@ -389,7 +388,7 @@ namespace Azerion.BlueStack.API
|
|
|
389
388
|
public void StopImpressionCheck()
|
|
390
389
|
{
|
|
391
390
|
base.CancelInvoke();
|
|
392
|
-
this.
|
|
391
|
+
this._isImpressionChecked = true;
|
|
393
392
|
}
|
|
394
393
|
|
|
395
394
|
// Method to check if a UI element overlaps with the screen
|
|
@@ -407,6 +406,7 @@ namespace Azerion.BlueStack.API
|
|
|
407
406
|
// Create a rect for the UI element
|
|
408
407
|
Rect elementRect = new Rect(x, y, elementSize.x, elementSize.y);
|
|
409
408
|
// Check if the UI element rect overlaps with the screen rect
|
|
409
|
+
Debug.LogWarning("Does screenRect.Overlaps: " + screenRect.Overlaps(elementRect, false));
|
|
410
410
|
if (screenRect.Overlaps(elementRect, false))
|
|
411
411
|
{
|
|
412
412
|
return true;
|
|
@@ -417,6 +417,9 @@ namespace Azerion.BlueStack.API
|
|
|
417
417
|
// Method to check if a gameobject is in the camera's view frustum
|
|
418
418
|
private bool IsInViewFrustum()
|
|
419
419
|
{
|
|
420
|
+
// Debug.LogWarning("::::::::::::");
|
|
421
|
+
// Debug.LogWarning("OBJECT: " + this.name);
|
|
422
|
+
// Debug.LogWarning("IsRenderedInScreenSpaceOverlayCanvas: " + NativeUtils.IsRenderedInScreenSpaceOverlayCanvas(gameObject));
|
|
420
423
|
// Check if the gameobject is rendered in the screen space overlay canvas
|
|
421
424
|
if (!NativeUtils.IsRenderedInScreenSpaceOverlayCanvas(gameObject))
|
|
422
425
|
{
|
|
@@ -432,11 +435,13 @@ namespace Azerion.BlueStack.API
|
|
|
432
435
|
{
|
|
433
436
|
bounds = this.GetComponent<Collider>().bounds;
|
|
434
437
|
}
|
|
435
|
-
|
|
438
|
+
Debug.LogWarning("bounds: " + bounds);
|
|
439
|
+
|
|
436
440
|
// Get the view frustum planes
|
|
437
441
|
Plane[] frustumPlanes = GeometryUtility.CalculateFrustumPlanes(mainCamera);
|
|
438
442
|
|
|
439
443
|
// Check if the gameobject bounds intersect with the view frustum planes
|
|
444
|
+
Debug.LogWarning("TestPlanesAABB: " + GeometryUtility.TestPlanesAABB(frustumPlanes, bounds));
|
|
440
445
|
if (!GeometryUtility.TestPlanesAABB(frustumPlanes, bounds))
|
|
441
446
|
{
|
|
442
447
|
return false;
|
|
@@ -450,6 +455,8 @@ namespace Azerion.BlueStack.API
|
|
|
450
455
|
float height = Math.Min(Screen.height, maxBounds.y) - Math.Max(0.0f, minBounds.y);
|
|
451
456
|
float width = Math.Min(Screen.width, maxBounds.x) - Math.Max(0.0f, minBounds.x);
|
|
452
457
|
|
|
458
|
+
Debug.LogWarning("height: " + height);
|
|
459
|
+
Debug.LogWarning("width: " + width);
|
|
453
460
|
// Check if the gameobject bounds are too small to be visible
|
|
454
461
|
if (height <= 0.01f * Screen.height || width <= 0.01f * Screen.width)
|
|
455
462
|
{
|
|
@@ -458,6 +465,8 @@ namespace Azerion.BlueStack.API
|
|
|
458
465
|
}
|
|
459
466
|
else // When rendered in the screen space overlay canvas
|
|
460
467
|
{
|
|
468
|
+
Debug.LogWarning("DoesUIElementOverlapScreen: " + DoesUIElementOverlapScreen());
|
|
469
|
+
|
|
461
470
|
// Check if the UI element overlaps with the screen
|
|
462
471
|
if (!DoesUIElementOverlapScreen())
|
|
463
472
|
{
|
|
@@ -470,8 +479,11 @@ namespace Azerion.BlueStack.API
|
|
|
470
479
|
|
|
471
480
|
private void CheckForImpression()
|
|
472
481
|
{
|
|
473
|
-
|
|
482
|
+
// Debug.LogWarning("_isVisible: " + this._isImpressionChecked);
|
|
483
|
+
Debug.LogWarning("IsInViewFrustum(): " + IsInViewFrustum());
|
|
484
|
+
if (!_isImpressionChecked && IsInViewFrustum())
|
|
474
485
|
{
|
|
486
|
+
// Debug.Log("CheckForImpression: OnAdDisplay");
|
|
475
487
|
OnAdDisplay?.Invoke(this, EventArgs.Empty);
|
|
476
488
|
}
|
|
477
489
|
}
|
|
@@ -480,41 +492,65 @@ namespace Azerion.BlueStack.API
|
|
|
480
492
|
return 0.1f;
|
|
481
493
|
}
|
|
482
494
|
|
|
483
|
-
// TODO:
|
|
495
|
+
// TODO: More testing and Improvement required
|
|
496
|
+
// TODO: BSSDK-401 : Move viewability to container level - may not have a container
|
|
484
497
|
private bool IsValidUIObject()
|
|
485
498
|
{
|
|
486
499
|
Canvas canvas = GetComponentInParent<Canvas>();
|
|
487
500
|
if (canvas == null)
|
|
488
501
|
{
|
|
489
|
-
Debug.Log("
|
|
502
|
+
Debug.Log("Unable to find Canvas component in parents");
|
|
490
503
|
return false;
|
|
491
504
|
}
|
|
492
505
|
|
|
493
506
|
RectTransform rectTransform = GetComponent<RectTransform>();
|
|
494
507
|
if (rectTransform == null)
|
|
495
508
|
{
|
|
496
|
-
Debug.Log("
|
|
509
|
+
Debug.Log("RectTransform component is null");
|
|
497
510
|
return false;
|
|
498
511
|
}
|
|
499
|
-
|
|
500
|
-
Rect rect = rectTransform.rect;
|
|
501
512
|
|
|
502
|
-
|
|
503
|
-
|
|
513
|
+
CanvasRenderer canvasRenderer = GetComponent<CanvasRenderer>();
|
|
514
|
+
if (canvasRenderer == null)
|
|
515
|
+
{
|
|
516
|
+
Debug.Log("CanvasRenderer component is null");
|
|
517
|
+
return false;
|
|
518
|
+
}
|
|
504
519
|
|
|
505
|
-
//
|
|
506
|
-
|
|
520
|
+
// Rect rect = rectTransform.rect;
|
|
521
|
+
//
|
|
522
|
+
// // Get the center position of the RectTransform in its local coordinates
|
|
523
|
+
// Vector2 centerLocalPosition = new Vector2(rect.center.x, rect.center.y);
|
|
524
|
+
//
|
|
525
|
+
// // Convert the local center position to world position
|
|
526
|
+
// Vector3 centerWorldPosition = rectTransform.TransformPoint(centerLocalPosition);
|
|
507
527
|
// Debug.Log("centerWorldPosition: " + centerWorldPosition);
|
|
508
|
-
|
|
509
|
-
Vector3 viewportPoint = NativeUtils.GetCamera().WorldToViewportPoint(centerWorldPosition);
|
|
528
|
+
//
|
|
529
|
+
// Vector3 viewportPoint = NativeUtils.GetCamera().WorldToViewportPoint(centerWorldPosition);
|
|
510
530
|
// Debug.Log("viewportPoints: " + viewportPoint);
|
|
511
|
-
if (viewportPoint.x >= 0 && viewportPoint.x <= 1 && viewportPoint.y >= 0 && viewportPoint.y <= 1 && viewportPoint.z > 0)
|
|
512
|
-
{
|
|
513
|
-
|
|
514
|
-
}
|
|
531
|
+
// if (viewportPoint.x >= 0 && viewportPoint.x <= 1 && viewportPoint.y >= 0 && viewportPoint.y <= 1 && viewportPoint.z > 0)
|
|
532
|
+
// {
|
|
533
|
+
// return true;
|
|
534
|
+
// }
|
|
535
|
+
|
|
536
|
+
// Check if it is completely inside the viewport
|
|
537
|
+
// Vector3[] corners = new Vector3[4];
|
|
538
|
+
// rectTransform.GetWorldCorners(corners);
|
|
539
|
+
// Debug.Log("Ad Object: " + this.name + " - " + corners.Length);
|
|
540
|
+
// foreach (Vector3 corner in corners)
|
|
541
|
+
// {
|
|
542
|
+
// // Debug.Log("corner: " + corner);
|
|
543
|
+
// Vector3 viewportPoint = Camera.main.WorldToViewportPoint(corner);
|
|
544
|
+
// // Debug.Log("viewportPoints: " + viewportPoint);
|
|
545
|
+
// if (viewportPoint.x >= 0 && viewportPoint.x <= 1 && viewportPoint.y >= 0 && viewportPoint.y <= 1 && viewportPoint.z > 0)
|
|
546
|
+
// {
|
|
547
|
+
// //return true;
|
|
548
|
+
// }
|
|
549
|
+
// }
|
|
515
550
|
|
|
516
|
-
Debug.Log("
|
|
517
|
-
|
|
551
|
+
// Debug.Log("Not a Valid UI Object!");
|
|
552
|
+
|
|
553
|
+
return true;
|
|
518
554
|
}
|
|
519
555
|
}
|
|
520
556
|
}
|
|
@@ -58,7 +58,8 @@ namespace Azerion.BlueStack.API.Rewarded
|
|
|
58
58
|
|
|
59
59
|
public void Load()
|
|
60
60
|
{
|
|
61
|
-
|
|
61
|
+
Preference preference = new Preference();
|
|
62
|
+
_rewardedVideoAdClient.Load(preference.getIPreferenceClient());
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
public void Load(Preference preference)
|
|
@@ -8,7 +8,11 @@ namespace Azerion.BlueStack.Internal
|
|
|
8
8
|
{
|
|
9
9
|
event EventHandler<EventArgs> OnNativeAdDidLoad;
|
|
10
10
|
event EventHandler<BlueStackError> OnNativeAdDidFail;
|
|
11
|
-
|
|
11
|
+
event EventHandler<EventArgs> OnNativeAdImpression;
|
|
12
|
+
event EventHandler<EventArgs> OnNativeAdClicked;
|
|
13
|
+
event EventHandler<EventArgs> OnNativeAdOpening;
|
|
14
|
+
event EventHandler<EventArgs> OnNativeAdClosed;
|
|
15
|
+
|
|
12
16
|
void Create(string placementId);
|
|
13
17
|
void Load();
|
|
14
18
|
void Load(IPreferenceClient iPreferenceClient);
|
|
@@ -20,6 +24,8 @@ namespace Azerion.BlueStack.Internal
|
|
|
20
24
|
string GetIconUrl();
|
|
21
25
|
string GetCoverImageUrl();
|
|
22
26
|
string GetClickUrl();
|
|
27
|
+
void RecordImpression();
|
|
28
|
+
void PerformClick();
|
|
23
29
|
void Destroy();
|
|
24
30
|
}
|
|
25
31
|
}
|
|
@@ -75,8 +75,7 @@ namespace Azerion.BlueStack.Platforms.Android
|
|
|
75
75
|
this.adaptersInitCompleteAction = adaptersInitCompleteAction;
|
|
76
76
|
|
|
77
77
|
var playerClass = new AndroidJavaClass(BlueStackNativeClassNames.UnityActivityClassName);
|
|
78
|
-
var activity =
|
|
79
|
-
playerClass.GetStatic<AndroidJavaObject>("currentActivity");
|
|
78
|
+
var activity = playerClass.GetStatic<AndroidJavaObject>("currentActivity");
|
|
80
79
|
var mngAdsClass = new AndroidJavaClass(BlueStackNativeClassNames.MNGAdsClassName);
|
|
81
80
|
mngAdsClass.CallStatic("setDebugModeEnabled", settings.IsDebugModeEnabled);
|
|
82
81
|
mngAdsClass.CallStatic("setMNGAdsSDKFactoryListener", this);
|
|
@@ -20,6 +20,10 @@ namespace Azerion.BlueStack.Platforms.Android
|
|
|
20
20
|
|
|
21
21
|
public event EventHandler<EventArgs> OnNativeAdDidLoad;
|
|
22
22
|
public event EventHandler<BlueStackError> OnNativeAdDidFail;
|
|
23
|
+
public event EventHandler<EventArgs> OnNativeAdImpression;
|
|
24
|
+
public event EventHandler<EventArgs> OnNativeAdClicked;
|
|
25
|
+
public event EventHandler<EventArgs> OnNativeAdOpening;
|
|
26
|
+
public event EventHandler<EventArgs> OnNativeAdClosed;
|
|
23
27
|
|
|
24
28
|
public void Create(string placementId)
|
|
25
29
|
{
|
|
@@ -36,12 +40,7 @@ namespace Azerion.BlueStack.Platforms.Android
|
|
|
36
40
|
PreferenceClient preferenceClient = (PreferenceClient)iPreferenceClient;
|
|
37
41
|
_unityNativeAd.Call("load", preferenceClient.getMNGPreference());
|
|
38
42
|
}
|
|
39
|
-
|
|
40
|
-
public void Show()
|
|
41
|
-
{
|
|
42
|
-
_unityNativeAd.Call("show");
|
|
43
|
-
}
|
|
44
|
-
|
|
43
|
+
|
|
45
44
|
public string GetTitle()
|
|
46
45
|
{
|
|
47
46
|
return _unityNativeAd.Call<string>("getTitle");
|
|
@@ -84,6 +83,16 @@ namespace Azerion.BlueStack.Platforms.Android
|
|
|
84
83
|
{
|
|
85
84
|
return _unityNativeAd.Call<string>("getClickUrl");
|
|
86
85
|
}
|
|
86
|
+
|
|
87
|
+
public void RecordImpression()
|
|
88
|
+
{
|
|
89
|
+
_unityNativeAd.Call("recordImpression");
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
public void PerformClick()
|
|
93
|
+
{
|
|
94
|
+
_unityNativeAd.Call("performClick");
|
|
95
|
+
}
|
|
87
96
|
|
|
88
97
|
public void Destroy()
|
|
89
98
|
{
|
|
@@ -102,6 +111,24 @@ namespace Azerion.BlueStack.Platforms.Android
|
|
|
102
111
|
OnNativeAdDidFail?.Invoke(this,
|
|
103
112
|
_blueStackErrorUtils.CreateBlueStackErrorFromJavaObject(adsErrorJavaObject));
|
|
104
113
|
}
|
|
114
|
+
|
|
115
|
+
public void onNativeAdRecordedImpression()
|
|
116
|
+
{
|
|
117
|
+
Debug.Log("NativeAdClient.onNativeAdRecordedImpression");
|
|
118
|
+
OnNativeAdImpression?.Invoke(this, EventArgs.Empty);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
public void onNativeAdPerformedClick()
|
|
122
|
+
{
|
|
123
|
+
Debug.Log("NativeAdClient.onNativeAdPerformedClick");
|
|
124
|
+
OnNativeAdClicked?.Invoke(this, EventArgs.Empty);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
public void onNativeAdClose()
|
|
128
|
+
{
|
|
129
|
+
Debug.Log("NativeAdClient.onNativeAdClose");
|
|
130
|
+
OnNativeAdClosed?.Invoke(this, EventArgs.Empty);
|
|
131
|
+
}
|
|
105
132
|
|
|
106
133
|
}
|
|
107
134
|
}
|
|
@@ -16,7 +16,15 @@ namespace Azerion.BlueStack.Platforms.UnityEditor
|
|
|
16
16
|
public event EventHandler<EventArgs> OnNativeAdDidLoad;
|
|
17
17
|
// Fires when the Native ad has failed to load
|
|
18
18
|
public event EventHandler<BlueStackError> OnNativeAdDidFail;
|
|
19
|
-
|
|
19
|
+
// Fires when the Native ad records impression
|
|
20
|
+
public event EventHandler<EventArgs> OnNativeAdImpression;
|
|
21
|
+
// Fires when the Native ad is clicked
|
|
22
|
+
public event EventHandler<EventArgs> OnNativeAdClicked;
|
|
23
|
+
// Fires when the Native ad is opening
|
|
24
|
+
public event EventHandler<EventArgs> OnNativeAdOpening;
|
|
25
|
+
// Fires when the Native ad is closed
|
|
26
|
+
public event EventHandler<EventArgs> OnNativeAdClosed;
|
|
27
|
+
|
|
20
28
|
// Creats a Native Ad
|
|
21
29
|
public void Create(string placementId)
|
|
22
30
|
{
|
|
@@ -84,6 +92,24 @@ namespace Azerion.BlueStack.Platforms.UnityEditor
|
|
|
84
92
|
return "https://developers.bluestack.app/";
|
|
85
93
|
}
|
|
86
94
|
|
|
95
|
+
public void RecordImpression()
|
|
96
|
+
{
|
|
97
|
+
Debug.LogWarning("Unity Native Ad Client : Impression Recorded!");
|
|
98
|
+
OnNativeAdImpression?.Invoke(this, EventArgs.Empty);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
public void PerformClick()
|
|
102
|
+
{
|
|
103
|
+
// OpenURL(GetClickUrl());
|
|
104
|
+
OnNativeAdClicked?.Invoke(this, EventArgs.Empty);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
private void OpenURL(string clickUrl)
|
|
108
|
+
{
|
|
109
|
+
Debug.Log("Opened URL");
|
|
110
|
+
Application.OpenURL(clickUrl);
|
|
111
|
+
}
|
|
112
|
+
|
|
87
113
|
// Destroys a Native Ad
|
|
88
114
|
public void Destroy()
|
|
89
115
|
{
|
|
@@ -231,12 +231,21 @@ namespace Azerion.BlueStack.Platforms.iOS
|
|
|
231
231
|
|
|
232
232
|
[DllImport("__Internal")]
|
|
233
233
|
internal static extern void BSUDestroyNativeAd(IntPtr native);
|
|
234
|
-
|
|
234
|
+
|
|
235
|
+
[DllImport("__Internal")]
|
|
236
|
+
internal static extern void BSURecordImpression(IntPtr native);
|
|
237
|
+
|
|
238
|
+
[DllImport("__Internal")]
|
|
239
|
+
internal static extern void BSUPerformClick(IntPtr native);
|
|
240
|
+
|
|
235
241
|
[DllImport("__Internal")]
|
|
236
242
|
internal static extern void BSUSetNativeAdCallbacks(
|
|
237
243
|
IntPtr bannerAd,
|
|
238
244
|
NativeAdClient.BSUOnNativeAdDidLoadCallback onNativeAdDidLoadCallback,
|
|
239
|
-
NativeAdClient.BSUOnNativeAdDidFailedCallback onNativeAdDidFailedCallback
|
|
245
|
+
NativeAdClient.BSUOnNativeAdDidFailedCallback onNativeAdDidFailedCallback,
|
|
246
|
+
NativeAdClient.BSUOnNativeAdDidRecordImpressionCallback onNativeAdDidRecordImpressionCallback,
|
|
247
|
+
NativeAdClient.BSUOnNativeAdDidPerformClickCallback onNativeAdDidPerformClickCallback,
|
|
248
|
+
NativeAdClient.BSUOnNativeAdCloseCallback onNativeAdCloseCallback
|
|
240
249
|
);
|
|
241
250
|
#endregion
|
|
242
251
|
|
|
@@ -15,7 +15,10 @@ namespace Azerion.BlueStack.Platforms.iOS
|
|
|
15
15
|
|
|
16
16
|
internal delegate void BSUOnNativeAdDidLoadCallback(IntPtr nativeClient);
|
|
17
17
|
internal delegate void BSUOnNativeAdDidFailedCallback(IntPtr nativeClient, IntPtr error);
|
|
18
|
-
|
|
18
|
+
internal delegate void BSUOnNativeAdDidRecordImpressionCallback(IntPtr nativeClient);
|
|
19
|
+
internal delegate void BSUOnNativeAdDidPerformClickCallback(IntPtr nativeClient);
|
|
20
|
+
internal delegate void BSUOnNativeAdCloseCallback(IntPtr nativeClient);
|
|
21
|
+
|
|
19
22
|
#endregion
|
|
20
23
|
|
|
21
24
|
// This property should be used when setting the nativeViewPtr.
|
|
@@ -51,7 +54,37 @@ namespace Azerion.BlueStack.Platforms.iOS
|
|
|
51
54
|
client.OnNativeAdDidFail(client, BlueStackErrorUtils.CreateFromIntPtr(error));
|
|
52
55
|
}
|
|
53
56
|
}
|
|
57
|
+
|
|
58
|
+
[AOT.MonoPInvokeCallback(typeof(BSUOnNativeAdDidLoadCallback))]
|
|
59
|
+
private static void OnNativeAdDidRecordImpressionCallback(IntPtr bannerClient)
|
|
60
|
+
{
|
|
61
|
+
NativeAdClient client = IntPtrToNativeAdClient(bannerClient);
|
|
62
|
+
if (client.OnNativeAdImpression != null)
|
|
63
|
+
{
|
|
64
|
+
client.OnNativeAdImpression(client, EventArgs.Empty);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
[AOT.MonoPInvokeCallback(typeof(BSUOnNativeAdDidLoadCallback))]
|
|
69
|
+
private static void OnNativeAdDidPerformClickCallback(IntPtr bannerClient)
|
|
70
|
+
{
|
|
71
|
+
NativeAdClient client = IntPtrToNativeAdClient(bannerClient);
|
|
72
|
+
if (client.OnNativeAdClicked != null)
|
|
73
|
+
{
|
|
74
|
+
client.OnNativeAdClicked(client, EventArgs.Empty);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
54
77
|
|
|
78
|
+
[AOT.MonoPInvokeCallback(typeof(BSUOnNativeAdDidLoadCallback))]
|
|
79
|
+
private static void OnNativeAdCloseCallback(IntPtr bannerClient)
|
|
80
|
+
{
|
|
81
|
+
NativeAdClient client = IntPtrToNativeAdClient(bannerClient);
|
|
82
|
+
if (client.OnNativeAdClosed != null)
|
|
83
|
+
{
|
|
84
|
+
client.OnNativeAdClosed(client, EventArgs.Empty);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
55
88
|
private static NativeAdClient IntPtrToNativeAdClient(IntPtr nativeClient)
|
|
56
89
|
{
|
|
57
90
|
GCHandle handle = (GCHandle)nativeClient;
|
|
@@ -84,7 +117,11 @@ namespace Azerion.BlueStack.Platforms.iOS
|
|
|
84
117
|
|
|
85
118
|
public event EventHandler<EventArgs> OnNativeAdDidLoad;
|
|
86
119
|
public event EventHandler<BlueStackError> OnNativeAdDidFail;
|
|
87
|
-
|
|
120
|
+
public event EventHandler<EventArgs> OnNativeAdImpression;
|
|
121
|
+
public event EventHandler<EventArgs> OnNativeAdClicked;
|
|
122
|
+
public event EventHandler<EventArgs> OnNativeAdOpening;
|
|
123
|
+
public event EventHandler<EventArgs> OnNativeAdClosed;
|
|
124
|
+
|
|
88
125
|
public void Create(string placementId)
|
|
89
126
|
{
|
|
90
127
|
this._nativeAdClientPtr = (IntPtr) GCHandle.Alloc(this);
|
|
@@ -95,7 +132,10 @@ namespace Azerion.BlueStack.Platforms.iOS
|
|
|
95
132
|
Externs.BSUSetNativeAdCallbacks(
|
|
96
133
|
this.NativeAdPtr,
|
|
97
134
|
OnNativeAdDidLoadCallback,
|
|
98
|
-
OnNativeAdDidFailCallback
|
|
135
|
+
OnNativeAdDidFailCallback,
|
|
136
|
+
OnNativeAdDidRecordImpressionCallback,
|
|
137
|
+
OnNativeAdDidPerformClickCallback,
|
|
138
|
+
OnNativeAdCloseCallback
|
|
99
139
|
);
|
|
100
140
|
}
|
|
101
141
|
|
|
@@ -149,7 +189,16 @@ namespace Azerion.BlueStack.Platforms.iOS
|
|
|
149
189
|
{
|
|
150
190
|
return Externs.BSUNativeAdGetClickUrl(this.NativeAdPtr);
|
|
151
191
|
}
|
|
152
|
-
|
|
192
|
+
|
|
193
|
+
public void RecordImpression()
|
|
194
|
+
{
|
|
195
|
+
Externs.BSURecordImpression(this.NativeAdPtr);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
public void PerformClick()
|
|
199
|
+
{
|
|
200
|
+
Externs.BSUPerformClick(this.NativeAdPtr);
|
|
201
|
+
}
|
|
153
202
|
}
|
|
154
203
|
}
|
|
155
204
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "com.azerion.bluestack",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-preview3",
|
|
4
4
|
"displayName": "BlueStack",
|
|
5
5
|
"description": "BlueStack SDK has been designed to give developers options for showing Ads from different ad networks.",
|
|
6
6
|
"unity": "2020.3",
|