Skip to content

Commit 133595b

Browse files
authored
Merge pull request #62 from singular-labs/SDKDEV-59-SKAN4-Update
Sdkdev 59 skan4 update
2 parents 17a9f4d + 16d82b1 commit 133595b

File tree

5 files changed

+52
-11
lines changed

5 files changed

+52
-11
lines changed

Singular-React-Native.podspec

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Pod::Spec.new do |spec|
1212
spec.source_files = "ios/*.{h,m}"
1313
spec.platform = :ios, "8.0"
1414
spec.static_framework = true
15-
spec.dependency 'Singular-SDK'
15+
spec.dependency 'Singular-SDK', '12.0.1'
16+
1617
spec.dependency 'React'
1718
end

Singular.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ export class Singular {
1414
static init(singularConfig) {
1515
this._singularLinkHandler = singularConfig.singularLinkHandler;
1616
this._conversionValueUpdatedHandler = singularConfig.conversionValueUpdatedHandler;
17-
17+
this._conversionValuesUpdatedHandler = singularConfig.conversionValuesUpdatedHandler;
18+
1819
this._singularNativeEmitter.addListener(
1920
'SingularLinkHandler',
2021
singularLinkParams => {
@@ -31,6 +32,14 @@ export class Singular {
3132
}
3233
});
3334

35+
this._singularNativeEmitter.addListener(
36+
'ConversionValuesUpdatedHandler',
37+
updatedConversionValues => {
38+
if (this._conversionValuesUpdatedHandler) {
39+
this._conversionValuesUpdatedHandler(updatedConversionValues);
40+
}
41+
});
42+
3443
SingularBridge.init(JSON.stringify(singularConfig));
3544
SingularBridge.setReactSDKVersion(SDK_NAME, SDK_VERSION);
3645
}
@@ -139,6 +148,12 @@ export class Singular {
139148
}
140149
return true
141150
}
151+
152+
static skanUpdateConversionValue(conversionValue, coarse, lock) {
153+
if (Platform.OS === 'ios') {
154+
SingularBridge.skanUpdateConversionValue(conversionValue, coarse, lock);
155+
}
156+
}
142157

143158
static skanGetConversionValue() {
144159
if (Platform.OS === 'ios') {

SingularConfig.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export class SingularConfig {
1111
clipboardAttribution;
1212
manualSkanConversionManagement;
1313
conversionValueUpdatedHandler;
14+
conversionValuesUpdatedHandler;
1415
waitForTrackingAuthorizationWithTimeoutInterval;
1516

1617
// Limit Data Sharing
@@ -72,6 +73,11 @@ export class SingularConfig {
7273
return this;
7374
}
7475

76+
withConversionValuesUpdatedHandler(conversionValuesUpdatedHandler) {
77+
this.conversionValuesUpdatedHandler = conversionValuesUpdatedHandler;
78+
return this;
79+
}
80+
7581
withWaitForTrackingAuthorizationWithTimeoutInterval(waitForTrackingAuthorizationWithTimeoutInterval) {
7682
this.waitForTrackingAuthorizationWithTimeoutInterval = waitForTrackingAuthorizationWithTimeoutInterval;
7783
return this;

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ repositories {
4141

4242
dependencies {
4343
implementation 'com.facebook.react:react-native:+'
44-
implementation 'com.singular.sdk:singular_sdk:12.0.8'
44+
implementation 'com.singular.sdk:singular_sdk:12.0.9'
4545
implementation 'com.android.support:support-annotations:28.0.0'
4646
}

ios/SingularBridge.m

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ +(void)startSessionWithUserActivity:(NSUserActivity*)userActivity{
4545
RCT_EXPORT_MODULE();
4646

4747
- (NSArray<NSString *> *)supportedEvents {
48-
return @[@"SingularLinkHandler", @"ConversionValueUpdatedHandler", @"ShortLinkHandler"];
48+
return @[@"SingularLinkHandler", @"ConversionValueUpdatedHandler", @"ShortLinkHandler", @"ConversionValuesUpdatedHandler"];
4949
}
5050

5151
// Init method using a json string representing the config
@@ -83,6 +83,10 @@ +(void)startSessionWithUserActivity:(NSUserActivity*)userActivity{
8383
singularConfig.conversionValueUpdatedCallback = ^(NSInteger conversionValue) {
8484
[SingularBridge handleConversionValueUpdated:conversionValue];
8585
};
86+
singularConfig.conversionValuesUpdatedCallback = ^(NSNumber *fineValue, NSNumber *coarseValue, BOOL lockWindow) {
87+
[SingularBridge handleConversionValuesUpdated:fineValue andCoarseValue:coarseValue andLockWindow:lockWindow];
88+
};
89+
8690
singularConfig.waitForTrackingAuthorizationWithTimeoutInterval =
8791
[[singularConfigDict objectForKey:@"waitForTrackingAuthorizationWithTimeoutInterval"] intValue];
8892

@@ -202,6 +206,10 @@ +(void)startSessionWithUserActivity:(NSUserActivity*)userActivity{
202206
return [Singular skanUpdateConversionValue:conversionValue] ? @YES : @NO;
203207
}
204208

209+
RCT_EXPORT_METHOD(skanUpdateConversionValue:(NSInteger)conversionValue coarse:(NSInteger)coarse lock:(BOOL)lock){
210+
[Singular skanUpdateConversionValue:conversionValue coarse:coarse lock:lock];
211+
}
212+
205213
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(skanGetConversionValue){
206214
return [Singular skanGetConversionValue];
207215
}
@@ -246,10 +254,6 @@ +(NSDictionary*)jsonToDictionary:(NSString*)json{
246254
return data;
247255
}
248256

249-
250-
251-
252-
253257
+(void)handleSingularLink:(SingularLinkParams*)params {
254258
// Raising the Singular Link handler in the react-native code
255259
[eventEmitter sendEventWithName:@"SingularLinkHandler" body:@{
@@ -260,12 +264,27 @@ +(void)handleSingularLink:(SingularLinkParams*)params {
260264

261265
}
262266

263-
264-
265-
266267
+(void)handleConversionValueUpdated:(NSInteger)conversionValue {
267268
// Raising the Conversion Value handler in the react-native code
268269
[eventEmitter sendEventWithName:@"ConversionValueUpdatedHandler" body:@(conversionValue)];
269270
}
270271

272+
+(void)handleConversionValuesUpdated:(NSNumber *)fineValue andCoarseValue:(NSNumber *)coarseValue andLockWindow:(BOOL)lockWindow {
273+
NSInteger fine = -1;
274+
NSInteger coarse = -1;
275+
276+
if (fineValue != nil) {
277+
fine = [fineValue intValue];
278+
}
279+
if (coarseValue != nil) {
280+
coarse = [coarseValue intValue];
281+
}
282+
283+
[eventEmitter sendEventWithName:@"ConversionValuesUpdatedHandler" body:@{
284+
@"conversionValue": @(fine),
285+
@"coarse": @(coarse),
286+
@"lock": @(lockWindow)
287+
}];
288+
}
289+
271290
@end

0 commit comments

Comments
 (0)