com.azerion.bluestack 2.0.1 → 3.0.0-preview2

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 (98) hide show
  1. package/Editor/BlueStackDependencies.xml +1 -1
  2. package/Example/Azerion.BlueStack.Example.asmdef +16 -0
  3. package/Example/Azerion.BlueStack.Example.asmdef.meta +7 -0
  4. package/Example/Prefabs/NativeAd.prefab +908 -0
  5. package/Example/Prefabs/NativeAd.prefab.meta +7 -0
  6. package/Example/Prefabs/SmallNativeAd.prefab +739 -0
  7. package/Example/Prefabs/SmallNativeAd.prefab.meta +7 -0
  8. package/Example/Prefabs.meta +8 -0
  9. package/Example/Scripts/NativeAdManager.cs +208 -0
  10. package/Example/Scripts/NativeAdManager.cs.meta +11 -0
  11. package/Example/Scripts/SmallNativeAdManager.cs +181 -0
  12. package/Example/Scripts/SmallNativeAdManager.cs.meta +11 -0
  13. package/Example/Scripts.meta +8 -0
  14. package/Example.meta +8 -0
  15. package/Plugins/Android/{bluestack-unity-android-bridge-1.0.1.aar → bluestack-unity-android-bridge-2.0.0-preview1.aar} +0 -0
  16. package/Plugins/Android/{bluestack-unity-android-bridge-1.0.1.aar.meta → bluestack-unity-android-bridge-2.0.0-preview1.aar.meta} +1 -1
  17. package/Plugins/iOS/BSUInterface.h +14 -0
  18. package/Plugins/iOS/BSUInterface.m +83 -1
  19. package/Plugins/iOS/BSUNativeAd.h +32 -0
  20. package/Plugins/iOS/BSUNativeAd.h.meta +27 -0
  21. package/Plugins/iOS/BSUNativeAd.m +82 -0
  22. package/Plugins/iOS/BSUNativeAd.m.meta +37 -0
  23. package/Plugins/iOS/BSUTypes.h +12 -0
  24. package/Runtime/API/BlueStackAds.cs +4 -2
  25. package/Runtime/API/NativeAd/NativeAd.cs +182 -0
  26. package/Runtime/API/NativeAd/NativeAd.cs.meta +3 -0
  27. package/Runtime/API/NativeAd/NativeAdEventArgs.cs +14 -0
  28. package/Runtime/API/NativeAd/NativeAdEventArgs.cs.meta +11 -0
  29. package/Runtime/API/NativeAd/NativeAdInteractionHandler.cs +157 -0
  30. package/Runtime/API/NativeAd/NativeAdInteractionHandler.cs.meta +11 -0
  31. package/Runtime/API/NativeAd/NativeAdInteractionUtils.cs +122 -0
  32. package/Runtime/API/NativeAd/NativeAdInteractionUtils.cs.meta +11 -0
  33. package/Runtime/API/NativeAd/NativeAdLoader.cs +57 -0
  34. package/Runtime/API/NativeAd/NativeAdLoader.cs.meta +11 -0
  35. package/Runtime/API/NativeAd/NativeAdObject.cs +520 -0
  36. package/Runtime/API/NativeAd/NativeAdObject.cs.meta +11 -0
  37. package/Runtime/API/NativeAd/NativeAdType.cs +8 -0
  38. package/Runtime/API/NativeAd/NativeAdType.cs.meta +11 -0
  39. package/Runtime/API/NativeAd/NativeAssetID.cs +30 -0
  40. package/Runtime/API/NativeAd/NativeAssetID.cs.meta +11 -0
  41. package/Runtime/API/NativeAd/NativeClientFactoryManager.cs +32 -0
  42. package/Runtime/API/NativeAd/NativeClientFactoryManager.cs.meta +11 -0
  43. package/Runtime/API/NativeAd.meta +8 -0
  44. package/Runtime/Common/NativeAd/AdLoaderClientArgs.cs +16 -0
  45. package/Runtime/Common/NativeAd/AdLoaderClientArgs.cs.meta +11 -0
  46. package/Runtime/Common/NativeAd/AdsEventExecutor.cs +84 -0
  47. package/Runtime/Common/NativeAd/AdsEventExecutor.cs.meta +11 -0
  48. package/Runtime/Common/NativeAd/DummyNativeClient.cs +61 -0
  49. package/Runtime/Common/NativeAd/DummyNativeClient.cs.meta +11 -0
  50. package/Runtime/Common/NativeAd/NativeClientEventArgs.cs +10 -0
  51. package/Runtime/Common/NativeAd/NativeClientEventArgs.cs.meta +11 -0
  52. package/Runtime/Common/NativeAd/NativeUtils.cs +117 -0
  53. package/Runtime/Common/NativeAd/NativeUtils.cs.meta +11 -0
  54. package/Runtime/Internal/IClientsFactory.cs +5 -2
  55. package/Runtime/Internal/NativeAd/IAdLoaderClient.cs +24 -0
  56. package/Runtime/Internal/NativeAd/IAdLoaderClient.cs.meta +11 -0
  57. package/Runtime/Internal/NativeAd/INativeAdClient.cs +25 -0
  58. package/Runtime/Internal/NativeAd/INativeAdClient.cs.meta +3 -0
  59. package/Runtime/Internal/NativeAd/INativeAdInteractionHandlerClient.cs +15 -0
  60. package/Runtime/Internal/NativeAd/INativeAdInteractionHandlerClient.cs.meta +11 -0
  61. package/Runtime/Internal/NativeAd/INativeClientFactory.cs +9 -0
  62. package/Runtime/Internal/NativeAd/INativeClientFactory.cs.meta +11 -0
  63. package/Runtime/Internal/NativeAd.meta +8 -0
  64. package/Runtime/Platforms/Android/AndroidJavaObjectFactory.cs +9 -1
  65. package/Runtime/Platforms/Android/BannerAdClient.cs +1 -1
  66. package/Runtime/Platforms/Android/BlueStackClient.cs +1 -1
  67. package/Runtime/Platforms/Android/BlueStackErrorUtils.cs +1 -1
  68. package/Runtime/Platforms/Android/BlueStackNativeClassNames.cs +4 -1
  69. package/Runtime/Platforms/Android/ClientsFactory.cs +12 -1
  70. package/Runtime/Platforms/Android/InitializationStatusClient.cs +1 -1
  71. package/Runtime/Platforms/Android/InterstitialAdClient.cs +1 -1
  72. package/Runtime/Platforms/Android/NativeAdClient.cs +108 -0
  73. package/Runtime/Platforms/Android/NativeAdClient.cs.meta +3 -0
  74. package/Runtime/Platforms/Android/PreferenceClient.cs +1 -1
  75. package/Runtime/Platforms/Android/RewardedVideoAdClient.cs +1 -1
  76. package/Runtime/Platforms/Unity/BannerAdClient.cs +1 -0
  77. package/Runtime/Platforms/Unity/ClientsFactory.cs +6 -1
  78. package/Runtime/Platforms/Unity/NativeAdClient.cs +101 -0
  79. package/Runtime/Platforms/Unity/NativeAdClient.cs.meta +3 -0
  80. package/Runtime/Platforms/Unity/RewardedTimer.cs +2 -2
  81. package/Runtime/Platforms/Unity/Utils.cs +73 -0
  82. package/Runtime/Platforms/Unity/Utils.cs.meta +11 -0
  83. package/Runtime/Platforms/iOS/BannerAdClient.cs +1 -1
  84. package/Runtime/Platforms/iOS/BlueStackClient.cs +1 -1
  85. package/Runtime/Platforms/iOS/BlueStackErrorUtils.cs +1 -1
  86. package/Runtime/Platforms/iOS/ClientsFactory.cs +13 -1
  87. package/Runtime/Platforms/iOS/Externs.cs +49 -1
  88. package/Runtime/Platforms/iOS/InitializationStatusClient.cs +1 -1
  89. package/Runtime/Platforms/iOS/InterstitialAdClient.cs +1 -1
  90. package/Runtime/Platforms/iOS/NativeAdClient.cs +156 -0
  91. package/Runtime/Platforms/iOS/NativeAdClient.cs.meta +3 -0
  92. package/Runtime/Platforms/iOS/PreferenceClient.cs +1 -1
  93. package/Runtime/Platforms/iOS/RewardedVideoAdClient.cs +1 -1
  94. package/Runtime/Platforms/iOS/Utils.cs +1 -1
  95. package/Runtime/Utilities/MiniJSON.cs +581 -0
  96. package/Runtime/Utilities/MiniJSON.cs.meta +11 -0
  97. package/Runtime/Utilities.meta +8 -0
  98. package/package.json +1 -1
@@ -0,0 +1,108 @@
1
+ #if UNITY_ANDROID //&& !UNITY_EDITOR
2
+ using System;
3
+ using Azerion.BlueStack.API;
4
+ using Azerion.BlueStack.Internal;
5
+ using UnityEngine;
6
+
7
+ namespace Azerion.BlueStack.Platforms.Android
8
+ {
9
+ public class NativeAdClient : AndroidJavaProxy, INativeAdClient
10
+ {
11
+ private readonly AndroidJavaObject _unityNativeAd;
12
+ private readonly BlueStackErrorUtils _blueStackErrorUtils;
13
+
14
+ public NativeAdClient(AndroidJavaObjectFactory androidJavaObjectFactory,
15
+ BlueStackErrorUtils blueStackErrorUtils) : base(BlueStackNativeClassNames.UnityNativeAdListener)
16
+ {
17
+ _unityNativeAd = androidJavaObjectFactory.CreateUnityNativeAdAndroidJavaObject(this);
18
+ _blueStackErrorUtils = blueStackErrorUtils;
19
+ }
20
+
21
+ public event EventHandler<EventArgs> OnNativeAdDidLoad;
22
+ public event EventHandler<BlueStackError> OnNativeAdDidFail;
23
+
24
+ public void Create(string placementId)
25
+ {
26
+ _unityNativeAd.Call("create", placementId);
27
+ }
28
+
29
+ public void Load()
30
+ {
31
+ _unityNativeAd.Call("load", null);
32
+ }
33
+
34
+ public void Load(IPreferenceClient iPreferenceClient)
35
+ {
36
+ PreferenceClient preferenceClient = (PreferenceClient)iPreferenceClient;
37
+ _unityNativeAd.Call("load", preferenceClient.getMNGPreference());
38
+ }
39
+
40
+ public void Show()
41
+ {
42
+ _unityNativeAd.Call("show");
43
+ }
44
+
45
+ public string GetTitle()
46
+ {
47
+ return _unityNativeAd.Call<string>("getTitle");
48
+ }
49
+
50
+ public string GetBodyText()
51
+ {
52
+ return _unityNativeAd.Call<string>("getBodyText");
53
+ }
54
+
55
+ public string GetCallToActionText()
56
+ {
57
+ return _unityNativeAd.Call<string>("getCTAText");
58
+ }
59
+
60
+ public byte[] GetBadgeBytes()
61
+ {
62
+ sbyte[] sBytes = _unityNativeAd.Call<sbyte[]>("getBadgeBytes");
63
+ byte[] bytes = (byte[]) (Array)sBytes;
64
+ Debug.Log("GetBadgeBytes ToString: " + BitConverter.ToString(bytes));
65
+ return bytes;
66
+ }
67
+
68
+ public string GetBadge()
69
+ {
70
+ return "Ad";
71
+ }
72
+
73
+ public string GetIconUrl()
74
+ {
75
+ return _unityNativeAd.Call<string>("getAdIconUrl");
76
+ }
77
+
78
+ public string GetCoverImageUrl()
79
+ {
80
+ return _unityNativeAd.Call<string>("getAdCoverImageUrl");
81
+ }
82
+
83
+ public string GetClickUrl()
84
+ {
85
+ return _unityNativeAd.Call<string>("getClickUrl");
86
+ }
87
+
88
+ public void Destroy()
89
+ {
90
+ _unityNativeAd.Call("destroy");
91
+ _unityNativeAd.Dispose();
92
+ }
93
+
94
+ public void onNativeAdDidLoad()
95
+ {
96
+ Debug.Log("NativeAdClient.onNativeAdDidLoad");
97
+ OnNativeAdDidLoad?.Invoke(this, EventArgs.Empty);
98
+ }
99
+
100
+ public void onNativeAdDidFail(AndroidJavaObject adsErrorJavaObject)
101
+ {
102
+ OnNativeAdDidFail?.Invoke(this,
103
+ _blueStackErrorUtils.CreateBlueStackErrorFromJavaObject(adsErrorJavaObject));
104
+ }
105
+
106
+ }
107
+ }
108
+ #endif
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: 2f8da5babed024db993e1bcc3dd722bd
3
+ timeCreated: 1669708370
@@ -1,4 +1,4 @@
1
- #if UNITY_ANDROID && !UNITY_EDITOR
1
+ #if UNITY_ANDROID //&& !UNITY_EDITOR
2
2
  using Azerion.BlueStack.API;
3
3
  using Azerion.BlueStack.Internal;
4
4
  using UnityEngine;
@@ -1,4 +1,4 @@
1
- #if UNITY_ANDROID && !UNITY_EDITOR
1
+ #if UNITY_ANDROID //&& !UNITY_EDITOR
2
2
  using System;
3
3
  using Azerion.BlueStack.API.Rewarded;
4
4
  using Azerion.BlueStack.API;
@@ -51,6 +51,7 @@ namespace Azerion.BlueStack.Platforms.UnityEditor
51
51
  // Loads a banner and adds it to the view hierarchy.
52
52
  public void Load(AdSize adSize)
53
53
  {
54
+ Debug.Log("Load banner AdSize: " + adSize.ToString());
54
55
  this._adSize = adSize;
55
56
 
56
57
  LoadAndSetAdPrefab(_prefabAds[adSize]);
@@ -24,7 +24,12 @@ namespace Azerion.BlueStack.Platforms.UnityEditor
24
24
  {
25
25
  return new BannerAdClient();
26
26
  }
27
-
27
+
28
+ public INativeAdClient CreateNativeAdClient()
29
+ {
30
+ return new NativeAdClient();
31
+ }
32
+
28
33
  public IPreferenceClient CreateIPreferenceClient()
29
34
  {
30
35
  return new PreferenceClient();
@@ -0,0 +1,101 @@
1
+ #if UNITY_EDITOR
2
+ using System;
3
+ using Azerion.BlueStack.API;
4
+ using Azerion.BlueStack.Internal;
5
+ using System.Collections.Generic;
6
+ using UnityEngine;
7
+ using UnityEngine.UI;
8
+
9
+ namespace Azerion.BlueStack.Platforms.UnityEditor
10
+ {
11
+ public class NativeAdClient: BaseAdClient, INativeAdClient, IDisposable
12
+ {
13
+ private string _placementId;
14
+
15
+ // Fires when the Native ad is loaded
16
+ public event EventHandler<EventArgs> OnNativeAdDidLoad;
17
+ // Fires when the Native ad has failed to load
18
+ public event EventHandler<BlueStackError> OnNativeAdDidFail;
19
+
20
+ // Creats a Native Ad
21
+ public void Create(string placementId)
22
+ {
23
+ this._placementId = placementId;
24
+ }
25
+
26
+ // Loads a Native Ad
27
+ public void Load()
28
+ {
29
+ //if (adPrefab != null)
30
+ //{
31
+ // OnNativeAdDidLoad?.Invoke(this, EventArgs.Empty);
32
+ //}
33
+ //else
34
+ //{
35
+ // OnNativeAdDidFail?.Invoke(this, new BlueStackError(-1, "Ad could not be loaded"));
36
+ //}
37
+
38
+ OnNativeAdDidLoad?.Invoke(this, EventArgs.Empty);
39
+ }
40
+
41
+ // Loads an Interstitial Ad with preference, NOT implemented for editor
42
+ public void Load(IPreferenceClient iPreferenceClient)
43
+ {
44
+ Load();
45
+ }
46
+
47
+ public string GetTitle()
48
+ {
49
+ return "Native Test Title";
50
+ }
51
+
52
+ public string GetBodyText()
53
+ {
54
+ return "Native Test Body Text: BlueStack supports native ads, that allow you to retrieve the metadata of ad campaigns and present the ads yourself, within the context of your app, using your own art style. You are fully responsible for rendering the ad views using the information we supply. Native ads however offer methods to help you register impressions and clicks on your custom view.";
55
+ }
56
+
57
+ public string GetCallToActionText()
58
+ {
59
+ return "Action";
60
+ }
61
+
62
+ public byte[] GetBadgeBytes()
63
+ {
64
+ return new byte[] { };
65
+ }
66
+
67
+ public string GetBadge()
68
+ {
69
+ return "Ad";
70
+ }
71
+
72
+ public string GetIconUrl()
73
+ {
74
+ return "https://creative.mng-ads.com/10/10394-15539.jpg";
75
+ }
76
+
77
+ public string GetCoverImageUrl()
78
+ {
79
+ return "https://creative.mng-ads.com/10/10394-15540.jpg";
80
+ }
81
+
82
+ public string GetClickUrl()
83
+ {
84
+ return "https://developers.bluestack.app/";
85
+ }
86
+
87
+ // Destroys a Native Ad
88
+ public void Destroy()
89
+ {
90
+ this._placementId = null;
91
+ AdBehaviour.DestroyAd(dummyAd);
92
+ adPrefab = null;
93
+ }
94
+
95
+ public void Dispose()
96
+ {
97
+ Destroy();
98
+ }
99
+ }
100
+ }
101
+ #endif
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: de07796c0dd38406f97f0c4b651231e6
3
+ timeCreated: 1671451395
@@ -1,5 +1,5 @@
1
- #if UNITY_EDITOR
2
- using System;
1
+ #if UNITY_EDITOR
2
+ using System;
3
3
  using Azerion.BlueStack.API.Rewarded;
4
4
  using UnityEngine;
5
5
  using UnityEngine.UI;
@@ -0,0 +1,73 @@
1
+ #if UNITY_EDITOR
2
+ using System;
3
+ using System.Collections.Generic;
4
+ using System.Runtime.InteropServices;
5
+ using Azerion.BlueStack.API;
6
+
7
+ namespace Azerion.BlueStack.Platforms.UnityEditor
8
+ {
9
+ internal class Utils
10
+ {
11
+ public static byte[] ConvertToByteArray(string value)
12
+ {
13
+ byte[] bytes = null;
14
+ if (String.IsNullOrEmpty(value))
15
+ bytes = new byte[] { };
16
+ else
17
+ {
18
+ int stringLength = value.Length;
19
+ int characterIndex = (value.StartsWith("0x", StringComparison.Ordinal)) ? 2 : 0; // Does the string define leading HEX indicator '0x'. Adjust starting index accordingly.
20
+ int numberOfCharacters = stringLength - characterIndex;
21
+
22
+ bool addLeadingZero = false;
23
+ if (0 != (numberOfCharacters % 2))
24
+ {
25
+ addLeadingZero = true;
26
+
27
+ numberOfCharacters += 1; // Leading '0' has been striped from the string presentation.
28
+ }
29
+
30
+ bytes = new byte[numberOfCharacters / 2]; // Initialize our byte array to hold the converted string.
31
+
32
+ int writeIndex = 0;
33
+ if (addLeadingZero)
34
+ {
35
+ bytes[writeIndex++] = FromCharacterToByte(value[characterIndex], characterIndex);
36
+ characterIndex += 1;
37
+ }
38
+
39
+ for (int readIndex = characterIndex; readIndex < value.Length; readIndex += 2)
40
+ {
41
+ byte upper = FromCharacterToByte(value[readIndex], readIndex, 4);
42
+ byte lower = FromCharacterToByte(value[readIndex + 1], readIndex + 1);
43
+
44
+ bytes[writeIndex++] = (byte)(upper | lower);
45
+ }
46
+ }
47
+
48
+ return bytes;
49
+ }
50
+
51
+ private static byte FromCharacterToByte(char character, int index, int shift = 0)
52
+ {
53
+ byte value = (byte)character;
54
+ if (((0x40 < value) && (0x47 > value)) || ((0x60 < value) && (0x67 > value)))
55
+ {
56
+ if (0x40 == (0x40 & value))
57
+ {
58
+ if (0x20 == (0x20 & value))
59
+ value = (byte)(((value + 0xA) - 0x61) << shift);
60
+ else
61
+ value = (byte)(((value + 0xA) - 0x41) << shift);
62
+ }
63
+ }
64
+ else if ((0x29 < value) && (0x40 > value))
65
+ value = (byte)((value - 0x30) << shift);
66
+ else
67
+ throw new InvalidOperationException($"Character '{character}' at index '{index}' is not valid alphanumeric character.");
68
+
69
+ return value;
70
+ }
71
+ }
72
+ }
73
+ #endif
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 4279f7aa2246744fcbfb6a5805183707
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -1,4 +1,4 @@
1
- #if UNITY_IOS && !UNITY_EDITOR
1
+ #if UNITY_IOS //&& !UNITY_EDITOR
2
2
  using System;
3
3
  using System.Runtime.InteropServices;
4
4
  using Azerion.BlueStack.API;
@@ -1,4 +1,4 @@
1
- #if UNITY_IOS && !UNITY_EDITOR
1
+ #if UNITY_IOS //&& !UNITY_EDITOR
2
2
  using System;
3
3
  using System.Runtime.InteropServices;
4
4
  using Azerion.BlueStack.API;
@@ -1,4 +1,4 @@
1
- #if UNITY_IOS && !UNITY_EDITOR
1
+ #if UNITY_IOS //&& !UNITY_EDITOR
2
2
  using System;
3
3
  using Azerion.BlueStack.API;
4
4
 
@@ -1,4 +1,4 @@
1
- #if UNITY_IOS && !UNITY_EDITOR
1
+ #if UNITY_IOS //&& !UNITY_EDITOR
2
2
  using System;
3
3
  using System.Reflection;
4
4
  using Azerion.BlueStack.Internal;
@@ -53,6 +53,18 @@ namespace Azerion.BlueStack.Platforms.iOS
53
53
  " on non-iOS runtime");
54
54
  }
55
55
 
56
+ public INativeAdClient CreateNativeAdClient()
57
+ {
58
+
59
+ if (Application.platform == RuntimePlatform.IPhonePlayer)
60
+ {
61
+ return new NativeAdClient();
62
+ }
63
+
64
+ throw new InvalidOperationException(@"Called " + MethodBase.GetCurrentMethod()?.Name +
65
+ " on non-iOS runtime");
66
+ }
67
+
56
68
  public IPreferenceClient CreateIPreferenceClient()
57
69
  {
58
70
  if (Application.platform == RuntimePlatform.IPhonePlayer)
@@ -1,4 +1,4 @@
1
- #if UNITY_IOS && !UNITY_EDITOR
1
+ #if UNITY_IOS //&& !UNITY_EDITOR
2
2
  using System;
3
3
  using System.Runtime.InteropServices;
4
4
 
@@ -192,6 +192,54 @@ namespace Azerion.BlueStack.Platforms.iOS
192
192
  BannerAdClient.BSUOnBannerDisplayCallback onBannerDisplayCallback
193
193
  );
194
194
  #endregion
195
+
196
+ #region NativeAd
197
+
198
+ [DllImport("__Internal")]
199
+ internal static extern IntPtr BSUCreateNativeAd(
200
+ IntPtr bannerClient, string placementId);
201
+
202
+ [DllImport("__Internal")]
203
+ internal static extern void BSULoadNativeAd(IntPtr native);
204
+
205
+ [DllImport("__Internal")]
206
+ internal static extern void BSULoadNativeAdWithPreference(IntPtr native, IntPtr preferencePtr);
207
+
208
+ [DllImport("__Internal")]
209
+ internal static extern string BSUNativeAdGetTitle(IntPtr native);
210
+
211
+ [DllImport("__Internal")]
212
+ internal static extern string BSUNativeAdGetBodyText(IntPtr native);
213
+
214
+ [DllImport("__Internal")]
215
+ internal static extern string BSUNativeAdGetCTAText(IntPtr native);
216
+
217
+ // [DllImport("__Internal")]
218
+ // internal static extern byte[] BSUNativeAdGetBadge(IntPtr native);
219
+
220
+ [DllImport("__Internal")]
221
+ internal static extern string BSUNativeAdGetBadge(IntPtr native);
222
+
223
+ [DllImport("__Internal")]
224
+ internal static extern string BSUNativeAdGetCoverImageUrl(IntPtr native);
225
+
226
+ [DllImport("__Internal")]
227
+ internal static extern string BSUNativeAdGetIconUrl(IntPtr native);
228
+
229
+ [DllImport("__Internal")]
230
+ internal static extern string BSUNativeAdGetClickUrl(IntPtr native);
231
+
232
+ [DllImport("__Internal")]
233
+ internal static extern void BSUDestroyNativeAd(IntPtr native);
234
+
235
+ [DllImport("__Internal")]
236
+ internal static extern void BSUSetNativeAdCallbacks(
237
+ IntPtr bannerAd,
238
+ NativeAdClient.BSUOnNativeAdDidLoadCallback onNativeAdDidLoadCallback,
239
+ NativeAdClient.BSUOnNativeAdDidFailedCallback onNativeAdDidFailedCallback
240
+ );
241
+ #endregion
242
+
195
243
  }
196
244
  }
197
245
  #endif
@@ -1,4 +1,4 @@
1
- #if UNITY_IOS && !UNITY_EDITOR
1
+ #if UNITY_IOS //&& !UNITY_EDITOR
2
2
  using System;
3
3
  using System.Collections.Generic;
4
4
  using Azerion.BlueStack.API;
@@ -1,4 +1,4 @@
1
- #if UNITY_IOS && !UNITY_EDITOR
1
+ #if UNITY_IOS //&& !UNITY_EDITOR
2
2
  using System;
3
3
  using System.Runtime.InteropServices;
4
4
  using Azerion.BlueStack.API;
@@ -0,0 +1,156 @@
1
+ #if UNITY_IOS //&& !UNITY_EDITOR
2
+ using System;
3
+ using System.Runtime.InteropServices;
4
+ using Azerion.BlueStack.API;
5
+ using Azerion.BlueStack.Internal;
6
+
7
+ namespace Azerion.BlueStack.Platforms.iOS
8
+ {
9
+ public class NativeAdClient : INativeAdClient, IDisposable
10
+ {
11
+ private IntPtr _nativeAdPtr;
12
+ private IntPtr _nativeAdClientPtr;
13
+
14
+ #region NativeAd callback types
15
+
16
+ internal delegate void BSUOnNativeAdDidLoadCallback(IntPtr nativeClient);
17
+ internal delegate void BSUOnNativeAdDidFailedCallback(IntPtr nativeClient, IntPtr error);
18
+
19
+ #endregion
20
+
21
+ // This property should be used when setting the nativeViewPtr.
22
+ private IntPtr NativeAdPtr
23
+ {
24
+ get => this._nativeAdPtr;
25
+
26
+ set
27
+ {
28
+ Externs.BSURelease(this._nativeAdPtr);
29
+ this._nativeAdPtr = value;
30
+ }
31
+ }
32
+
33
+ #region Native callback methods
34
+
35
+ [AOT.MonoPInvokeCallback(typeof(BSUOnNativeAdDidLoadCallback))]
36
+ private static void OnNativeAdDidLoadCallback(IntPtr bannerClient)
37
+ {
38
+ NativeAdClient client = IntPtrToNativeAdClient(bannerClient);
39
+ if (client.OnNativeAdDidLoad != null)
40
+ {
41
+ client.OnNativeAdDidLoad(client, EventArgs.Empty);
42
+ }
43
+ }
44
+
45
+ [AOT.MonoPInvokeCallback(typeof(BSUOnNativeAdDidFailedCallback))]
46
+ private static void OnNativeAdDidFailCallback(IntPtr nativeClient, IntPtr error)
47
+ {
48
+ NativeAdClient client = IntPtrToNativeAdClient(nativeClient);
49
+ if (client.OnNativeAdDidFail != null)
50
+ {
51
+ client.OnNativeAdDidFail(client, BlueStackErrorUtils.CreateFromIntPtr(error));
52
+ }
53
+ }
54
+
55
+ private static NativeAdClient IntPtrToNativeAdClient(IntPtr nativeClient)
56
+ {
57
+ GCHandle handle = (GCHandle)nativeClient;
58
+ return handle.Target as NativeAdClient;
59
+ }
60
+
61
+ #endregion
62
+
63
+ public void Destroy()
64
+ {
65
+ this.DestroyNativeAd();
66
+ }
67
+
68
+ // Destroys the banner ad.
69
+ private void DestroyNativeAd()
70
+ {
71
+ Externs.BSUDestroyNativeAd(this.NativeAdPtr);
72
+ this.NativeAdPtr = IntPtr.Zero;
73
+ }
74
+ public void Dispose()
75
+ {
76
+ this.DestroyNativeAd();
77
+ ((GCHandle) this._nativeAdClientPtr).Free();
78
+ }
79
+
80
+ ~NativeAdClient()
81
+ {
82
+ this.Dispose();
83
+ }
84
+
85
+ public event EventHandler<EventArgs> OnNativeAdDidLoad;
86
+ public event EventHandler<BlueStackError> OnNativeAdDidFail;
87
+
88
+ public void Create(string placementId)
89
+ {
90
+ this._nativeAdClientPtr = (IntPtr) GCHandle.Alloc(this);
91
+
92
+ this.NativeAdPtr = Externs.BSUCreateNativeAd(
93
+ this._nativeAdClientPtr, placementId);
94
+
95
+ Externs.BSUSetNativeAdCallbacks(
96
+ this.NativeAdPtr,
97
+ OnNativeAdDidLoadCallback,
98
+ OnNativeAdDidFailCallback
99
+ );
100
+ }
101
+
102
+ public void Load()
103
+ {
104
+ Externs.BSULoadNativeAd(this.NativeAdPtr);
105
+ }
106
+
107
+ public void Load(IPreferenceClient iPreferenceClient)
108
+ {
109
+ PreferenceClient preferenceClient = (PreferenceClient)iPreferenceClient;
110
+ Externs.BSULoadNativeAdWithPreference(this.NativeAdPtr, preferenceClient.GetPreferenceClientPtr());
111
+ }
112
+
113
+ public string GetTitle()
114
+ {
115
+ return Externs.BSUNativeAdGetTitle(this.NativeAdPtr);
116
+ }
117
+
118
+ public string GetBodyText()
119
+ {
120
+ return Externs.BSUNativeAdGetBodyText(this.NativeAdPtr);
121
+ }
122
+
123
+ public string GetCallToActionText()
124
+ {
125
+ return Externs.BSUNativeAdGetCTAText(this.NativeAdPtr);
126
+ }
127
+
128
+ public byte[] GetBadgeBytes()
129
+ {
130
+ return Array.Empty<byte>();
131
+ }
132
+
133
+ public string GetBadge()
134
+ {
135
+ return Externs.BSUNativeAdGetBadge(this.NativeAdPtr);
136
+ }
137
+
138
+ public string GetCoverImageUrl()
139
+ {
140
+ return Externs.BSUNativeAdGetCoverImageUrl(this.NativeAdPtr);
141
+ }
142
+
143
+ public string GetIconUrl()
144
+ {
145
+ return Externs.BSUNativeAdGetIconUrl(this.NativeAdPtr);
146
+ }
147
+
148
+ public string GetClickUrl()
149
+ {
150
+ return Externs.BSUNativeAdGetClickUrl(this.NativeAdPtr);
151
+ }
152
+
153
+ }
154
+ }
155
+
156
+ #endif
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: 96ff2202bdb1a42509c7721912805ce4
3
+ timeCreated: 1670479013
@@ -1,4 +1,4 @@
1
- #if UNITY_IOS && !UNITY_EDITOR
1
+ #if UNITY_IOS //&& !UNITY_EDITOR
2
2
  using System;
3
3
  using Azerion.BlueStack.API;
4
4
  using Azerion.BlueStack.Internal;
@@ -1,4 +1,4 @@
1
- #if UNITY_IOS && !UNITY_EDITOR
1
+ #if UNITY_IOS //&& !UNITY_EDITOR
2
2
  using System;
3
3
  using System.Runtime.InteropServices;
4
4
  using Azerion.BlueStack.API;
@@ -1,4 +1,4 @@
1
- #if UNITY_IOS && !UNITY_EDITOR
1
+ #if UNITY_IOS //&& !UNITY_EDITOR
2
2
  using System;
3
3
  using System.Collections.Generic;
4
4
  using System.Runtime.InteropServices;