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

[in_app_purchase] Configured example app to use StoreKit Testing on iOS 14 #3772

Merged
merged 4 commits into from
Apr 7, 2021

Conversation

mvanbeusekom
Copy link
Contributor

Configured example app to use StoreKit Testing on iOS 14 and higher.

If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I signed the CLA.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy.
  • I updated CHANGELOG.md to add a description of the change.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Comment on lines 72 to 74
<StoreKitConfigurationFileReference
identifier = "../Runner/Configuration.storekit">
</StoreKitConfigurationFileReference>
Copy link
Contributor

Choose a reason for hiding this comment

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

@jmagman We discovered that this setting doesn't seem to be picked up when running the app with flutter run. It is only affective when running the app through xcode.
Do you have any idea why would that be?

Copy link
Member

Choose a reason for hiding this comment

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

I see the same think from Xcode and flutter run --debug:
Screen Shot 2021-03-30 at 12 36 00 PM

What are the repro steps to see it not working?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I started the example app from Android Studio (run not debug). I guess the --debug makes the difference.

Copy link
Member

Choose a reason for hiding this comment

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

It should work in release, too. Looks like it doesn't work on a real device though, I had only tried on the simulator. In the device logs I see:

default	12:50:08.880522-0700	appstored	appstored	StoreKit	com.apple.appstored	StoreKitServiceConnection(1084): Loading 4 products for io.flutter.plugins.inAppPurchaseExample
default	12:50:08.971100-0700	appstored	appstored	StoreKit	com.apple.appstored	StoreKitServiceConnection(1084): Returning 0 products, 4 invalid identifiers for io.flutter.plugins.inAppPurchaseExample

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm I will look into it again. I was also running on a simulator.

I did notice that if I run it first with Xcode and afterwards from Android Studio it worked fine. However if I start a fresh simulator (which didn't have the app installed) and run it with Android Studio I run into some exceptions.

It is kinda late over here so I will do some more testing tomorrow and if I run into issues I will make a detailed report.

Copy link
Member

Choose a reason for hiding this comment

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

Hm it's weird, if I run it once from Xcode it works, and then subsequently from the command line it also works, so Xcode is laying something else down. The bundles look identical. The entitlements are the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes indeed, Xcode is doing some magic regarding the Configuration.storekit file in my opinion. I followed the Setting Up StoreKit Testing in Xcode article which describe to enable StoreKit Testing in Xcode through the following steps:

  1. Click the scheme to open the scheme menu; choose Edit Scheme.
  2. In the scheme editor, choose the Run action.
  3. Click Options in the action settings.
  4. For the StoreKit Configuration option, select a configuration file.

I have the feeling that Xcode somehow parses the Configuration.storekit and registers the products configured in the file separate from the App on the simulator (some form of offline StoreKit cache). If you make changes to the Configuration.storekit file and run the App using flutter run the changes are not reflected in the App it self. If you run the App using Xcode the changes are correctly reflected in the App.

Copy link
Contributor

@cyanglaz cyanglaz left a comment

Choose a reason for hiding this comment

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

The change looks good. Let's wait for Jenn to see if there's a way to make flutter run work.

Copy link
Contributor

@cyanglaz cyanglaz left a comment

Choose a reason for hiding this comment

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

LGTM! The storekit testing doesn't seem to be working in command line, which will delay our plan to make XCUITests for IAP. However, this PR is a big improvement for the example app and there's no regression, so we should land it!

@cyanglaz cyanglaz added the waiting for tree to go green (Use "autosubmit") This PR is approved and tested, but waiting for the tree to be green to land. label Apr 7, 2021
@fluttergithubbot fluttergithubbot merged commit d5ebaa5 into flutter:master Apr 7, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 7, 2021
fluttergithubbot pushed a commit to flutter/flutter that referenced this pull request Apr 7, 2021
@kpradeepkumarreddy
Copy link

StoreKit is for testing with the data that is configured locally. How to test with the consumables created on app store connect using simulator ?

@mvanbeusekom
Copy link
Contributor Author

StoreKit is for testing with the data that is configured locally. How to test with the consumables created on app store connect using simulator ?

Unfortunately you can't. If you want to test your consumables configured in the AppStore you will have to test on a real device.

@cyanglaz
Copy link
Contributor

@mvanbeusekom Maybe we should add this information in our docs too?

bhaveshptl pushed a commit to bhaveshptl/plugins that referenced this pull request Apr 23, 2021
* master: (397 commits)
  [in_app_purchase] Implementation of platform interface (flutter#3781)
  [google_sign_in] Add todo WRT correctly setting X-Goog-AuthUser header (flutter#3819)
  [tools] fix version check command not working for new packages (flutter#3818)
  [camera] android-rework part 1: Base classes to support Android Camera features (flutter#3795)
  fix MD (flutter#3815)
  Path provider windows crash fix (flutter#3814)
  [local_auth] docs update (flutter#3103)
  Update PULL_REQUEST_TEMPLATE.md (flutter#3801)
  [quick_actions] handle cold start on iOS correctly (flutter#3811)
  Replace path_provider_linux widget tests with simple unit tests (flutter#3812)
  [sensors] format dart code based on the new dart formatter (flutter#3809)
  [google_sign_in] Fix "pick account" on iOS (flutter#3805)
  [image_picker_platform_interface] Added pickMultiImage (flutter#3782)
  [in_app_purchase] Added currency code and numerical price to product detail model. (flutter#3794)
  [local_auth] Fix iOS crash when no localizedReason (flutter#3780)
  Fix and update version checks (flutter#3792)
  [in_app_purchase] Configured example app to use StoreKit Testing on iOS 14 (flutter#3772)
  [local_auth] Unnecessary reassignment in example removed (flutter#2983)
  [flutter_webview] Fix `allowsInlineMediaPlayback` ignored on iOS (flutter#3791)
  Switch script/tools over to the new analysis options (flutter#3777)
  ...
fotiDim pushed a commit to fotiDim/plugins that referenced this pull request Sep 13, 2021
@mvanbeusekom mvanbeusekom deleted the issue/79286 branch September 21, 2021 09:33
@sneglia9191
Copy link

Is there any additional information on this? It does appear StoreKit testing will work using Android Studio, only after executed from Xcode one time. Is this the assumed workaround, or will a fix be implemented to initially work from Android Studio?

@jmagman
Copy link
Member

jmagman commented Dec 29, 2022

It does appear StoreKit testing will work using Android Studio, only after executed from Xcode one time. Is this the assumed workaround, or will a fix be implemented to initially work from Android Studio?

@sneglia9191 can you file a new issue describing what you're seeing? I'm unfamiliar with that problem.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes p: in_app_purchase platform-ios waiting for tree to go green (Use "autosubmit") This PR is approved and tested, but waiting for the tree to be green to land.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[in_app_purchase] setup store kit testing for example app
7 participants