Skip to content

Commit 57feeb4

Browse files
authored
Merge pull request #161 from adjust/v511
Version 5.1.1
2 parents 977bce7 + e803e1f commit 57feeb4

File tree

11 files changed

+56
-30
lines changed

11 files changed

+56
-30
lines changed

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
### Version 5.1.1 (March 5th 2025)
2+
#### Fixed
3+
- Fixed crashes happening in cases where native iOS `jsonResponse` is `nil` (https://github.com/adjust/flutter_sdk/pull/160).
4+
5+
#### Native SDKs
6+
- [iOS@v5.1.1][ios_sdk_v5.1.1]
7+
- [Android@v5.1.0][android_sdk_v5.1.0]
8+
9+
---
10+
111
### Version 5.1.0 (25th February 2025)
212
#### Added
313
- Added `jsonResponse` field (JSON string) to `AdjustAttribution` where every key-value pair sent by the backend as part of the attribution response can be found.

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5.1.0
1+
5.1.1

android/src/main/java/com/adjust/sdk/flutter/AdjustSdk.java

+7-3
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,9 @@ public void onAttributionChanged(AdjustAttribution adjustAttribution) {
423423
adjustAttribution.costAmount.toString() : "");
424424
adjustAttributionMap.put("costCurrency", adjustAttribution.costCurrency);
425425
adjustAttributionMap.put("fbInstallReferrer", adjustAttribution.fbInstallReferrer);
426-
adjustAttributionMap.put("jsonResponse", adjustAttribution.jsonResponse);
426+
if (adjustAttribution.jsonResponse != null) {
427+
adjustAttributionMap.put("jsonResponse", adjustAttribution.jsonResponse);
428+
}
427429
if (channel != null) {
428430
channel.invokeMethod(dartMethodName, adjustAttributionMap);
429431
}
@@ -721,7 +723,7 @@ private void gdprForgetMe(final Result result) {
721723
private void getAttribution(final Result result) {
722724
Adjust.getAttribution(new OnAttributionReadListener() {
723725
@Override
724-
public void onAttributionRead(AdjustAttribution attribution){
726+
public void onAttributionRead(AdjustAttribution attribution) {
725727
HashMap<String, String> adjustAttributionMap = new HashMap<String, String>();
726728
adjustAttributionMap.put("trackerToken", attribution.trackerToken);
727729
adjustAttributionMap.put("trackerName", attribution.trackerName);
@@ -735,7 +737,9 @@ public void onAttributionRead(AdjustAttribution attribution){
735737
attribution.costAmount.toString() : "");
736738
adjustAttributionMap.put("costCurrency", attribution.costCurrency);
737739
adjustAttributionMap.put("fbInstallReferrer", attribution.fbInstallReferrer);
738-
adjustAttributionMap.put("jsonResponse", attribution.jsonResponse);
740+
if (attribution.jsonResponse != null) {
741+
adjustAttributionMap.put("jsonResponse", attribution.jsonResponse);
742+
}
739743
result.success(adjustAttributionMap);
740744
}
741745
});

ios/Classes/AdjustSdk.m

+15-9
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ - (void)initSdk:(FlutterMethodCall *)call withResult:(FlutterResult)result {
267267
[adjustConfig disableIdfvReading];
268268
}
269269
}
270-
270+
271271
// SKAdNetwork attribution
272272
if ([self isFieldValid:isSkanAttributionEnabled]) {
273273
if ([isSkanAttributionEnabled boolValue] == NO) {
@@ -419,7 +419,7 @@ - (void)processDeeplink:(FlutterMethodCall *)call withResult:(FlutterResult)resu
419419
if (urlString == nil) {
420420
return;
421421
}
422-
422+
423423
NSURL *url = [NSURL URLWithString:urlString];
424424
ADJDeeplink *deeplink = [[ADJDeeplink alloc] initWithDeeplink:url];
425425
[Adjust processDeeplink:deeplink];
@@ -456,12 +456,12 @@ - (void)trackAdRevenue:(FlutterMethodCall *)call withResult:(FlutterResult)resul
456456
if ([self isFieldValid:adRevenueNetwork]) {
457457
[adjustAdRevenue setAdRevenueNetwork:adRevenueNetwork];
458458
}
459-
459+
460460
// ad revenue unit
461461
if ([self isFieldValid:adRevenueUnit]) {
462462
[adjustAdRevenue setAdRevenueUnit:adRevenueUnit];
463463
}
464-
464+
465465
// ad revenue placement
466466
if ([self isFieldValid:adRevenuePlacement]) {
467467
[adjustAdRevenue setAdRevenuePlacement:adRevenuePlacement];
@@ -576,13 +576,19 @@ - (void)getAttribution:(FlutterMethodCall *)call withResult:(FlutterResult)resul
576576
[self addValueOrEmpty:attribution.costType withKey:@"costType" toDictionary:dictionary];
577577
[self addNumberOrEmpty:attribution.costAmount withKey:@"costAmount" toDictionary:dictionary];
578578
[self addValueOrEmpty:attribution.costCurrency withKey:@"costCurrency" toDictionary:dictionary];
579-
NSData *dataJsonResponse = [NSJSONSerialization dataWithJSONObject:attribution.jsonResponse
579+
580+
// Add nil check before serializing jsonResponse
581+
if (attribution.jsonResponse != nil) {
582+
NSData *dataJsonResponse = [NSJSONSerialization dataWithJSONObject:attribution.jsonResponse
580583
options:0
581584
error:nil];
582-
NSString *stringJsonResponse = [[NSString alloc] initWithBytes:[dataJsonResponse bytes]
585+
NSString *stringJsonResponse = [[NSString alloc] initWithBytes:[dataJsonResponse bytes]
583586
length:[dataJsonResponse length]
584587
encoding:NSUTF8StringEncoding];
585-
[self addValueOrEmpty:stringJsonResponse withKey:@"jsonResponse" toDictionary:dictionary];
588+
[self addValueOrEmpty:stringJsonResponse withKey:@"jsonResponse" toDictionary:dictionary];
589+
} else {
590+
[self addValueOrEmpty:@"" withKey:@"jsonResponse" toDictionary:dictionary];
591+
}
586592
result(dictionary);
587593
}];
588594
}
@@ -687,7 +693,7 @@ - (void)verifyAppStorePurchase:(FlutterMethodCall *)call withResult:(FlutterResu
687693
if (verificationResult == nil) {
688694
result(dictionary);
689695
}
690-
696+
691697
[self addValueOrEmpty:verificationResult.verificationStatus
692698
withKey:@"verificationStatus"
693699
toDictionary:dictionary];
@@ -788,7 +794,7 @@ - (void)verifyAndTrackAppStorePurchase:(FlutterMethodCall *)call withResult:(Flu
788794
if (verificationResult == nil) {
789795
result(dictionary);
790796
}
791-
797+
792798
[self addValueOrEmpty:verificationResult.verificationStatus
793799
withKey:@"verificationStatus"
794800
toDictionary:dictionary];

ios/Classes/AdjustSdkDelegate.m

+16-10
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ + (id)getInstanceWithSwizzleOfAttributionCallback:(NSString *)swizzleAttribution
4444
methodChannel:(FlutterMethodChannel *)channel {
4545
dispatch_once(&onceToken, ^{
4646
defaultInstance = [[AdjustSdkDelegate alloc] init];
47-
47+
4848
// do the swizzling where and if needed
4949
if (swizzleAttributionCallback != nil) {
5050
[defaultInstance swizzleCallbackMethod:@selector(adjustAttributionChanged:)
@@ -107,7 +107,7 @@ - (void)adjustAttributionChangedWannabe:(ADJAttribution *)attribution {
107107
if (nil == attribution || nil == dartAttributionCallback) {
108108
return;
109109
}
110-
110+
111111
id keys[] = {
112112
@"trackerToken",
113113
@"trackerName",
@@ -121,12 +121,18 @@ - (void)adjustAttributionChangedWannabe:(ADJAttribution *)attribution {
121121
@"costCurrency",
122122
@"jsonResponse"
123123
};
124-
NSData *dataJsonResponse = [NSJSONSerialization dataWithJSONObject:attribution.jsonResponse
125-
options:0
126-
error:nil];
127-
NSString *stringJsonResponse = [[NSString alloc] initWithBytes:[dataJsonResponse bytes]
128-
length:[dataJsonResponse length]
129-
encoding:NSUTF8StringEncoding];
124+
125+
// Add nil check before serializing jsonResponse
126+
NSString *strJsonResponse = nil;
127+
if (attribution.jsonResponse != nil) {
128+
NSData *dataJsonResponse = [NSJSONSerialization dataWithJSONObject:attribution.jsonResponse
129+
options:0
130+
error:nil];
131+
strJsonResponse = [[NSString alloc] initWithBytes:[dataJsonResponse bytes]
132+
length:[dataJsonResponse length]
133+
encoding:NSUTF8StringEncoding];
134+
}
135+
130136
id values[] = {
131137
[self getValueOrEmpty:[attribution trackerToken]],
132138
[self getValueOrEmpty:[attribution trackerName]],
@@ -138,7 +144,7 @@ - (void)adjustAttributionChangedWannabe:(ADJAttribution *)attribution {
138144
[self getValueOrEmpty:[attribution costType]],
139145
[self getNumberValueOrEmpty:[attribution costAmount]],
140146
[self getValueOrEmpty:[attribution costCurrency]],
141-
[self getValueOrEmpty:stringJsonResponse]
147+
[self getValueOrEmpty:strJsonResponse]
142148
};
143149
NSUInteger count = sizeof(values) / sizeof(id);
144150
NSDictionary *attributionMap = [NSDictionary dictionaryWithObjects:values
@@ -202,7 +208,7 @@ - (void)adjustEventTrackingSucceededWannabe:(ADJEventSuccess *)eventSuccessRespo
202208
if (nil == eventSuccessResponseData || nil == dartEventSuccessCallback) {
203209
return;
204210
}
205-
211+
206212
id keys[] = {
207213
@"message",
208214
@"timestamp",

ios/adjust_sdk.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'adjust_sdk'
3-
s.version = '5.1.0'
3+
s.version = '5.1.1'
44
s.summary = 'Adjust Flutter SDK for iOS platform'
55
s.description = <<-DESC
66
Adjust Flutter SDK for iOS platform.

lib/adjust.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import 'package:flutter/services.dart';
2424
import 'package:meta/meta.dart';
2525

2626
class Adjust {
27-
static const String _sdkPrefix = 'flutter5.1.0';
27+
static const String _sdkPrefix = 'flutter5.1.1';
2828
static const MethodChannel _channel =
2929
const MethodChannel('com.adjust.sdk/api');
3030

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: adjust_sdk
22
description: This is the Flutter SDK of Adjust™. You can read more about Adjust™ at adjust.com.
33
homepage: https://github.com/adjust/flutter_sdk
4-
version: 5.1.0
4+
version: 5.1.1
55

66
environment:
77
sdk: ">=2.12.0 <3.0.0"

test/app/lib/main.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ class _MyAppState extends State<MyApp> {
2626
super.initState();
2727

2828
if (Platform.isAndroid) {
29-
String _address = '192.168.2.46';
29+
String _address = '192.168.86.187';
3030
String _protocol = 'https';
3131
String _port = '8443';
3232
_overwriteUrl = _protocol + '://' + _address + ':' + _port;
3333
_controlUrl = 'ws://' + _address + ':1987';
3434
} else {
35-
String _address = '192.168.2.46';
35+
String _address = '192.168.86.187';
3636
String _protocol = 'http';
3737
String _port = '8080';
3838
_overwriteUrl = _protocol + '://' + _address + ':' + _port;

test/ios/test_lib.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'test_lib'
3-
s.version = '5.1.0'
3+
s.version = '5.1.1'
44
s.summary = 'Adjust test library for iOS platform'
55
s.description = <<-DESC
66
Adjust test library for iOS platform.

test/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: test_lib
22
description: Flutter plugin for Adjust Testing Library. Intended exclusively for internal use.
3-
version: 5.1.0
3+
version: 5.1.1
44
author: Adjust (sdk@adjust.com)
55

66
environment:

0 commit comments

Comments
 (0)