Skip to content

Commit 99e6d7d

Browse files
ijunaidpeterBrxwnArtursKadikis
authored
Fixed iOS pushtoken issue during init. (#205)
* Fixed iOS pushtoken issue during init. * typo fix * updated changelogs and updated version * updated changelogs and updated version * Update CHANGELOG.md * Update CountlyConfig.js * docs addition * Update CountlyConfig.js * changing a comment * no message * . * . * ., * ' * ., --------- Co-authored-by: Peter Obiechina <[email protected]> Co-authored-by: Artūrs Kadiķis <[email protected]>
1 parent 4200e88 commit 99e6d7d

File tree

9 files changed

+3454
-8283
lines changed

9 files changed

+3454
-8283
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 23.2.3
2+
* Fixed bug where the push notification type was not correctly set during init
3+
14
## 23.2.2
25
* Fixed bug that caused an issue in the deprecated init call
36

Countly.js

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@ Countly.TemporaryDeviceIDString = 'TemporaryDeviceID';
5353
* @deprecated in 23.02.0 : use 'initWithConfig' intead of 'init'.
5454
*
5555
* @function Countly.init should be used to initialize countly
56+
* @param {String} serverURL server url
57+
* @param {String} appKey application key
58+
* @param {String} deviceId device ID
5659
*/
57-
// countly initialization
5860
Countly.init = async function (serverUrl, appKey, deviceId) {
5961
Countly.logError('init is deprecated, use initWithConfig instead');
6062
const countlyConfig = new CountlyConfig(serverUrl, appKey).setDeviceID(deviceId);
@@ -65,8 +67,8 @@ Countly.init = async function (serverUrl, appKey, deviceId) {
6567
* Initialize Countly
6668
*
6769
* @function Countly.initWithConfig should be used to initialize countly with config
70+
* @param {Object} countlyConfig countly config object
6871
*/
69-
// countly initialization with config
7072
Countly.initWithConfig = async function (countlyConfig) {
7173
if (_isInitialized) {
7274
Countly.logError('init', 'SDK is already initialized');
@@ -93,6 +95,11 @@ Countly.initWithConfig = async function (countlyConfig) {
9395
_isInitialized = true;
9496
};
9597

98+
/**
99+
* Converts countly config object to JSON
100+
*
101+
* @param {Object} countlyConfig config
102+
*/
96103
_configToJson = function (config) {
97104
const json = {};
98105
try {
@@ -165,6 +172,11 @@ _configToJson = function (config) {
165172
return json;
166173
};
167174

175+
/**
176+
* Checks if the sdk is initialized;
177+
*
178+
* @return {bool} whether countly sdk has been initialized
179+
*/
168180
Countly.isInitialized = async function () {
169181
// returns a promise
170182
_isInitialized = await CountlyReactNative.isInitialized();
@@ -180,7 +192,9 @@ Countly.hasBeenCalledOnStart = function () {
180192
return CountlyReactNative.hasBeenCalledOnStart();
181193
};
182194

183-
// countly sending various types of events
195+
/**
196+
* Used to send events
197+
*/
184198
Countly.sendEvent = function (options) {
185199
if (!_isInitialized) {
186200
const message = "'init' must be called before 'sendEvent'";
@@ -491,6 +505,7 @@ Countly.disableLocation = function () {
491505
*
492506
* Get currently used device Id.
493507
* Should be called after Countly init
508+
* @return {String} device id
494509
* */
495510
Countly.getCurrentDeviceId = async function () {
496511
if (!_isInitialized) {
@@ -516,28 +531,35 @@ _getDeviceIdType = function (deviceIdType) {
516531
break;
517532
}
518533
if (result == null) {
519-
Countly.logError('_getDeviceIdType', "unexpected deviceIdType [" + deviceIdType.toString() + "] from native side");
534+
Countly.logError('_getDeviceIdType', 'unexpected deviceIdType [' + deviceIdType.toString() + '] from native side');
520535
return null;
521536
}
522537
return result;
523538
};
539+
524540
/**
525541
* Get currently used device Id type.
526542
* Should be called after Countly init
543+
* @return {String} device id type
527544
* */
528545
Countly.getDeviceIDType = async function () {
529546
if (!_isInitialized) {
530547
Countly.logError('getDeviceIDType', "'init' must be called before 'getDeviceIDType'");
531548
return null;
532549
}
533550
const result = await CountlyReactNative.getDeviceIDType();
534-
if (result == null || result == "") {
551+
if (result == null || result == '') {
535552
Countly.logError('getDeviceIDType', "'getDeviceIDType' unexpected null value from native side");
536553
return null;
537554
}
538555
return _getDeviceIdType(result);
539556
};
540557

558+
/**
559+
* Change the current device id
560+
* @param {String} device id new device id
561+
* @param {boolean} onServer merge device id
562+
* */
541563
Countly.changeDeviceId = async function (newDeviceID, onServer) {
542564
if (!_isInitialized) {
543565
const msg = "'init' must be called before 'changeDeviceId'";

CountlyConfig.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class CountlyConfig {
8585
/**
8686
* Method to give consent for specific features before init
8787
*
88-
* @param {array of String} consents consents e.g ['location', 'sessions',
88+
* @param {String[]} consents consents e.g ['location', 'sessions',
8989
* 'attribution', 'push', 'events', 'views', 'crashes', 'users', 'push',
9090
* 'star-rating', 'apm', 'feedback', 'remote-config']
9191
*/
@@ -147,8 +147,8 @@ class CountlyConfig {
147147
/**
148148
* Method to configure intent redirection check
149149
*
150-
* @param {String} allowedIntentClassNames allowedIntentClassNames
151-
* @param {String} allowedIntentPackageNames allowedIntentPackageNames
150+
* @param {String[]} allowedIntentClassNames allowed intent class names
151+
* @param {String[]} allowedIntentPackageNames allowed intent package name
152152
*/
153153
configureIntentRedirectionCheck(allowedIntentClassNames, allowedIntentPackageNames) {
154154
this.allowedIntentClassNames = allowedIntentClassNames;
@@ -170,14 +170,18 @@ class CountlyConfig {
170170
return this;
171171
}
172172

173-
/// Report direct user attribution
173+
/**
174+
* Report direct user attribution
175+
*/
174176
recordDirectAttribution(campaignType, campaignData) {
175177
this.campaignType = campaignType;
176178
this.campaignData = campaignData;
177179
return this;
178180
}
179-
180-
/// Report indirect user attribution
181+
182+
/**
183+
* Report indirect user attribution
184+
*/
181185
recordIndirectAttribution(attributionValues) {
182186
this.attributionValues = attributionValues;
183187
return this;

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 = '23.2.2'
3+
s.version = '23.2.3'
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
@@ -83,7 +83,7 @@ public String toString() {
8383
public class CountlyReactNative extends ReactContextBaseJavaModule implements LifecycleEventListener {
8484

8585
public static final String TAG = "CountlyRNPlugin";
86-
private String COUNTLY_RN_SDK_VERSION_STRING = "23.2.2";
86+
private String COUNTLY_RN_SDK_VERSION_STRING = "23.2.3";
8787
private String COUNTLY_RN_SDK_NAME = "js-rnb-android";
8888

8989
private static final 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: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ @interface CountlyFeedbackWidget ()
2424
+ (CountlyFeedbackWidget *)createWithDictionary:(NSDictionary *)dictionary;
2525
@end
2626

27-
NSString *const kCountlyReactNativeSDKVersion = @"23.2.2";
27+
NSString *const kCountlyReactNativeSDKVersion = @"23.2.3";
2828
NSString *const kCountlyReactNativeSDKName = @"js-rnb-ios";
2929

3030
CLYPushTestMode const CLYPushTestModeProduction = @"CLYPushTestModeProduction";
@@ -155,10 +155,11 @@ - (void) populateConfig:(id) json {
155155
}
156156

157157
#ifndef COUNTLY_EXCLUDE_PUSHNOTIFICATIONS
158-
if (json[@"pushNotification"]) {
158+
NSDictionary *pushJson = json[@"pushNotification"];
159+
if (pushJson) {
159160
config.sendPushTokenAlways = YES;
160161
config.pushTestMode = CLYPushTestModeProduction;
161-
NSString *tokenType = json[@"tokenType"];
162+
NSString *tokenType = pushJson[@"tokenType"];
162163
if ([tokenType isEqualToString:@"1"]) {
163164
config.pushTestMode = CLYPushTestModeDevelopment;
164165
} else if ([tokenType isEqualToString:@"2"]) {

0 commit comments

Comments
 (0)