Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 408689a

Browse files
YukiOyaChris Yang
authored andcommitted
[in_app_purchase] iOS: Support unsupported UserInfo value types in NSError. (#1819)
1 parent 19bdcce commit 408689a

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

packages/in_app_purchase/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.2.0+5
2+
3+
* iOS: Support unsupported UserInfo value types on NSError.
4+
15
## 0.2.0+4
26

37
* Fixed code error in `README.md` and adjusted links to work on Pub.

packages/in_app_purchase/ios/Classes/FIAObjectTranslator.m

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,18 @@ + (NSDictionary *)getMapFromNSError:(NSError *)error {
153153
if (!error) {
154154
return nil;
155155
}
156-
return @{
157-
@"code" : @(error.code),
158-
@"domain" : error.domain ?: @"",
159-
@"userInfo" : error.userInfo ?: @{}
160-
};
156+
NSMutableDictionary *userInfo = [NSMutableDictionary new];
157+
for (NSErrorUserInfoKey key in error.userInfo) {
158+
id value = error.userInfo[key];
159+
if ([value isKindOfClass:[NSError class]]) {
160+
userInfo[key] = [FIAObjectTranslator getMapFromNSError:value];
161+
} else if ([value isKindOfClass:[NSURL class]]) {
162+
userInfo[key] = [value absoluteString];
163+
} else {
164+
userInfo[key] = value;
165+
}
166+
}
167+
return @{@"code" : @(error.code), @"domain" : error.domain ?: @"", @"userInfo" : userInfo};
161168
}
162169

163170
@end

0 commit comments

Comments
 (0)