@sentiance-react-native/core 6.4.0-rc.3 → 6.4.0

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.
@@ -1,10 +1,10 @@
1
1
  require 'json'
2
- package = JSON.parse(File.read(File.join(__dir__, '../package.json')))
2
+ package = JSON.parse(File.read(File.join(__dir__, './package.json')))
3
3
  sentiance_sdk_version = package['sdkVersions']['ios']['sentiance']
4
4
 
5
5
  Pod::Spec.new do |s|
6
6
  s.name = "RNSentianceCore"
7
- s.version = "6.4.0-rc.3"
7
+ s.version = "6.4.0"
8
8
  s.summary = "RNSentianceCore"
9
9
  s.description = <<-DESC
10
10
  RNSentianceCore
@@ -14,8 +14,8 @@ Pod::Spec.new do |s|
14
14
  # s.license = { :type => "MIT", :file => "FILE_LICENSE" }
15
15
  s.author = { "author" => "sdk@sentiance.com" }
16
16
  s.platform = :ios, "9.0"
17
- s.source = { :git => "https://github.com/sentiance/react-native-sentiance.git", :tag => "master" }
18
- s.source_files = "*.{h,m}"
17
+ s.source = { :git => "https://github.com/sentiance/react-native-sentiance.git", :tag => "v#{s.version}" }
18
+ s.source_files = "ios/*.{h,m}"
19
19
  s.requires_arc = true
20
20
  s.xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => '${PODS_ROOT}/SENTSDK' }
21
21
 
@@ -2,6 +2,7 @@
2
2
  #import <React/RCTBridgeModule.h>
3
3
  #import <React/RCTEventEmitter.h>
4
4
  #import <SENTSDK/SENTSDK.h>
5
+ #import <SENTSDK/SENTSDK-Swift.h>
5
6
 
6
7
  static NSString * _Nonnull const UserLinkEvent = @"SENTIANCE_USER_LINK_EVENT";
7
8
  static NSString * _Nonnull const SdkStatusUpdateEvent = @"SENTIANCE_STATUS_UPDATE_EVENT";
@@ -8,6 +8,7 @@ class SentianceEventEmitter extends NativeEventEmitter {
8
8
  const bindings = this.requireNativeBindings(nativeModule);
9
9
  this._addNativeListener = bindings.addNativeListener;
10
10
  this._removeNativeListener = bindings.removeNativeListener;
11
+ this._subscriptionsMap = {};
11
12
  }
12
13
 
13
14
  requireNativeBindings(nativeModule) {
@@ -32,16 +33,31 @@ class SentianceEventEmitter extends NativeEventEmitter {
32
33
  }
33
34
 
34
35
  async addListener(eventType, listener, context): EmitterSubscription {
36
+ if (!this._subscriptionsMap[eventType]) {
37
+ this._subscriptionsMap[eventType] = [];
38
+ }
39
+ const subscriptionsForType = this._subscriptionsMap[eventType];
40
+ const key = subscriptionsForType.length;
35
41
  const subscription = super.addListener(eventType, listener, context);
36
- await this._addNativeListener(eventType, subscription.key);
42
+ subscription.key = key;
43
+ subscriptionsForType.push(subscription);
44
+ await this._addNativeListener(eventType, key);
37
45
  return subscription;
38
46
  }
39
47
 
40
48
  async clearSubscription(eventType, subscription) {
49
+ const key = subscription.key;
50
+ const subscriptionsForType = this._subscriptionsMap[eventType];
51
+ if (subscriptionsForType) {
52
+ const targetSubIndex = subscriptionsForType.findIndex(sub => sub.key === key);
53
+ if (targetSubIndex !== -1) {
54
+ subscriptionsForType.splice(targetSubIndex, 1);
55
+ }
56
+ }
41
57
  if (super.removeSubscription != null) {
42
58
  super.removeSubscription(subscription);
43
59
  } else {
44
- // RN 0.64+ no longer provides a removeSubscription function
60
+ // RN 0.65+ no longer provides a removeSubscription function
45
61
  subscription.remove();
46
62
  }
47
63
  await this._removeNativeListener(eventType, subscription.key);
@@ -5,8 +5,9 @@ exports.createEventListener = async (eventName: String, emitter: SentianceEventE
5
5
  callback(data);
6
6
  };
7
7
  const subscription = await emitter.addListener(eventName, listener);
8
- subscription.remove = async function () {
9
- await emitter.clearSubscription(eventName, subscription);
10
- }
11
- return subscription;
12
- };
8
+ return {
9
+ key: subscription.key,
10
+ eventName,
11
+ remove: () => emitter.clearSubscription(eventName, subscription)
12
+ };
13
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentiance-react-native/core",
3
- "version": "6.4.0-rc.3",
3
+ "version": "6.4.0",
4
4
  "description": "React Native Sentiance core library",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",