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

Code refactor & more proper null safety update #301

Conversation

bohdan1krokhmaliuk
Copy link
Contributor

@bohdan1krokhmaliuk bohdan1krokhmaliuk commented Jul 22, 2021

  • General refactor of android part, small refactor of ios part
  • updated logic for some methods and fixed AndroidStudio warnings
  • replaced JSONObject with HashMap(supported by MethodChannels) in androidInAppPurchasePlugin.java
  • deprecated originalJsonAndroid and dataAndroid as it is always the same object as transactionReceipt
  • refactored Dart part

@bohdan1krokhmaliuk bohdan1krokhmaliuk marked this pull request as draft July 22, 2021 17:18
@@ -1,3 +1,6 @@
## 5.5.0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR: NOT FINISHED YET

Bohdan Krokhmaliuk added 2 commits July 22, 2021 20:22
UP:
1. Updated Amazon file to return acceptable value types by plugin
2. Created FlutterEntitiesBuilder
3. Removed unnecessary try catches
@@ -4,32 +4,28 @@
import android.content.Context;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hyochan What is the status on amazon IAP? Is it a working feature? I tried to unify Amazon IAPs maps to be the same as Android apps, but it is better to kill amazon IAPs in case it is not a working feature and nobody uses it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bohdan1krokhmaliuk Honestly I've not tried Amazon at all because I am not using it. Also, this was developed by the community by @Rockvole.

How about separating the two variants as done in dooboolab-community/react-native-iap#1336?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No no, I was wondering cause it would make two more variables not nullable

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, Sorry I cant help much, I have not done any Android java development since this Amazon IAP work (2018 I think). The Amazon store may become more important soon since it will be used for Android apps in Windows 11.
https://www.theverge.com/2021/6/24/22548428/microsoft-windows-11-android-apps-support-amazon-store

Comment on lines 262 to 267
/// android specific
'dataAndroid: $dataAndroid, '
'signatureAndroid: $signatureAndroid, '
'isAcknowledgedAndroid: $isAcknowledgedAndroid, '
'autoRenewingAndroid: $autoRenewingAndroid, '
'purchaseStateAndroid: $purchaseStateAndroid, '
'originalJsonAndroid: $originalJsonAndroid, '

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed fields removed as those are the copy of transactionReceipt

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure you can remove it!

Comment on lines -317 to +321
NSString* introductoryPriceNumber = @"";
NSString* introductoryPricePaymentMode = @"";
NSString* introductoryPriceNumberOfPeriods = @"";
NSString* introductoryPriceSubscriptionPeriod = @"";
NSString* introductoryPriceNumber;
NSString* introductoryPricePaymentMode;
NSString* introductoryPriceNumberOfPeriods;
NSString* introductoryPriceSubscriptionPeriod;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be no default values

Comment on lines -588 to +565
@(transaction.transactionDate.timeIntervalSince1970 * 1000), @"transactionDate",
@(lround(transaction.transactionDate.timeIntervalSince1970 * 1000)), @"transactionDate",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int on dart side

Comment on lines -73 to -77
} else if (_platform.isIOS) {
return 'no-ops in ios';
}
throw PlatformException(
code: _platform.operatingSystem, message: "platform not supported");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Platform specific methods should throw exceptions on not supported platforms

Comment on lines -69 to 74
Future get consumeAllItems async {
Future get consumeAllItemsAndroid async {
if (_platform.isAndroid) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Platform specific methods should end with platform name

Comment on lines 116 to +117
);

return extractItems(json.encode(result));
return extractItems(result ?? []);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Around the whole platform operations with strings were replaced with operations with maps. So method channels are sending maps mostly and there is no need to make another unnecessary json string encode/decode

@bohdan1krokhmaliuk
Copy link
Contributor Author

@hyochan Could you please test if there are no type errors with subscriptions and consumables IAPs for android and IOS? As I use just non-consumables and it works fine with them?

@bohdan1krokhmaliuk bohdan1krokhmaliuk marked this pull request as ready for review July 26, 2021 07:28
@hyochan
Copy link
Member

hyochan commented Jul 27, 2021

@hyochan Could you please test if there are no type errors with subscriptions and consumables IAPs for android and IOS? As I use just non-consumables and it works fine with them?

Hm. Looks like we need others to test this out because I don't have any related example currently 😞
All we have is an example project in current repo.

@github-actions
Copy link

This PR is stale because it has been open 90 days with no activity. Leave a comment or this will be closed in 7 days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants