Skip to content

Commit a0ebf07

Browse files
authored
iOS main thread for all functions and version updated. (#50)
* iOS main thread for all functions and version updated. * Redundant main thread call removed from init.
1 parent 5d1967b commit a0ebf07

File tree

6 files changed

+34
-31
lines changed

6 files changed

+34
-31
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 20.11.5
2+
* iOS thread safety added to make all function calls on main thread.
3+
14
## 20.11.4
25
* Android session start issue fixed.
36
* Updated underlying android SDK to 20.11.5

CountlyReactNative.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'CountlyReactNative'
3-
s.version = '20.11.4'
3+
s.version = '20.11.5'
44
s.license = {
55
:type => 'COMMUNITY',
66
:text => <<-LICENSE

android/src/main/java/ly/count/android/sdk/react/CountlyReactNative.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public String toString(){
7474
public class CountlyReactNative extends ReactContextBaseJavaModule implements LifecycleEventListener {
7575

7676
public static final String TAG = "CountlyRNPlugin";
77-
private String COUNTLY_RN_SDK_VERSION_STRING = "20.11.4";
77+
private String COUNTLY_RN_SDK_VERSION_STRING = "20.11.5";
7878
private String COUNTLY_RN_SDK_NAME = "js-rnb-android";
7979

8080
private static CountlyConfig config = new CountlyConfig();

example/install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ rm App.js
1111
curl https://raw.githubusercontent.com/Countly/countly-sdk-react-native-bridge/master/example/App.js --output App.js
1212
curl https://raw.githubusercontent.com/Countly/countly-sdk-react-native-bridge/master/example/Example.js --output Example.js
1313

14-
14+
1515

1616
cd ./ios
1717
pod install

ios/src/CountlyReactNative.m

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ @interface CountlyFeedbackWidget ()
2121
+ (CountlyFeedbackWidget *)createWithDictionary:(NSDictionary *)dictionary;
2222
@end
2323

24-
NSString* const kCountlyReactNativeSDKVersion = @"20.11.4";
24+
NSString* const kCountlyReactNativeSDKVersion = @"20.11.5";
2525
NSString* const kCountlyReactNativeSDKName = @"js-rnb-ios";
2626

2727
CountlyConfig* config = nil;
@@ -44,35 +44,32 @@ @implementation CountlyReactNative
4444
initWithResolver:(RCTPromiseResolveBlock)resolve
4545
rejecter:(RCTPromiseRejectBlock)reject)
4646
{
47-
NSString* serverurl = [arguments objectAtIndex:0];
48-
NSString* appkey = [arguments objectAtIndex:1];
49-
NSString* deviceID = [arguments objectAtIndex:2];
50-
51-
if (config == nil){
52-
config = CountlyConfig.new;
53-
}
54-
55-
if(deviceID != nil && deviceID != (NSString *)[NSNull null] && ![deviceID isEqual: @""]){
56-
config.deviceID = deviceID;
57-
}
58-
config.appKey = appkey;
59-
config.host = serverurl;
47+
dispatch_async(dispatch_get_main_queue(), ^ {
48+
NSString* serverurl = [arguments objectAtIndex:0];
49+
NSString* appkey = [arguments objectAtIndex:1];
50+
NSString* deviceID = [arguments objectAtIndex:2];
6051

61-
CountlyCommon.sharedInstance.SDKName = kCountlyReactNativeSDKName;
62-
CountlyCommon.sharedInstance.SDKVersion = kCountlyReactNativeSDKVersion;
63-
if(enablePushNotifications) {
64-
[self addCountlyFeature:CLYPushNotifications];
65-
}
52+
if (config == nil){
53+
config = CountlyConfig.new;
54+
}
55+
56+
if(deviceID != nil && deviceID != (NSString *)[NSNull null] && ![deviceID isEqual: @""]){
57+
config.deviceID = deviceID;
58+
}
59+
config.appKey = appkey;
60+
config.host = serverurl;
6661

67-
if (serverurl != nil && [serverurl length] > 0) {
68-
dispatch_async(dispatch_get_main_queue(), ^
69-
{
70-
[[Countly sharedInstance] startWithConfig:config];
71-
72-
resolve(@"Success");
73-
});
74-
}
62+
CountlyCommon.sharedInstance.SDKName = kCountlyReactNativeSDKName;
63+
CountlyCommon.sharedInstance.SDKVersion = kCountlyReactNativeSDKVersion;
64+
if(enablePushNotifications) {
65+
[self addCountlyFeature:CLYPushNotifications];
66+
}
7567

68+
if (serverurl != nil && [serverurl length] > 0) {
69+
[[Countly sharedInstance] startWithConfig:config];
70+
resolve(@"Success");
71+
}
72+
});
7673
}
7774

7875
RCT_EXPORT_METHOD(event:(NSArray*)arguments)
@@ -226,6 +223,7 @@ - (void) saveListener:(Result) result{
226223
}
227224
RCT_EXPORT_METHOD(registerForNotification:(NSArray*)arguments)
228225
{
226+
dispatch_async(dispatch_get_main_queue(), ^ {
229227
[self saveListener: ^(id _Nullable result) {
230228
[self sendEventWithName:@"onCountlyPushNotification" body: [CountlyReactNative toJSON:lastStoredNotification]];
231229
lastStoredNotification = nil;
@@ -234,6 +232,8 @@ - (void) saveListener:(Result) result{
234232
[self sendEventWithName:@"onCountlyPushNotification" body: [CountlyReactNative toJSON:lastStoredNotification]];
235233
lastStoredNotification = nil;
236234
}
235+
});
236+
237237
};
238238

239239
+ (void)onNotification:(NSDictionary *)notificationMessage

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "countly-sdk-react-native-bridge",
3-
"version": "20.11.4",
3+
"version": "20.11.5",
44
"author": "Countly <[email protected]> (https://count.ly/)",
55
"bugs": {
66
"url": "https://github.com/Countly/countly-sdk-react-native-bridge/issues"

0 commit comments

Comments
 (0)