@thealteroffice/react-native-adgeist 0.0.7 → 0.0.8

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/Adgeist.podspec CHANGED
@@ -16,7 +16,7 @@ Pod::Spec.new do |s|
16
16
  s.source_files = "ios/**/*.{h,m,mm,cpp,swift}"
17
17
  s.private_header_files = "ios/**/*.h"
18
18
 
19
- s.dependency "AdgeistKit", '= 0.0.3'
19
+ s.dependency "AdgeistKit", '= 0.0.4'
20
20
 
21
21
  # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
22
22
  # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
package/ios/Adgeist.mm CHANGED
@@ -20,6 +20,14 @@ RCT_EXPORT_MODULE(Adgeist)
20
20
  return self;
21
21
  }
22
22
 
23
+ RCT_EXPORT_METHOD(initializeSdk:(NSString *)customDomain
24
+ resolve:(RCTPromiseResolveBlock)resolve
25
+ reject:(RCTPromiseRejectBlock)reject)
26
+ {
27
+ [adgeist initializeSdkWithCustomDomain:customDomain
28
+ resolver:resolve
29
+ rejecter:reject];
30
+ }
23
31
 
24
32
  // Exported methods for JS
25
33
  RCT_EXPORT_METHOD(fetchCreative:(NSString *)apiKey
@@ -3,7 +3,25 @@ import AdgeistKit
3
3
  import React
4
4
 
5
5
  @objc public class AdgeistImpl: NSObject {
6
- private static let adGeist = AdgeistCore.shared
6
+ private var adgeistInstance: AdgeistCore?
7
+ private var getAd: FetchCreative?
8
+ private var postCreativeAnalytic: CreativeAnalytics?
9
+
10
+ @objc public func initializeSdk(
11
+ customDomain: String?,
12
+ resolver: @escaping RCTPromiseResolveBlock,
13
+ rejecter: @escaping RCTPromiseRejectBlock
14
+ ) {
15
+ do {
16
+ adgeistInstance = AdgeistCore.initialize(customDomain: customDomain ?? "bg-services-api.adgeist.ai")
17
+ getAd = adgeistInstance?.getCreative()
18
+ postCreativeAnalytic = adgeistInstance?.postCreativeAnalytics()
19
+ resolver("SDK initialized with domain: \(customDomain ?? "default")")
20
+ } catch {
21
+ rejecter("INIT_FAILED", "SDK initialization failed", error)
22
+ }
23
+ }
24
+
7
25
  @objc public func fetchCreative(
8
26
  apiKey: String,
9
27
  origin: String,
@@ -13,7 +31,12 @@ import React
13
31
  resolver: @escaping RCTPromiseResolveBlock,
14
32
  rejecter: @escaping RCTPromiseRejectBlock
15
33
  ) {
16
- AdgeistImpl.adGeist.getCreative().fetchCreative(
34
+ guard let getAd = getAd else {
35
+ rejecter("SDK_NOT_INITIALIZED", "SDK not initialized. Call initializeSdk() first.", nil)
36
+ return
37
+ }
38
+
39
+ getAd.fetchCreative(
17
40
  apiKey: apiKey,
18
41
  origin: origin,
19
42
  adSpaceId: adSpaceId,
@@ -50,7 +73,12 @@ import React
50
73
  resolver: @escaping RCTPromiseResolveBlock,
51
74
  rejecter: @escaping RCTPromiseRejectBlock
52
75
  ) {
53
- AdgeistImpl.adGeist.postCreativeAnalytics().sendTrackingData(
76
+ guard let postCreativeAnalytic = postCreativeAnalytic else {
77
+ rejecter("SDK_NOT_INITIALIZED", "SDK not initialized. Call initializeSdk() first.", nil)
78
+ return
79
+ }
80
+
81
+ postCreativeAnalytic.sendTrackingData(
54
82
  campaignId: campaignId,
55
83
  adSpaceId: adSpaceId,
56
84
  publisherId: publisherId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thealteroffice/react-native-adgeist",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "Publishers can integrate our SDK to connect their ad spaces to the AdGeist marketplace.",
5
5
  "main": "./lib/module/index.js",
6
6
  "module": "./lib/module/index.js",