Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
652e5d1
Draft implementation of platform interface
mvanbeusekom Apr 2, 2021
bcb9d38
Added finishPurchase and restorePurchase definitions
mvanbeusekom Apr 7, 2021
23230c9
Fix formatting and analysis warnings
mvanbeusekom Apr 7, 2021
8f17a42
Added missing license header
mvanbeusekom Apr 7, 2021
164700d
Fix analysis warnings
mvanbeusekom Apr 7, 2021
af8a388
Fix typo
mvanbeusekom Apr 7, 2021
a7693bd
Remove NoopInAppPurchase implementation
mvanbeusekom Apr 7, 2021
b80a3c6
Apply feedback from PR
mvanbeusekom Apr 8, 2021
12943f4
Removed obsolete PurchaseException
mvanbeusekom Apr 9, 2021
7ec5de6
Updated documentation per feedback
mvanbeusekom Apr 14, 2021
3ceef85
Fixed formatting
mvanbeusekom Apr 14, 2021
efc6120
Allow nullable instance
mvanbeusekom Apr 14, 2021
e7f6216
Updated readme to reflect setInstance method
mvanbeusekom Apr 14, 2021
24d305b
Removed platform specific comments
mvanbeusekom Apr 21, 2021
d86ac55
Add interfaces to support InAppPurchaseAddition
mvanbeusekom Apr 21, 2021
9eb358f
Document the addition functionality in README
mvanbeusekom Apr 22, 2021
33d1118
Added example code and documentation
mvanbeusekom Apr 22, 2021
a7cea45
Reference the platform_interface
mvanbeusekom Apr 22, 2021
06dd755
Initial iOS specific implementation
mvanbeusekom Apr 26, 2021
21eb28d
Added StoreKit wrapper tests
mvanbeusekom Apr 26, 2021
0cfc84d
Added unit-tests
mvanbeusekom Apr 28, 2021
fa22504
Merged with master
mvanbeusekom Apr 28, 2021
2f115b9
Clean up code
mvanbeusekom Apr 28, 2021
d4e9165
Added initial version of README.md
mvanbeusekom Apr 28, 2021
61dc0be
Fixed typo
mvanbeusekom Apr 28, 2021
a33f312
Added support for iOS specific features
mvanbeusekom Apr 28, 2021
415ac5e
Add missing license headers
mvanbeusekom Apr 28, 2021
70e89cd
Added feedback from PR
mvanbeusekom Apr 29, 2021
99fde90
Merge remote-tracking branch 'upstream/master' into iap_federated_ios…
mvanbeusekom Apr 29, 2021
0474545
Unblock tree by solving lint error
mvanbeusekom Apr 30, 2021
4f723de
Merge remote-tracking branch 'upstream/master' into iap_federated_ios…
mvanbeusekom May 5, 2021
125c490
Implement registerPlatform method for iOS implementation
mvanbeusekom May 5, 2021
67a491f
Added TODO comment to add example
mvanbeusekom May 5, 2021
3d644b5
Added iOS example
mvanbeusekom May 10, 2021
3eb649b
Added iOS integration test
mvanbeusekom May 10, 2021
8ab0aa9
Merged with master
mvanbeusekom May 11, 2021
ec570b4
Merged with master
mvanbeusekom May 11, 2021
ab4eaa0
Update example dependencies
mvanbeusekom May 12, 2021
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
75 changes: 75 additions & 0 deletions packages/in_app_purchase/in_app_purchase_ios/example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# In App Purchase iOS Example

Demonstrates how to use the In App Purchase iOS (IAP) Plugin.

## Getting Started

### Preparation

There's a significant amount of setup required for testing in app purchases
successfully, including registering new app IDs and store entries to use for
testing in App Store Connect. The App Store requires developers to configure
an app with in-app items for purchase to call their in-app-purchase APIs.
The App Store has extensive documentation on how to do this, and we've also
included a high level guide below.

* [In-App Purchase (App Store)](https://developer.apple.com/in-app-purchase/)

### iOS

When using Xcode 12 and iOS 14 or higher you can run the example in the simulator or on a device without
having to configure an App in App Store Connect. The example app is set up to use StoreKit Testing configured
in the `example/ios/Runner/Configuration.storekit` file (as documented in the article [Setting Up StoreKit Testing in Xcode](https://developer.apple.com/documentation/xcode/setting_up_storekit_testing_in_xcode?language=objc)).
To run the application take the following steps (note that it will only work when running from Xcode):

1. Open the example app with Xcode, `File > Open File` `example/ios/Runner.xcworkspace`;

2. Within Xcode edit the current scheme, `Product > Scheme > Edit Scheme...` (or press `Command + Shift + ,`);

3. Enable StoreKit testing:
a. Select the `Run` action;
b. Click `Options` in the action settings;
c. Select the `Configuration.storekit` for the StoreKit Configuration option.

4. Click the `Close` button to close the scheme editor;

5. Select the device you want to run the example App on;

6. Run the application using `Product > Run` (or hit the run button).

When testing on pre-iOS 14 you can't run the example app on a simulator and you will need to configure an app in App Store Connect. You can do so by following the steps below:

1. Follow ["Workflow for configuring in-app
purchases"](https://help.apple.com/app-store-connect/#/devb57be10e7), a
detailed guide on all the steps needed to enable IAPs for an app. Complete
steps 1 ("Sign a Paid Applications Agreement") and 2 ("Configure in-app
purchases").

For step #2, "Configure in-app purchases in App Store Connect," you'll want
to create the following products:

- A consumable with product ID `consumable`
- An upgrade with product ID `upgrade`
- An auto-renewing subscription with product ID `subscription_silver`
- An non-renewing subscription with product ID `subscription_gold`

2. In XCode, `File > Open File` `example/ios/Runner.xcworkspace`. Update the
Bundle ID to match the Bundle ID of the app created in step #1.

3. [Create a Sandbox tester
account](https://help.apple.com/app-store-connect/#/dev8b997bee1) to test the
in-app purchases with.

4. Use `flutter run` to install the app and test it. Note that you need to test
it on a real device instead of a simulator. Next click on one of the products
in the example App, this enables the "SANDBOX ACCOUNT" section in the iOS
settings. You will now be asked to sign in with your sandbox test account to
complete the purchase (no worries you won't be charged). If for some reason
you aren't asked to sign-in or the wrong user is listed, go into the iOS
settings ("Settings" -> "App Store" -> "SANDBOX ACCOUNT") and update your
sandbox account from there. This procedure is explained in great detail in
the [Testing In-App Purchases with Sandbox](https://developer.apple.com/documentation/storekit/in-app_purchase/testing_in-app_purchases_with_sandbox?language=objc) article.


**Important:** signing into any production service (including iTunes!) with the
sandbox test account will permanently invalidate it.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// 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.

// @dart = 2.9
import 'package:flutter_test/flutter_test.dart';
import 'package:in_app_purchase_ios/in_app_purchase_ios.dart';
import 'package:in_app_purchase_platform_interface/in_app_purchase_platform_interface.dart';
import 'package:integration_test/integration_test.dart';

void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

testWidgets('Can create InAppPurchaseAndroid instance',
(WidgetTester tester) async {
InAppPurchaseIosPlatform.registerPlatform();
final InAppPurchasePlatform androidPlatform =
InAppPurchasePlatform.instance;
expect(androidPlatform, isNotNull);
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>App</string>
<key>CFBundleIdentifier</key>
<string>io.flutter.flutter.app</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>App</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>8.0</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"
45 changes: 45 additions & 0 deletions packages/in_app_purchase/in_app_purchase_ios/example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}

def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end

File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))

target 'in_app_purchase_pluginTests' do
inherit! :search_paths

# Matches in_app_purchase test_spec dependency.
pod 'OCMock','3.5'
end
end

post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
Loading