Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[in_app_purchase_storekit] Allows 'localizedDescription' to be nullable to handle occasional nulls in Storekit objects #7515

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## NEXT
## 0.3.18

* Updates minimum supported SDK version to Flutter 3.19/Dart 3.3.
* Changes the `localizedDescription` field of `SKProductMessage` to allow for null values

## 0.3.17+3

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ typedef NS_ENUM(NSUInteger, SKSubscriptionPeriodUnitMessage) {
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)makeWithProductIdentifier:(NSString *)productIdentifier
localizedTitle:(NSString *)localizedTitle
localizedDescription:(NSString *)localizedDescription
localizedDescription:(nullable NSString *)localizedDescription
priceLocale:(SKPriceLocaleMessage *)priceLocale
subscriptionGroupIdentifier:(nullable NSString *)subscriptionGroupIdentifier
price:(NSString *)price
Expand All @@ -196,7 +196,7 @@ typedef NS_ENUM(NSUInteger, SKSubscriptionPeriodUnitMessage) {
discounts:(nullable NSArray<SKProductDiscountMessage *> *)discounts;
@property(nonatomic, copy) NSString *productIdentifier;
@property(nonatomic, copy) NSString *localizedTitle;
@property(nonatomic, copy) NSString *localizedDescription;
@property(nonatomic, copy, nullable) NSString *localizedDescription;
@property(nonatomic, strong) SKPriceLocaleMessage *priceLocale;
@property(nonatomic, copy, nullable) NSString *subscriptionGroupIdentifier;
@property(nonatomic, copy) NSString *price;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Autogenerated from Pigeon (v16.0.4), do not edit directly.
// Autogenerated from Pigeon (v16.0.5), do not edit directly.
// See also: https://pub.dev/packages/pigeon

#import "messages.g.h"
Expand Down Expand Up @@ -333,7 +333,7 @@ @implementation SKProductMessage
+ (instancetype)
makeWithProductIdentifier:(NSString *)productIdentifier
localizedTitle:(NSString *)localizedTitle
localizedDescription:(NSString *)localizedDescription
localizedDescription:(nullable NSString *)localizedDescription
priceLocale:(SKPriceLocaleMessage *)priceLocale
subscriptionGroupIdentifier:(nullable NSString *)subscriptionGroupIdentifier
price:(NSString *)price
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ class SKProductMessage {
SKProductMessage({
required this.productIdentifier,
required this.localizedTitle,
required this.localizedDescription,
this.localizedDescription,
required this.priceLocale,
this.subscriptionGroupIdentifier,
required this.price,
Expand All @@ -335,7 +335,7 @@ class SKProductMessage {

String localizedTitle;

String localizedDescription;
String? localizedDescription;

SKPriceLocaleMessage priceLocale;

Expand Down Expand Up @@ -368,7 +368,7 @@ class SKProductMessage {
return SKProductMessage(
productIdentifier: result[0]! as String,
localizedTitle: result[1]! as String,
localizedDescription: result[2]! as String,
localizedDescription: result[2] as String?,
priceLocale: SKPriceLocaleMessage.decode(result[3]! as List<Object?>),
subscriptionGroupIdentifier: result[4] as String?,
price: result[5]! as String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ class SKProductWrapper {
return SKProductWrapper(
productIdentifier: msg.productIdentifier,
localizedTitle: msg.localizedTitle,
localizedDescription: msg.localizedDescription,
localizedDescription: msg.localizedDescription ?? '',
priceLocale: SKPriceLocaleWrapper.convertFromPigeon(msg.priceLocale),
price: msg.price,
subscriptionGroupIdentifier: msg.subscriptionGroupIdentifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,20 @@ class SKProductMessage {
const SKProductMessage(
{required this.productIdentifier,
required this.localizedTitle,
required this.localizedDescription,
required this.priceLocale,
required this.price,
this.localizedDescription,
this.subscriptionGroupIdentifier,
this.subscriptionPeriod,
this.introductoryPrice,
this.discounts});

final String productIdentifier;
final String localizedTitle;
final String localizedDescription;
// This field should be nullable to handle occasional nulls in the StoreKit
// object despite the the StoreKit header showing that it is nonnullable
// https://github.com/flutter/flutter/issues/154047
final String? localizedDescription;
LouiseHsu marked this conversation as resolved.
Show resolved Hide resolved
final SKPriceLocaleMessage priceLocale;
final String? subscriptionGroupIdentifier;
final String price;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: in_app_purchase_storekit
description: An implementation for the iOS and macOS platforms of the Flutter `in_app_purchase` plugin. This uses the StoreKit Framework.
repository: https://github.com/flutter/packages/tree/main/packages/in_app_purchase/in_app_purchase_storekit
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+in_app_purchase%22
version: 0.3.17+3
version: 0.3.18

environment:
sdk: ^3.3.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class FakeStoreKitPlatform implements TestInAppPurchaseApi {
void reset() {
transactionList = <SKPaymentTransactionWrapper>[];
receiptData = 'dummy base64data';
validProductIDs = <String>{'123', '456'};
validProductIDs = <String>{'123', '456', '789'};
validProducts = <String, SKProductWrapper>{};
for (final String validID in validProductIDs) {
final Map<String, dynamic> productWrapperMap =
Expand All @@ -42,6 +42,9 @@ class FakeStoreKitPlatform implements TestInAppPurchaseApi {
if (validID == '456') {
productWrapperMap['priceLocale'] = buildLocaleMap(noSymbolLocale);
}
if (validID == '789') {
productWrapperMap['localizedDescription'] = null;
}
validProducts[validID] = SKProductWrapper.fromJson(productWrapperMap);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ void main() {
test('should get product list and correct invalid identifiers', () async {
final InAppPurchaseStoreKitPlatform connection =
InAppPurchaseStoreKitPlatform();
final ProductDetailsResponse response =
await connection.queryProductDetails(<String>{'123', '456', '789'});
final ProductDetailsResponse response = await connection
.queryProductDetails(<String>{'123', '456', '789', '999'});
final List<ProductDetails> products = response.productDetails;
expect(products.first.id, '123');
expect(products[1].id, '456');
expect(response.notFoundIDs, <String>['789']);
expect(products[2].id, '789');
expect(products[2].description, '');
expect(response.notFoundIDs, <String>['999']);
expect(response.error, isNull);
expect(response.productDetails.first.currencySymbol, r'$');
expect(response.productDetails[1].currencySymbol, 'EUR');
Expand Down