Skip to content

Commit

Permalink
Fix StripeApplePay in App Extensions (#2860)
Browse files Browse the repository at this point in the history
## Summary
Fix StripeApplePay support in App Extensions.

## Motivation
#2853

## Testing
Added a Cocoapods test to build an iMessage App Extension with the
StripeApplePay SDK.

## Changelog
Updated
  • Loading branch information
davidme-stripe authored and lisaliu-stripe committed Aug 22, 2023
1 parent bba9f5a commit 3648ce2
Show file tree
Hide file tree
Showing 9 changed files with 442 additions and 2 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## 23.14.0 2023-08-21
## x.x.x x-x-x
### StripeApplePay
* Fixed a compile-time issue with using StripeApplePay in an App Extension. ([#2853](https://github.com/stripe/stripe-ios/issues/2853))

## 23.14.0 2023-08-21
### All
* Improved redirect UX when using Cash App Pay.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ public class STPApplePayContext: NSObject, PKPaymentAuthorizationControllerDeleg
/// @note This method should only be called once; create a new instance of STPApplePayContext every time you present Apple Pay.
/// - Parameters:
/// - completion: Called after the Apple Pay sheet is presented
@available(iOSApplicationExtension, unavailable)
@available(macCatalystApplicationExtension, unavailable)
@objc(presentApplePayWithCompletion:)
public func presentApplePay(completion: STPVoidBlock? = nil) {
let window = UIApplication.shared.windows.first { $0.isKeyWindow }
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,10 @@ target 'CocoapodsTest' do
inherit! :search_paths
end
end

target 'TestExtension' do
platform :ios, '13.0'
use_frameworks!
pod 'StripeApplePay', path: '../../../..'
pod 'StripeCore', path: '../../../..'
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"images" : [
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "60x45"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "60x45"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "67x50"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "74x55"
},
{
"idiom" : "ios-marketing",
"scale" : "1x",
"size" : "1024x1024"
},
{
"idiom" : "universal",
"platform" : "ios",
"scale" : "2x",
"size" : "27x20"
},
{
"idiom" : "universal",
"platform" : "ios",
"scale" : "3x",
"size" : "27x20"
},
{
"idiom" : "universal",
"platform" : "ios",
"scale" : "2x",
"size" : "32x24"
},
{
"idiom" : "universal",
"platform" : "ios",
"scale" : "3x",
"size" : "32x24"
},
{
"idiom" : "ios-marketing",
"platform" : "ios",
"scale" : "1x",
"size" : "1024x768"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="ObA-dk-sSI">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Messages View Controller-->
<scene sceneID="7MM-of-jgj">
<objects>
<viewController id="ObA-dk-sSI" customClass="MessagesViewController" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="zMn-AG-sqS">
<rect key="frame" x="0.0" y="0.0" width="320" height="528"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Hello World" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="d1e-fi-ked">
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" xcode11CocoaTouchSystemColor="labelColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<constraints>
<constraint firstAttribute="centerY" secondItem="d1e-fi-ked" secondAttribute="centerY" id="H0s-hz-dDP"/>
<constraint firstAttribute="centerX" secondItem="d1e-fi-ked" secondAttribute="centerX" id="wFy-hW-Bib"/>
</constraints>
<viewLayoutGuide key="safeArea" id="LDy-ih-0nr"/>
</view>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<size key="freeformSize" width="320" height="528"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="X47-rx-isc" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
</scene>
</scenes>
</document>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?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>NSExtension</key>
<dict>
<key>NSExtensionMainStoryboard</key>
<string>MainInterface</string>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.message-payload-provider</string>
</dict>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
//
// MessagesViewController.swift
// TestExtension
//
// Created by David Estes on 8/21/23.
// Copyright © 2023 jflinter. All rights reserved.
//

import UIKit
import Messages
import StripeApplePay

class MessagesViewController: MSMessagesAppViewController {

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}

// MARK: - Conversation Handling

override func willBecomeActive(with conversation: MSConversation) {
// Called when the extension is about to move from the inactive to active state.
// This will happen when the extension is about to present UI.

// Use this method to configure the extension and restore previously stored state.
}

override func didResignActive(with conversation: MSConversation) {
// Called when the extension is about to move from the active to inactive state.
// This will happen when the user dismisses the extension, changes to a different
// conversation or quits Messages.

// Use this method to release shared resources, save user data, invalidate timers,
// and store enough state information to restore your extension to its current state
// in case it is terminated later.
}

override func didReceive(_ message: MSMessage, conversation: MSConversation) {
// Called when a message arrives that was generated by another instance of this
// extension on a remote device.

// Use this method to trigger UI updates in response to the message.
}

override func didStartSending(_ message: MSMessage, conversation: MSConversation) {
// Called when the user taps the send button.
}

override func didCancelSending(_ message: MSMessage, conversation: MSConversation) {
// Called when the user deletes the message without sending it.

// Use this to clean up state related to the deleted message.
}

override func willTransition(to presentationStyle: MSMessagesAppPresentationStyle) {
// Called before the extension transitions to a new presentation style.

// Use this method to prepare for the change in presentation style.
}

override func didTransition(to presentationStyle: MSMessagesAppPresentationStyle) {
// Called after the extension transitions to a new presentation style.

// Use this method to finalize any behaviors associated with the change in presentation style.
}

}

0 comments on commit 3648ce2

Please sign in to comment.