com.azerion.bluestack 3.0.0-preview3 → 3.0.1-preview1

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.
Files changed (25) hide show
  1. package/Editor/BlueStackDependencies.xml +2 -3
  2. package/Editor/BlueStackSettings.cs +6 -6
  3. package/Example/Prefabs/NativeAd.prefab +76 -15
  4. package/Example/Scripts/NativeAdManager.cs +0 -1
  5. package/Plugins/Android/bluestack-unity-android-bridge-2.0.0.aar +0 -0
  6. package/Plugins/Android/{bluestack-unity-android-bridge-2.0.0-preview1.aar.meta → bluestack-unity-android-bridge-2.0.0.aar.meta} +1 -1
  7. package/Plugins/iOS/BSUInterface.m +3 -1
  8. package/Plugins/iOS/BSUNativeAd.m +2 -2
  9. package/Runtime/API/NativeAd/NativeAd.cs +3 -3
  10. package/Runtime/API/NativeAd/NativeAdInteractionHandler.cs +25 -20
  11. package/Runtime/API/NativeAd/NativeAdLoader.cs +2 -3
  12. package/Runtime/API/NativeAd/NativeAdObject.cs +80 -78
  13. package/Runtime/API/NativeAd/{NativeAssetID.cs → NativeAssetInfo.cs} +13 -0
  14. package/Runtime/Platforms/Android/AndroidJavaObjectFactory.cs +8 -0
  15. package/Runtime/Platforms/Android/BlueStackClient.cs +5 -0
  16. package/Runtime/Platforms/Android/BlueStackNativeClassNames.cs +2 -0
  17. package/Runtime/Platforms/Android/NativeAdClient.cs +0 -1
  18. package/Runtime/Platforms/Unity/NativeAdClient.cs +1 -1
  19. package/package.json +1 -1
  20. package/Plugins/Android/bluestack-unity-android-bridge-2.0.0-preview1.aar +0 -0
  21. package/Runtime/API/NativeAd/NativeAdInteractionUtils.cs +0 -120
  22. package/Runtime/API/NativeAd/NativeAdInteractionUtils.cs.meta +0 -11
  23. package/Runtime/API/NativeAd/NativeClientFactoryManager.cs +0 -32
  24. package/Runtime/API/NativeAd/NativeClientFactoryManager.cs.meta +0 -11
  25. /package/Runtime/API/NativeAd/{NativeAssetID.cs.meta → NativeAssetInfo.cs.meta} +0 -0
@@ -1,9 +1,8 @@
1
1
  <dependencies>
2
2
  <androidPackages>
3
- <androidPackage spec="com.azerion:bluestack-sdk-core:4.2.10" />
3
+ <androidPackage spec="com.azerion:bluestack-sdk-core:4.3.0" />
4
4
  </androidPackages>
5
5
  <iosPods>
6
- <iosPod name="BlueStack-SDK" version="4.3.0-preview.1" bitcodeEnabled="false"
7
- addToAllTargets="false"/>
6
+ <iosPod name="BlueStack-SDK" version="4.3.0" bitcodeEnabled="false" addToAllTargets="false"/>
8
7
  </iosPods>
9
8
  </dependencies>
@@ -7,9 +7,9 @@ namespace Azerion.BlueStack.Editor
7
7
  private static BlueStackSettings instance;
8
8
  private const string BlueStackSettingsFile = "BlueStackSettings";
9
9
 
10
- #if !UNITY_ANDROID
11
- [HideInInspector]
12
- #endif
10
+ // #if !UNITY_ANDROID
11
+ // [HideInInspector]
12
+ // #endif
13
13
  [SerializeField] private string admobAppIdAndroid;
14
14
  public string AdmobAppIdAndroid
15
15
  {
@@ -17,9 +17,9 @@ namespace Azerion.BlueStack.Editor
17
17
  set { Instance.admobAppIdAndroid = value; }
18
18
  }
19
19
 
20
- #if !UNITY_IOS
21
- [HideInInspector]
22
- #endif
20
+ // #if !UNITY_IOS
21
+ // [HideInInspector]
22
+ // #endif
23
23
  [SerializeField] private string admobAppIdIOS;
24
24
  public string AdmobAppIdIOS
25
25
  {
@@ -28,10 +28,10 @@ RectTransform:
28
28
  m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
29
29
  m_LocalPosition: {x: 0, y: 0, z: 0}
30
30
  m_LocalScale: {x: 1, y: 1, z: 1}
31
+ m_ConstrainProportionsScale: 0
31
32
  m_Children:
32
33
  - {fileID: 5666620918551509491}
33
34
  m_Father: {fileID: 5666620918374091928}
34
- m_RootOrder: 0
35
35
  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
36
36
  m_AnchorMin: {x: 0, y: 1}
37
37
  m_AnchorMax: {x: 0, y: 1}
@@ -102,9 +102,9 @@ RectTransform:
102
102
  m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
103
103
  m_LocalPosition: {x: 0, y: 0, z: 0}
104
104
  m_LocalScale: {x: 1, y: 1, z: 1}
105
+ m_ConstrainProportionsScale: 0
105
106
  m_Children: []
106
107
  m_Father: {fileID: 5666620918604549423}
107
- m_RootOrder: 0
108
108
  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
109
109
  m_AnchorMin: {x: 0, y: 0}
110
110
  m_AnchorMax: {x: 1, y: 1}
@@ -161,9 +161,17 @@ BoxCollider:
161
161
  m_PrefabAsset: {fileID: 0}
162
162
  m_GameObject: {fileID: 5666620917415584048}
163
163
  m_Material: {fileID: 0}
164
+ m_IncludeLayers:
165
+ serializedVersion: 2
166
+ m_Bits: 0
167
+ m_ExcludeLayers:
168
+ serializedVersion: 2
169
+ m_Bits: 0
170
+ m_LayerOverridePriority: 0
164
171
  m_IsTrigger: 0
172
+ m_ProvidesContacts: 0
165
173
  m_Enabled: 1
166
- serializedVersion: 2
174
+ serializedVersion: 3
167
175
  m_Size: {x: 1000, y: 100, z: 1}
168
176
  m_Center: {x: 0, y: 0, z: 0}
169
177
  --- !u!1 &5666620918374091929
@@ -194,6 +202,7 @@ RectTransform:
194
202
  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
195
203
  m_LocalPosition: {x: 0, y: 0, z: 0}
196
204
  m_LocalScale: {x: 1, y: 1, z: 1}
205
+ m_ConstrainProportionsScale: 0
197
206
  m_Children:
198
207
  - {fileID: 5666620917246655718}
199
208
  - {fileID: 5666620919071030927}
@@ -202,7 +211,6 @@ RectTransform:
202
211
  - {fileID: 5666620919168347858}
203
212
  - {fileID: 5666620918604549423}
204
213
  m_Father: {fileID: 5666620918536744664}
205
- m_RootOrder: 0
206
214
  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
207
215
  m_AnchorMin: {x: 0.5, y: 0.5}
208
216
  m_AnchorMax: {x: 0.5, y: 0.5}
@@ -276,9 +284,9 @@ RectTransform:
276
284
  m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
277
285
  m_LocalPosition: {x: 0, y: 0, z: 0}
278
286
  m_LocalScale: {x: 1, y: 1, z: 1}
287
+ m_ConstrainProportionsScale: 0
279
288
  m_Children: []
280
289
  m_Father: {fileID: 5666620918374091928}
281
- m_RootOrder: 2
282
290
  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
283
291
  m_AnchorMin: {x: 0, y: 1}
284
292
  m_AnchorMax: {x: 0, y: 1}
@@ -335,9 +343,17 @@ BoxCollider:
335
343
  m_PrefabAsset: {fileID: 0}
336
344
  m_GameObject: {fileID: 5666620918419381243}
337
345
  m_Material: {fileID: 0}
346
+ m_IncludeLayers:
347
+ serializedVersion: 2
348
+ m_Bits: 0
349
+ m_ExcludeLayers:
350
+ serializedVersion: 2
351
+ m_Bits: 0
352
+ m_LayerOverridePriority: 0
338
353
  m_IsTrigger: 0
354
+ m_ProvidesContacts: 0
339
355
  m_Enabled: 1
340
- serializedVersion: 2
356
+ serializedVersion: 3
341
357
  m_Size: {x: 785, y: 130, z: 1}
342
358
  m_Center: {x: 392.5, y: -65.6, z: 0}
343
359
  --- !u!1 &5666620918536744661
@@ -370,10 +386,10 @@ RectTransform:
370
386
  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
371
387
  m_LocalPosition: {x: 0, y: 0, z: 0}
372
388
  m_LocalScale: {x: 0, y: 0, z: 0}
389
+ m_ConstrainProportionsScale: 0
373
390
  m_Children:
374
391
  - {fileID: 5666620918374091928}
375
392
  m_Father: {fileID: 0}
376
- m_RootOrder: 0
377
393
  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
378
394
  m_AnchorMin: {x: 0, y: 0}
379
395
  m_AnchorMax: {x: 0, y: 0}
@@ -397,7 +413,9 @@ Canvas:
397
413
  m_OverrideSorting: 0
398
414
  m_OverridePixelPerfect: 0
399
415
  m_SortingBucketNormalizedSize: 0
416
+ m_VertexColorAlwaysGammaSpace: 0
400
417
  m_AdditionalShaderChannelsFlag: 0
418
+ m_UpdateRectTransformForStandalone: 0
401
419
  m_SortingLayerID: 0
402
420
  m_SortingOrder: 100
403
421
  m_TargetDisplay: 0
@@ -488,9 +506,9 @@ RectTransform:
488
506
  m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
489
507
  m_LocalPosition: {x: 0, y: 0, z: 0}
490
508
  m_LocalScale: {x: 1, y: 1, z: 1}
509
+ m_ConstrainProportionsScale: 0
491
510
  m_Children: []
492
511
  m_Father: {fileID: 5666620917246655718}
493
- m_RootOrder: 0
494
512
  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
495
513
  m_AnchorMin: {x: 0.5, y: 0.5}
496
514
  m_AnchorMax: {x: 0.5, y: 0.5}
@@ -547,9 +565,17 @@ BoxCollider:
547
565
  m_PrefabAsset: {fileID: 0}
548
566
  m_GameObject: {fileID: 5666620918551509388}
549
567
  m_Material: {fileID: 0}
568
+ m_IncludeLayers:
569
+ serializedVersion: 2
570
+ m_Bits: 0
571
+ m_ExcludeLayers:
572
+ serializedVersion: 2
573
+ m_Bits: 0
574
+ m_LayerOverridePriority: 0
550
575
  m_IsTrigger: 0
576
+ m_ProvidesContacts: 0
551
577
  m_Enabled: 1
552
- serializedVersion: 2
578
+ serializedVersion: 3
553
579
  m_Size: {x: 100, y: 50, z: 1}
554
580
  m_Center: {x: 0, y: 0, z: 0}
555
581
  --- !u!1 &5666620918604549416
@@ -580,10 +606,10 @@ RectTransform:
580
606
  m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
581
607
  m_LocalPosition: {x: 0, y: 0, z: 0}
582
608
  m_LocalScale: {x: 1, y: 1, z: 1}
609
+ m_ConstrainProportionsScale: 0
583
610
  m_Children:
584
611
  - {fileID: 5666620917415584055}
585
612
  m_Father: {fileID: 5666620918374091928}
586
- m_RootOrder: 5
587
613
  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
588
614
  m_AnchorMin: {x: 0.5, y: 0}
589
615
  m_AnchorMax: {x: 0.5, y: 0}
@@ -657,9 +683,9 @@ RectTransform:
657
683
  m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
658
684
  m_LocalPosition: {x: 0, y: 0, z: 0}
659
685
  m_LocalScale: {x: 1, y: 1, z: 1}
686
+ m_ConstrainProportionsScale: 0
660
687
  m_Children: []
661
688
  m_Father: {fileID: 5666620918374091928}
662
- m_RootOrder: 3
663
689
  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
664
690
  m_AnchorMin: {x: 0, y: 1}
665
691
  m_AnchorMax: {x: 0, y: 1}
@@ -716,9 +742,17 @@ BoxCollider:
716
742
  m_PrefabAsset: {fileID: 0}
717
743
  m_GameObject: {fileID: 5666620918867964668}
718
744
  m_Material: {fileID: 0}
745
+ m_IncludeLayers:
746
+ serializedVersion: 2
747
+ m_Bits: 0
748
+ m_ExcludeLayers:
749
+ serializedVersion: 2
750
+ m_Bits: 0
751
+ m_LayerOverridePriority: 0
719
752
  m_IsTrigger: 0
753
+ m_ProvidesContacts: 0
720
754
  m_Enabled: 1
721
- serializedVersion: 2
755
+ serializedVersion: 3
722
756
  m_Size: {x: 1000, y: 137, z: 1}
723
757
  m_Center: {x: 494.51, y: -68.2, z: 0}
724
758
  --- !u!1 &5666620919071030920
@@ -750,9 +784,9 @@ RectTransform:
750
784
  m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
751
785
  m_LocalPosition: {x: 0, y: 0, z: 0}
752
786
  m_LocalScale: {x: 1, y: 1, z: 1}
787
+ m_ConstrainProportionsScale: 0
753
788
  m_Children: []
754
789
  m_Father: {fileID: 5666620918374091928}
755
- m_RootOrder: 1
756
790
  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
757
791
  m_AnchorMin: {x: 0, y: 1}
758
792
  m_AnchorMax: {x: 0, y: 1}
@@ -804,6 +838,25 @@ BoxCollider2D:
804
838
  m_Enabled: 1
805
839
  m_Density: 1
806
840
  m_Material: {fileID: 0}
841
+ m_IncludeLayers:
842
+ serializedVersion: 2
843
+ m_Bits: 0
844
+ m_ExcludeLayers:
845
+ serializedVersion: 2
846
+ m_Bits: 0
847
+ m_LayerOverridePriority: 0
848
+ m_ForceSendLayers:
849
+ serializedVersion: 2
850
+ m_Bits: 4294967295
851
+ m_ForceReceiveLayers:
852
+ serializedVersion: 2
853
+ m_Bits: 4294967295
854
+ m_ContactCaptureLayers:
855
+ serializedVersion: 2
856
+ m_Bits: 4294967295
857
+ m_CallbackLayers:
858
+ serializedVersion: 2
859
+ m_Bits: 4294967295
807
860
  m_IsTrigger: 0
808
861
  m_UsedByEffector: 0
809
862
  m_UsedByComposite: 0
@@ -849,9 +902,9 @@ RectTransform:
849
902
  m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
850
903
  m_LocalPosition: {x: 0, y: 0, z: 0}
851
904
  m_LocalScale: {x: 1, y: 1, z: 1}
905
+ m_ConstrainProportionsScale: 0
852
906
  m_Children: []
853
907
  m_Father: {fileID: 5666620918374091928}
854
- m_RootOrder: 4
855
908
  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
856
909
  m_AnchorMin: {x: 0, y: 1}
857
910
  m_AnchorMax: {x: 0, y: 1}
@@ -866,9 +919,17 @@ BoxCollider:
866
919
  m_PrefabAsset: {fileID: 0}
867
920
  m_GameObject: {fileID: 5666620919168347859}
868
921
  m_Material: {fileID: 0}
922
+ m_IncludeLayers:
923
+ serializedVersion: 2
924
+ m_Bits: 0
925
+ m_ExcludeLayers:
926
+ serializedVersion: 2
927
+ m_Bits: 0
928
+ m_LayerOverridePriority: 0
869
929
  m_IsTrigger: 0
930
+ m_ProvidesContacts: 0
870
931
  m_Enabled: 1
871
- serializedVersion: 2
932
+ serializedVersion: 3
872
933
  m_Size: {x: 1000, y: 500, z: 1}
873
934
  m_Center: {x: 500, y: -250, z: 0}
874
935
  --- !u!222 &5666620919168347856
@@ -127,7 +127,6 @@ namespace Azerion.BlueStack.Example
127
127
  if (!this.nativeAd.RegisterBodyTextGameObject(this.body))
128
128
  {
129
129
  Debug.Log("RegisterBodyTextGameObject Unsuccessful");
130
-
131
130
  }
132
131
  }
133
132
 
@@ -1,5 +1,5 @@
1
1
  fileFormatVersion: 2
2
- guid: 505fa3b888bfa43f994c430c74b494b3
2
+ guid: 0ef5e1c8c3bad4e478a34254a658d3bc
3
3
  PluginImporter:
4
4
  externalObjects: {}
5
5
  serializedVersion: 2
@@ -58,6 +58,9 @@ 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
+ // set the client as CrossPlatform
62
+ [[NSUserDefaults standardUserDefaults] setBool: YES forKey:@"IsCrossPlatformNativeAd"];
63
+
61
64
  [[BSUInitializer sharedInstance] prepareBlueStackSDKWithAppId:appIdString withSettings:settings
62
65
  withSDKCompletionHandler:^(BOOL success, NSError *error) {
63
66
  NSLog(@"BSUInitializeWithCallback withCompletionHandler");
@@ -389,7 +392,6 @@ void BSUSetNativeAdCallbacks(BSUTypeNativeAdRef nativeAd,
389
392
  }
390
393
 
391
394
  BSUTypeNativeAdRef BSUCreateNativeAd(BSUTypeNativeAdClientRef *nativeAdClient, const char *placementId) {
392
- [[NSUserDefaults standardUserDefaults] setBool: YES forKey:@"IsCrossPlatformNativeAd"];
393
395
  NSString *placementIdStr = BSUStringFromUTF8String(placementId);
394
396
  BSUNativeAd *internalNativeAd = [[BSUNativeAd alloc] initWithNativeAdClientReference:nativeAdClient placementId:placementIdStr];
395
397
  BSUObjectCache *cache = [BSUObjectCache sharedInstance];
@@ -86,8 +86,8 @@
86
86
  self.badge = @"Ad"; //nativeObject.badge;
87
87
  self.callToAction = nativeObject.callToAction;
88
88
  self.clickUrl = @"https://developers.bluestack.app/"; //nativeObject.clickUrl;
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; //
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;
91
91
 
92
92
  self.onDidLoadCallback(self.nativeAdClient);
93
93
  }
@@ -24,7 +24,7 @@ namespace Azerion.BlueStack.API
24
24
 
25
25
  private NativeAdInteractionHandler _nativeAdInteractionHandler;
26
26
 
27
- public NativeAd(string placementId) : this(placementId,
27
+ internal NativeAd(string placementId) : this(placementId,
28
28
  BlueStackAds.GetClientsFactory().CreateNativeAdClient())
29
29
  {
30
30
  }
@@ -180,15 +180,15 @@ namespace Azerion.BlueStack.API
180
180
  {
181
181
  return _nativeAdInteractionHandler.RegisterAdvertiserTextGameObject(gameObject);
182
182
  }
183
-
184
183
 
185
- public void Destroy()
184
+ internal void Destroy()
186
185
  {
187
186
  _nativeAdClient.Destroy();
188
187
  }
189
188
 
190
189
  ~NativeAd()
191
190
  {
191
+ Debug.Log("NativeAd Destructor was called");
192
192
  AdsEventExecutor.ExecuteInUpdate(delegate
193
193
  {
194
194
  Destroy();
@@ -1,5 +1,6 @@
1
1
  using System;
2
2
  using System.Collections.Generic;
3
+ using System.Linq;
3
4
  using Azerion.BlueStack.Common;
4
5
  using Azerion.BlueStack.Internal;
5
6
  using UnityEngine;
@@ -30,7 +31,7 @@ namespace Azerion.BlueStack.API
30
31
 
31
32
  public bool RegisterIconImageGameObject(GameObject gameObject)
32
33
  {
33
- return RegisterGameObject(gameObject, NativeAssetID.Icon);
34
+ return RegisterGameObject(gameObject, NativeAssetID.Icon, true);
34
35
  }
35
36
 
36
37
  public bool RegisterAdChoicesLogoGameObject(GameObject gameObject)
@@ -40,7 +41,7 @@ namespace Azerion.BlueStack.API
40
41
 
41
42
  public bool RegisterHeadlineTextGameObject(GameObject gameObject)
42
43
  {
43
- return RegisterGameObject(gameObject, NativeAssetID.Headline);
44
+ return RegisterGameObject(gameObject, NativeAssetID.Headline, true);
44
45
  }
45
46
 
46
47
  public bool RegisterBodyTextGameObject(GameObject gameObject)
@@ -50,12 +51,12 @@ namespace Azerion.BlueStack.API
50
51
 
51
52
  public bool RegisterCallToActionGameObject(GameObject gameObject)
52
53
  {
53
- return RegisterGameObject(gameObject, NativeAssetID.CallToAction);
54
+ return RegisterGameObject(gameObject, NativeAssetID.CallToAction, true, true);
54
55
  }
55
56
 
56
57
  public bool RegisterAdvertiserTextGameObject(GameObject gameObject)
57
58
  {
58
- return RegisterGameObject(gameObject, NativeAssetID.Advertiser);
59
+ return RegisterGameObject(gameObject, NativeAssetID.Advertiser, true);
59
60
  }
60
61
 
61
62
  public bool RegisterPriceGameObject(GameObject gameObject)
@@ -68,12 +69,12 @@ namespace Azerion.BlueStack.API
68
69
  return RegisterGameObject(gameObject, NativeAssetID.Store);
69
70
  }
70
71
 
71
- private bool RegisterGameObject(GameObject adObject, NativeAssetID assetID)
72
+ private bool RegisterGameObject(GameObject adObject, NativeAssetID assetID, bool isImpressive = false, bool isClickable = false)
72
73
  {
73
- return Register(adObject, assetID.Value); // replace with GetAssetIDMappings
74
+ return Register(adObject, assetID.Value, isImpressive, isClickable); // replace with GetAssetIDMappings
74
75
  }
75
76
 
76
- private bool Register(GameObject adObject, string assetID, bool isClickable = false)
77
+ private bool Register(GameObject adObject, string assetID, bool isImpressive, bool isClickable)
77
78
  {
78
79
  NativeAdObject nativeAdObject = adObject.GetComponent<NativeAdObject>();
79
80
  if (nativeAdObject != null)
@@ -87,7 +88,7 @@ namespace Azerion.BlueStack.API
87
88
  nativeAdObject.OnAdClick += RecordClick;
88
89
  try
89
90
  {
90
- nativeAdObject.Initialize(assetID, isClickable);
91
+ nativeAdObject.Initialize(assetID, isImpressive, isClickable);
91
92
  }
92
93
  catch (InvalidOperationException ex)
93
94
  {
@@ -111,28 +112,32 @@ namespace Azerion.BlueStack.API
111
112
  // Handle Ad Impression - Incomplete
112
113
  private void RecordImpression(object sender, EventArgs eventArgs)
113
114
  {
114
- impressionComplete = true;
115
- Debug.LogWarning("Impression Complete");
115
+ List<string> requiredAssets = NativeAssetInfo.RequiredAssets;
116
+ var successfulImpressiveAssets = _nativeAdObjects.Where(obj => requiredAssets.Contains(obj.ObjectTag) && obj.HasMadeImpression).Select(obj => obj.ObjectTag);
117
+ impressionComplete = requiredAssets.All(tag => successfulImpressiveAssets.Contains(tag));
118
+ // Debug.LogWarning("Is Impression check successful: " + impressionComplete);
116
119
 
120
+ if(!impressionComplete) return;
121
+
117
122
  if (sender is NativeAdObject nativeAdObject)
118
123
  {
119
- _nativeAdClient.RecordImpression();
120
124
  _nativeAdClient.OnNativeAdImpression += (sender, args) =>
121
125
  {
122
- Debug.LogWarning("InteractionHandlerClient: OnNativeAdImpression!");
126
+ // Debug.LogWarning("InteractionHandlerClient: OnNativeAdImpression!");
123
127
  foreach (NativeAdObject adObject in _nativeAdObjects)
124
128
  {
125
- if(adObject != null)
126
- adObject.StopImpressionCheck();
129
+ if (adObject != null)
130
+ {
131
+ AdsEventExecutor.ExecuteInUpdate(delegate { adObject.StopImpressionCheck(); });
132
+ }
127
133
  }
128
134
  };
129
-
135
+ _nativeAdClient.RecordImpression();
136
+
130
137
  // if (_nativeAdInteractionHandlerClient.RecordImpression(NativeAdInteractionUtils.CreateImpressionSignal(nativeAdObject, _nativeAdObjects)))
131
138
  // {
132
139
  // foreach (NativeAdObject adObject in _nativeAdObjects)
133
140
  // {
134
- // if(adObject != null)
135
- // adObject.StopImpressionCheck();
136
141
  // }
137
142
  // }
138
143
  }
@@ -149,15 +154,15 @@ namespace Azerion.BlueStack.API
149
154
  {
150
155
  _nativeAdClient.OnNativeAdClicked += (sender, args) =>
151
156
  {
152
- OpenURL();
157
+ // OpenURL();
153
158
  Debug.LogWarning("InteractionHandlerClient: OnNativeAdClicked!");
154
159
  };
155
160
  _nativeAdClient.PerformClick();
156
161
 
157
162
  // Dictionary<string, string> touchEventSignal =
158
- // NativeAdInteractionUtils.CreateTouchEventSignal(clickEventArgs.startClick, clickEventArgs.endClick);
163
+ // NativeAdInteractionUtils.CreateTouchEventSignal(clickEventArgs.startClick, clickEventArgs.endClick);
159
164
  // Dictionary<string, object> clickSignal =
160
- // NativeAdInteractionUtils.CreateClickSignal(nativeAdObject, _nativeAdObjects, clickEventArgs.startClick, clickEventArgs.endClick);
165
+ // NativeAdInteractionUtils.CreateClickSignal(nativeAdObject, _nativeAdObjects, clickEventArgs.startClick, clickEventArgs.endClick);
161
166
  //
162
167
  // // _nativeAdInteractionHandlerClient.ReportTouchEvent(touchEventSignal);
163
168
  // Debug.LogWarning("InteractionHandlerClient: ReportTouchEvent!");
@@ -41,9 +41,8 @@ namespace Azerion.BlueStack.API
41
41
 
42
42
  this.OnNativeAdLoaded?.Invoke(this, nativeAdEventArgs);
43
43
  };
44
-
45
44
  }
46
-
45
+
47
46
  public string AdUnitId { get; private set; }
48
47
  public HashSet<NativeAdType> AdTypes { get; private set; }
49
48
  public HashSet<string> FormatIds { get; private set; }
@@ -51,7 +50,7 @@ namespace Azerion.BlueStack.API
51
50
 
52
51
  public void Load() => this._nativeAd.Load();
53
52
  public void Load(Preference preference) => this._nativeAd.Load(preference);
54
-
53
+ public void Destroy() => this._nativeAd.Destroy();
55
54
  }
56
55
 
57
56
  }
@@ -18,14 +18,14 @@ namespace Azerion.BlueStack.API
18
18
 
19
19
  internal struct ClickInfo
20
20
  {
21
- public Vector3 clickPosition;
22
- public float clickTime;
21
+ public Vector3 ClickPosition;
22
+ public float ClickTime;
23
23
  }
24
24
 
25
25
  internal class ClickEventArgs : EventArgs
26
26
  {
27
- public ClickInfo startClick { get; set; }
28
- public ClickInfo endClick { get; set; }
27
+ public ClickInfo StartClick { get; set; }
28
+ public ClickInfo EndClick { get; set; }
29
29
  }
30
30
 
31
31
  internal enum HitStatus
@@ -40,42 +40,33 @@ namespace Azerion.BlueStack.API
40
40
  {
41
41
  private const float _timeInterval = 0.1f;
42
42
  private const int _iterations = 5;
43
- private float _interactionTime;
44
43
  private float _lastInteractionTime;
45
- private bool _isImpressionChecked;
46
44
  private ClickInfo _clickInfo;
47
- private string _objectTag;
48
45
  private bool _is2DColliderPresent;
49
46
  private bool _isInteractionStarted;
50
47
  private bool _isRectTransPresent; // check again
51
48
  internal event EventHandler<EventArgs> OnAdDisplay;
52
49
  internal event EventHandler<ClickEventArgs> OnAdClick;
53
- internal float InteractionTime
54
- {
55
- get
56
- {
57
- return this._interactionTime;
58
- }
59
- }
50
+ internal bool IsImpressionChecked;
51
+ internal bool HasMadeImpression;
52
+ internal bool IsImpressive;
53
+ internal bool IsClickable;
54
+
55
+ internal float InteractionTime { get; private set; }
60
56
 
61
- internal string ObjectTag
62
- {
63
- get
64
- {
65
- return this._objectTag;
66
- }
67
- }
57
+ internal string ObjectTag { get; private set; }
68
58
 
69
59
  public void Start()
70
60
  {
71
61
  this._lastInteractionTime = 0f;
72
- this._isImpressionChecked = false;
62
+ this.IsImpressionChecked = false;
73
63
  }
74
64
 
75
- public void Initialize(string tag, bool isClickable = false)
65
+ public void Initialize(string nativeAssetID, bool isImpressive = false, bool isClickable = false)
76
66
  {
77
- _objectTag = tag;
78
- string exMessage;
67
+ ObjectTag = nativeAssetID;
68
+ IsImpressive = isImpressive;
69
+ IsClickable = isClickable;
79
70
 
80
71
  if (GetComponent<Collider>() == null)
81
72
  {
@@ -113,27 +104,30 @@ namespace Azerion.BlueStack.API
113
104
  throw new InvalidOperationException(" Not a valid Ad Object.");
114
105
  }
115
106
 
116
- InvokeRepeating("CheckForImpression", 0f, this.TimeInterval());
107
+ if(IsImpressive)
108
+ InvokeRepeating("CheckForImpression", 0.0f, this.TimeInterval());
117
109
  }
118
110
 
119
111
  ClickInfo _startClick;
120
112
  ClickInfo _endClick;
121
-
122
113
  public void Update()
123
114
  {
115
+ if(!IsClickable) return;
116
+
117
+ // track clickable elements
124
118
  this._lastInteractionTime += (Time.deltaTime - this._lastInteractionTime) * 0.1f;
125
119
 
126
120
  if (Input.GetMouseButtonDown(0))
127
121
  {
128
122
  this._isInteractionStarted = true;
129
- _startClick.clickPosition = Input.mousePosition;
130
- _startClick.clickTime = Time.time * 1000f;
123
+ _startClick.ClickPosition = Input.mousePosition;
124
+ _startClick.ClickTime = Time.time * 1000f;
131
125
  }
132
126
  else if (this._isInteractionStarted && Input.GetMouseButtonUp(0))
133
127
  {
134
128
  this._isInteractionStarted = false;
135
- _endClick.clickPosition = Input.mousePosition;
136
- _endClick.clickTime = Time.time * 1000f;
129
+ _endClick.ClickPosition = Input.mousePosition;
130
+ _endClick.ClickTime = Time.time * 1000f;
137
131
 
138
132
  HitStatus hitStatus;
139
133
 
@@ -147,11 +141,9 @@ namespace Azerion.BlueStack.API
147
141
  hitStatus = CheckHitStatus2D(Input.mousePosition);
148
142
  }
149
143
 
150
- // hitStatus = CheckHitStatusCanvas(Input.mousePosition);
151
- // Debug.Log("Hit Status::::::: " + hitStatus.ToString());
152
144
  if (hitStatus == HitStatus.UnobstructedHit)
153
145
  {
154
- OnAdClick?.Invoke(this, new ClickEventArgs { startClick = _startClick, endClick = _endClick });
146
+ OnAdClick?.Invoke(this, new ClickEventArgs { StartClick = _startClick, EndClick = _endClick });
155
147
  }
156
148
  }
157
149
  }
@@ -162,9 +154,9 @@ namespace Azerion.BlueStack.API
162
154
  // Get camera component
163
155
  Camera mainCamera = NativeUtils.GetCamera();
164
156
  VisibilityInfo visibilityInfo = new VisibilityInfo(); // Create a new struct
165
- // Get gameobject to check bounds for
157
+ // Get gameobject to check bounds for
166
158
  GameObject currentGameObject = this.gameObject;
167
- // Get world space bounds
159
+ // Get world space bounds
168
160
  Bounds worldSpaceBounds;
169
161
  if (!_is2DColliderPresent) // Check if 3D object
170
162
  {
@@ -174,27 +166,32 @@ namespace Azerion.BlueStack.API
174
166
  {
175
167
  worldSpaceBounds = currentGameObject.GetComponent<Collider2D>().bounds;
176
168
  }
177
- // Get max bounds
169
+ // Get max bounds
178
170
  Vector3 maxBounds = NativeUtils.GetBoundsMax(currentGameObject, mainCamera, worldSpaceBounds);
179
- // Get min bounds
171
+ // Get min bounds
180
172
  Vector3 minBounds = NativeUtils.GetBoundsMin(currentGameObject, mainCamera, worldSpaceBounds);
181
173
 
182
- // Calculate screen space bounds
174
+ // Calculate screen space bounds
183
175
  float minX = Math.Max(0.0f, minBounds.x);
184
176
  float minY = Math.Max(0.0f, minBounds.y);
185
177
  float maxX = Math.Min(Screen.width, maxBounds.x);
186
178
  float maxY = Math.Min(Screen.height, maxBounds.y);
187
179
 
188
- // Increment amounts
180
+ // Increment amounts
189
181
  int xDivisions = (int) ((maxX - minX) / 5.0);
190
182
  int yDivisions = (int) ((maxY - minY) / 5.0);
191
183
 
192
- // Check if center is visible
184
+ // Check if center is visible
193
185
  if (xDivisions <= 0 || yDivisions <= 0)
194
186
  {
195
187
  return visibilityInfo;
196
188
  }
197
- // Calculate screen space area
189
+
190
+ // Calculate actual area
191
+ float actualWidth = maxBounds.x - minBounds.x;
192
+ float actualHeight = maxBounds.y - minBounds.y;
193
+
194
+ // Calculate screen space area
198
195
  float width = maxX - minX;
199
196
  float height = maxY - minY;
200
197
 
@@ -203,20 +200,20 @@ namespace Azerion.BlueStack.API
203
200
  {
204
201
  return visibilityInfo;
205
202
  }
206
- float area = width * height;
207
-
208
- // Set values in Visibility Info
203
+ float areaOnScreen = width * height;
204
+ float percentageOfAreaOnScreen = areaOnScreen / (actualWidth * actualHeight);
205
+
209
206
  // visibilityInfo.PercentageOfVisibleArea = !this._is2DColliderPresent ? this.CalculatePercentageOfVisibleArea3D(minX, maxX, minY, maxY, xDivisions, yDivisions)
210
207
  // : this.CalculatePercentageOfVisibleArea3D(minX, maxX, minY, maxY, xDivisions, yDivisions);
211
208
 
212
- visibilityInfo.PercentageOfVisibleArea = CalculatePercentageOfVisibleArea(minX, maxX, minY, maxY, xDivisions, yDivisions);
213
- visibilityInfo.PercentageOfScreenSpace = area / (Screen.width * Screen.height);
214
- return visibilityInfo;
209
+ // Set values in Visibility Info
210
+ visibilityInfo.PercentageOfVisibleArea = CalculatePercentageOfVisibleArea(minX, maxX, minY, maxY, xDivisions, yDivisions, percentageOfAreaOnScreen);
211
+ visibilityInfo.PercentageOfScreenSpace = areaOnScreen / (Screen.width * Screen.height);
212
+ return visibilityInfo;
215
213
  }
216
214
 
217
- // Methods to check if the given input vector is obstructed or unobstructed v
218
-
219
- public HitStatus CheckHitStatus2D(Vector3 position)
215
+ // Methods to check if the given input vector is obstructed or unobstructed
216
+ private HitStatus CheckHitStatus2D(Vector3 position)
220
217
  {
221
218
  // Create a ray from the camera to the specified screen point
222
219
  Ray ray = NativeUtils.GetCamera().ScreenPointToRay(position);
@@ -224,7 +221,7 @@ namespace Azerion.BlueStack.API
224
221
  // Perform a 2D raycast and store the result
225
222
  var rayIntersection = Physics2D.GetRayIntersection(ray);
226
223
  // Check if the raycast hit is obstructed by a Collider component
227
- if (rayIntersection.collider != null)
224
+ if ((UnityEngine.Object)rayIntersection.collider != null)
228
225
  {
229
226
  if (rayIntersection.collider == GetComponent<Collider2D>())
230
227
  {
@@ -322,8 +319,8 @@ namespace Azerion.BlueStack.API
322
319
  {
323
320
  // Check for 2D raycast hit
324
321
  rayIntersection = Physics2D.GetRayIntersection(ray);
325
- if ((UnityEngine.Object)rayIntersection.collider != (UnityEngine.Object)null &&
326
- (double)rayIntersection.distance <= (double)hitInfo.distance)
322
+ if ((UnityEngine.Object)rayIntersection.collider != null &&
323
+ rayIntersection.distance <= hitInfo.distance)
327
324
  {
328
325
  return HitStatus.UnobstructedHit;
329
326
  }
@@ -336,8 +333,8 @@ namespace Azerion.BlueStack.API
336
333
  return this.CheckHitStatusCanvas(position);
337
334
  }
338
335
 
339
- // Method to check for Visible Area in screen space
340
- private float CalculatePercentageOfVisibleArea(float minX, float maxX, float minY, float maxY, int xDivisions, int yDivisions)
336
+ // Method to check for Unobstructed Visible Area in screen space
337
+ private float CalculatePercentageOfVisibleArea(float minX, float maxX, float minY, float maxY, int xDivisions, int yDivisions, float percentageOfAreaOnScreen)
341
338
  {
342
339
  // Initialize variables
343
340
  float numUnobstructedPoints = 0.0f;
@@ -367,7 +364,8 @@ namespace Azerion.BlueStack.API
367
364
  currentX += xDivisions;
368
365
  currentY = minY;
369
366
  }
370
- return numUnobstructedPoints / totalPoints;
367
+
368
+ return percentageOfAreaOnScreen * (numUnobstructedPoints / totalPoints);
371
369
  }
372
370
 
373
371
  public void OnDestroy()
@@ -377,9 +375,9 @@ namespace Azerion.BlueStack.API
377
375
 
378
376
  public void OnBecameVisible()
379
377
  {
380
- if (!this._isImpressionChecked)
378
+ if (!this.IsImpressionChecked && IsImpressive)
381
379
  {
382
- InvokeRepeating("CheckForImpression", 0f, this.TimeInterval());
380
+ InvokeRepeating("CheckForImpression", 1.0f, this.TimeInterval());
383
381
  }
384
382
  }
385
383
 
@@ -388,7 +386,7 @@ namespace Azerion.BlueStack.API
388
386
  public void StopImpressionCheck()
389
387
  {
390
388
  base.CancelInvoke();
391
- this._isImpressionChecked = true;
389
+ this.IsImpressionChecked = true;
392
390
  }
393
391
 
394
392
  // Method to check if a UI element overlaps with the screen
@@ -398,15 +396,15 @@ namespace Azerion.BlueStack.API
398
396
  RectTransform rectTransform = this.GetComponent<RectTransform>();
399
397
  // Create a rect for the screen size
400
398
  Rect screenRect = new Rect(0.0f, 0.0f, Screen.width, Screen.height);
401
- // Get the anchored position of the UI element
399
+ // Get the anchored position of the UI element
402
400
  float x = rectTransform.anchoredPosition.x + rectTransform.position.x;
403
401
  float y = Screen.height - rectTransform.position.y - rectTransform.anchoredPosition.y;
404
- // Get the size of the UI element
402
+ // Get the size of the UI element
405
403
  Vector2 elementSize = Vector2.Scale(rectTransform.rect.size, rectTransform.lossyScale);
406
- // Create a rect for the UI element
404
+ // Create a rect for the UI element
407
405
  Rect elementRect = new Rect(x, y, elementSize.x, elementSize.y);
408
- // Check if the UI element rect overlaps with the screen rect
409
- Debug.LogWarning("Does screenRect.Overlaps: " + screenRect.Overlaps(elementRect, false));
406
+ // Check if the UI element rect overlaps with the screen rect
407
+ Debug.LogWarning("Does screenRect.Overlaps: " + screenRect.Overlaps(elementRect, false));
410
408
  if (screenRect.Overlaps(elementRect, false))
411
409
  {
412
410
  return true;
@@ -417,9 +415,6 @@ namespace Azerion.BlueStack.API
417
415
  // Method to check if a gameobject is in the camera's view frustum
418
416
  private bool IsInViewFrustum()
419
417
  {
420
- // Debug.LogWarning("::::::::::::");
421
- // Debug.LogWarning("OBJECT: " + this.name);
422
- // Debug.LogWarning("IsRenderedInScreenSpaceOverlayCanvas: " + NativeUtils.IsRenderedInScreenSpaceOverlayCanvas(gameObject));
423
418
  // Check if the gameobject is rendered in the screen space overlay canvas
424
419
  if (!NativeUtils.IsRenderedInScreenSpaceOverlayCanvas(gameObject))
425
420
  {
@@ -435,13 +430,13 @@ namespace Azerion.BlueStack.API
435
430
  {
436
431
  bounds = this.GetComponent<Collider>().bounds;
437
432
  }
438
- Debug.LogWarning("bounds: " + bounds);
433
+ // Debug.LogWarning("bounds: " + bounds);
439
434
 
440
435
  // Get the view frustum planes
441
436
  Plane[] frustumPlanes = GeometryUtility.CalculateFrustumPlanes(mainCamera);
442
437
 
443
438
  // Check if the gameobject bounds intersect with the view frustum planes
444
- Debug.LogWarning("TestPlanesAABB: " + GeometryUtility.TestPlanesAABB(frustumPlanes, bounds));
439
+ // Debug.LogWarning("TestPlanesAABB: " + GeometryUtility.TestPlanesAABB(frustumPlanes, bounds));
445
440
  if (!GeometryUtility.TestPlanesAABB(frustumPlanes, bounds))
446
441
  {
447
442
  return false;
@@ -455,8 +450,9 @@ namespace Azerion.BlueStack.API
455
450
  float height = Math.Min(Screen.height, maxBounds.y) - Math.Max(0.0f, minBounds.y);
456
451
  float width = Math.Min(Screen.width, maxBounds.x) - Math.Max(0.0f, minBounds.x);
457
452
 
458
- Debug.LogWarning("height: " + height);
459
- Debug.LogWarning("width: " + width);
453
+ // Debug.LogWarning("height: " + height);
454
+ // Debug.LogWarning("width: " + width);
455
+
460
456
  // Check if the gameobject bounds are too small to be visible
461
457
  if (height <= 0.01f * Screen.height || width <= 0.01f * Screen.width)
462
458
  {
@@ -479,17 +475,23 @@ namespace Azerion.BlueStack.API
479
475
 
480
476
  private void CheckForImpression()
481
477
  {
482
- // Debug.LogWarning("_isVisible: " + this._isImpressionChecked);
483
- Debug.LogWarning("IsInViewFrustum(): " + IsInViewFrustum());
484
- if (!_isImpressionChecked && IsInViewFrustum())
478
+ VisibilityInfo visibilityInfo = GetVisibilityInfo();
479
+ if (!IsImpressionChecked && IsInViewFrustum())
485
480
  {
486
- // Debug.Log("CheckForImpression: OnAdDisplay");
487
- OnAdDisplay?.Invoke(this, EventArgs.Empty);
481
+ if (visibilityInfo.PercentageOfVisibleArea >= 0.5f) // if Visible Area is >= 50%
482
+ {
483
+ HasMadeImpression = true;
484
+ OnAdDisplay?.Invoke(this, EventArgs.Empty);
485
+ }
486
+ else
487
+ {
488
+ HasMadeImpression = false;
489
+ }
488
490
  }
489
491
  }
490
492
  private float TimeInterval()
491
493
  {
492
- return 0.1f;
494
+ return 1.0f;
493
495
  }
494
496
 
495
497
  // TODO: More testing and Improvement required
@@ -1,3 +1,5 @@
1
+ using System.Collections.Generic;
2
+
1
3
  namespace Azerion.BlueStack.API
2
4
  {
3
5
  public class NativeAssetID
@@ -27,4 +29,15 @@ namespace Azerion.BlueStack.API
27
29
  Value = value;
28
30
  }
29
31
  }
32
+
33
+ public class NativeAssetInfo
34
+ {
35
+ public static List<string> RequiredAssets => new List<string>
36
+ {
37
+ NativeAssetID.Icon.Value,
38
+ NativeAssetID.Headline.Value,
39
+ NativeAssetID.CallToAction.Value,
40
+ NativeAssetID.Advertiser.Value
41
+ };
42
+ }
30
43
  }
@@ -41,6 +41,14 @@ namespace Azerion.BlueStack.Platforms.Android
41
41
  playerClass.GetStatic<AndroidJavaObject>("currentActivity");
42
42
  return new AndroidJavaObject(BlueStackNativeClassNames.UnityNativeAd, activity, unityNativeAdListener);
43
43
  }
44
+
45
+ public virtual AndroidJavaObject CreateCrossPlatformClientSetupAndroidJavaObject()
46
+ {
47
+ AndroidJavaClass playerClass = new AndroidJavaClass(BlueStackNativeClassNames.UnityActivityClassName);
48
+ AndroidJavaObject activity =
49
+ playerClass.GetStatic<AndroidJavaObject>("currentActivity");
50
+ return new AndroidJavaObject(BlueStackNativeClassNames.CrossPlatformClientSetup, activity);
51
+ }
44
52
  }
45
53
  }
46
54
  #endif
@@ -21,6 +21,11 @@ namespace Azerion.BlueStack.Platforms.Android
21
21
  public void onMNGAdsSDKFactoryDidFinishInitializing()
22
22
  {
23
23
  var status = new SDKInitializationStatus(true, "BlueStack is successfully initialized");
24
+
25
+ // Set pref as cross platform client
26
+ var crossPlatformClientSetup = AndroidJavaObjectFactory.Instance.CreateCrossPlatformClientSetupAndroidJavaObject();
27
+ crossPlatformClientSetup.Call("setPlatformPref");
28
+
24
29
  sdkInitCompleteAction?.Invoke(status);
25
30
  }
26
31
 
@@ -17,6 +17,8 @@ namespace Azerion.BlueStack.Platforms.Android
17
17
 
18
18
  #region BlueStack Android Bridge
19
19
 
20
+ public const string CrossPlatformClientSetup = "com.azerion.bluestack.unity.CrossPlatformClientSetup";
21
+
20
22
  public const string UnityRewardedVideoAd = "com.azerion.bluestack.unity.rewarded.UnityRewardedVideoAd";
21
23
  public const string UnityRewardedAdListener = "com.azerion.bluestack.unity.rewarded.UnityRewardedAdListener";
22
24
 
@@ -129,7 +129,6 @@ namespace Azerion.BlueStack.Platforms.Android
129
129
  Debug.Log("NativeAdClient.onNativeAdClose");
130
130
  OnNativeAdClosed?.Invoke(this, EventArgs.Empty);
131
131
  }
132
-
133
132
  }
134
133
  }
135
134
  #endif
@@ -100,7 +100,7 @@ namespace Azerion.BlueStack.Platforms.UnityEditor
100
100
 
101
101
  public void PerformClick()
102
102
  {
103
- // OpenURL(GetClickUrl());
103
+ OpenURL(GetClickUrl());
104
104
  OnNativeAdClicked?.Invoke(this, EventArgs.Empty);
105
105
  }
106
106
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.azerion.bluestack",
3
- "version": "3.0.0-preview3",
3
+ "version": "3.0.1-preview1",
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",
@@ -1,120 +0,0 @@
1
- using System;
2
- using System.Collections.Generic;
3
- using System.Globalization;
4
- using System.Text;
5
- using Azerion.BlueStack.Common;
6
- using UnityEngine;
7
-
8
- // incomplete
9
- namespace Azerion.BlueStack.API
10
- {
11
- internal static class NativeAdInteractionUtils
12
- {
13
- public static Dictionary<string, string> CreateTouchEventSignal(ClickInfo currentPosition,
14
- ClickInfo previousPosition)
15
- {
16
- Dictionary<string, string> signal = new Dictionary<string, string>();
17
- signal.Add(GetHashedString("PreviousClickPosition.x"),
18
- NativeUtils.ConvertPxToDp(previousPosition.clickPosition.x)
19
- .ToString((IFormatProvider)CultureInfo.InvariantCulture));
20
- signal.Add(GetHashedString("PreviousClickPosition.y"),
21
- NativeUtils.ConvertPxToDp(previousPosition.clickPosition.y)
22
- .ToString((IFormatProvider)CultureInfo.InvariantCulture));
23
- signal.Add(GetHashedString("TimeInterval"),
24
- Mathf.RoundToInt(previousPosition.clickTime - currentPosition.clickTime)
25
- .ToString((IFormatProvider)CultureInfo.InvariantCulture));
26
- return signal;
27
- }
28
-
29
- public static Dictionary<string, object> CreateClickSignal(NativeAdObject adComponent,
30
- List<NativeAdObject> adComponents, ClickInfo currentPosition, ClickInfo previousPosition)
31
- {
32
- Dictionary<string, object> signal = new Dictionary<string, object>();
33
- Dictionary<string, string> positionSignal = new Dictionary<string, string>();
34
- Dictionary<string, object> clickSignal = new Dictionary<string, object>();
35
- positionSignal.Add(GetHashedString("CurrentClickPosition.x"),
36
- NativeUtils.ConvertPxToDp(currentPosition.clickPosition.x)
37
- .ToString((IFormatProvider)CultureInfo.InvariantCulture));
38
- positionSignal.Add(GetHashedString("CurrentClickPosition.y"),
39
- NativeUtils.ConvertPxToDp(currentPosition.clickPosition.y)
40
- .ToString((IFormatProvider)CultureInfo.InvariantCulture));
41
- positionSignal.Add(GetHashedString("PreviousClickPosition.x"),
42
- NativeUtils.ConvertPxToDp(previousPosition.clickPosition.x)
43
- .ToString((IFormatProvider)CultureInfo.InvariantCulture));
44
- positionSignal.Add(GetHashedString("PreviousClickPosition.y"),
45
- NativeUtils.ConvertPxToDp(previousPosition.clickPosition.y)
46
- .ToString((IFormatProvider)CultureInfo.InvariantCulture));
47
- clickSignal = CreateImpressionSignal(adComponent, adComponents);
48
- // positionSignal.Add(GetHashedString(""), GetHashedString(""));
49
- signal.Add(GetHashedString("PositionSignal"), positionSignal);
50
- signal.Add(GetHashedString("ObjectTag"), adComponent.ObjectTag);
51
- clickSignal.Add(GetHashedString("Signal"), signal);
52
- return clickSignal;
53
- }
54
-
55
- public static Dictionary<string, object> CreateImpressionSignal(NativeAdObject adComponent,
56
- List<NativeAdObject> adComponents)
57
- {
58
- Dictionary<string, object> signal = new Dictionary<string, object>();
59
- Dictionary<string, string> adData = new Dictionary<string, string>();
60
- string version = BuildVersionString(NativeUtils.Version);
61
- adData.Add(GetHashedString("Version"), version);
62
- adData.Add(GetHashedString("InteractionTime"),
63
- adComponent.InteractionTime.ToString((IFormatProvider)CultureInfo.InvariantCulture));
64
- signal.Add(GetHashedString("AdData"), adData);
65
- // signal.Add(GetHashedString(""), CreateAdData(adComponents));
66
- return signal;
67
- }
68
-
69
- private static string GetHashedString(uint hash)
70
- {
71
- // Return the string representation of the hash
72
- return hash.ToString();
73
- }
74
-
75
- private static string GetHashedString(string text, string key = "")
76
- {
77
- if (String.IsNullOrEmpty(text))
78
- {
79
- return String.Empty;
80
- }
81
-
82
- // Uses SHA256 to create the hash
83
- using (var sha = new System.Security.Cryptography.SHA256Managed())
84
- {
85
- // Convert the string to a byte array first, to be processed
86
- byte[] textBytes = System.Text.Encoding.UTF8.GetBytes(text + key);
87
- byte[] hashBytes = sha.ComputeHash(textBytes);
88
-
89
- // Convert back to a string, removing the '-' that BitConverter adds
90
- string hash = BitConverter
91
- .ToString(hashBytes)
92
- .Replace("-", String.Empty);
93
-
94
- return hash;
95
- }
96
- }
97
-
98
- private static string Version
99
- {
100
- get
101
- {
102
- Version version = typeof(NativeAd).Assembly.GetName().Version;
103
- return string.Format("{0}.{1}.{2}", version.Major, version.Minor, version.Build);
104
- }
105
- }
106
-
107
- internal static string BuildVersionString(string nativePluginVersion = null)
108
- {
109
- StringBuilder stringBuilder = new StringBuilder("unity-");
110
- stringBuilder.Append(Version);
111
- if (!string.IsNullOrEmpty(nativePluginVersion))
112
- {
113
- stringBuilder.Append("-native-");
114
- stringBuilder.Append(nativePluginVersion);
115
- }
116
-
117
- return stringBuilder.ToString();
118
- }
119
- }
120
- }
@@ -1,11 +0,0 @@
1
- fileFormatVersion: 2
2
- guid: 97dd1a4fcb7444fe2adc8b5ac4ed21d0
3
- MonoImporter:
4
- externalObjects: {}
5
- serializedVersion: 2
6
- defaultReferences: []
7
- executionOrder: 0
8
- icon: {instanceID: 0}
9
- userData:
10
- assetBundleName:
11
- assetBundleVariant:
@@ -1,32 +0,0 @@
1
- using System;
2
- using Azerion.BlueStack.Common;
3
- using Azerion.BlueStack.Internal;
4
- using UnityEngine;
5
-
6
- internal class NativeClientFactoryManager
7
- {
8
- private static INativeClientFactory _nativeClientFactory;
9
- internal static INativeClientFactory GetNativeClientFactory()
10
- {
11
- if (NativeClientFactoryManager._nativeClientFactory == null)
12
- {
13
- string typeName;
14
- switch (Application.platform)
15
- {
16
- case RuntimePlatform.IPhonePlayer:
17
- typeName = "Azerion.BlueStack.Platforms.Android.ClientsFactory";
18
- break;
19
- case RuntimePlatform.Android:
20
- typeName = "Azerion.BlueStack.Platforms.iOS.ClientsFactory";
21
- break;
22
- default:
23
- typeName = "Azerion.BlueStack.Platforms.UnityEditor.ClientsFactory";
24
- break;
25
- }
26
- NativeClientFactoryManager._nativeClientFactory = (INativeClientFactory) Activator.CreateInstance(System.Type.GetType(typeName));
27
- }
28
- return NativeClientFactoryManager._nativeClientFactory;
29
- }
30
-
31
- internal static IAdLoaderClient CreateAdLoaderClient(AdLoaderClientArgs args) => NativeClientFactoryManager.GetNativeClientFactory().BuildAdLoaderClient(args);
32
- }
@@ -1,11 +0,0 @@
1
- fileFormatVersion: 2
2
- guid: 755720907efeb471ab3564825cbe407c
3
- MonoImporter:
4
- externalObjects: {}
5
- serializedVersion: 2
6
- defaultReferences: []
7
- executionOrder: 0
8
- icon: {instanceID: 0}
9
- userData:
10
- assetBundleName:
11
- assetBundleVariant: