Skip to content

Commit

Permalink
ios-related improvements (#1)
Browse files Browse the repository at this point in the history
* allow to skip navigation parameters

* leave navigation params

* add screenshots
  • Loading branch information
c4t-dr34m authored Jan 8, 2025
1 parent 4f53f55 commit aba7b97
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 14 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ The library was created with a significant contribution from Alza.cz a.s. It's a

## Screenshots

<img src="doc/android_screenshot_1.png" width="200" /> <img src="doc/android_screenshot_2.png" width="200" />
TODO @c4t-dr34m
<img src="doc/android_screenshot_1.png" width="200" /> <img src="doc/android_screenshot_2.png" width="200" /><img src="doc/ios_screenshot_1.png" width="200" /> <img src="doc/ios_screenshot_2.png" width="200" />

## Bank support

Expand Down Expand Up @@ -80,12 +79,11 @@ Add a new entry into `dependencies`: `.package(url: "https://github.com/stepupla
Where appropriate, create an instance of `SpaydPayViaBankAppResolver` and call `.payViaBankApp()` on it.

```swift
SpaydPayViaBankAppResolver().payViaBankApp(spayd: spayd, navParams: NavigationParameters)
SpaydPayViaBankAppResolver().payViaBankApp(spayd: spayd)
```

where:
- `spayd` is a string containing the payment information in the [SPAYD format](https://en.wikipedia.org/wiki/Short_Payment_Descriptor). We recommend [our library](https://github.com/step-up-labs/spayd-kmp) for generating SPAYD on iOS.
- `navParams` is a new instance of `NavigationParameters()`. iOS doesn't need it, it's there just for compatibility with Android.

## How does it work?

Expand Down
Binary file added doc/ios_screenshot_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/ios_screenshot_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 25 additions & 2 deletions iosApp/iosApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/* Begin PBXBuildFile section */
058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557BA273AAA24004C7B11 /* Assets.xcassets */; };
058557D9273AAEEB004C7B11 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */; };
08B321602D2EE0910034ACDD /* PayViaBankApp in Frameworks */ = {isa = PBXBuildFile; productRef = 08B3215F2D2EE0910034ACDD /* PayViaBankApp */; };
2152FB042600AC8F00CF470E /* Application.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2152FB032600AC8F00CF470E /* Application.swift */; };
7555FF83242A565900829871 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7555FF82242A565900829871 /* ContentView.swift */; };
/* End PBXBuildFile section */
Expand All @@ -28,6 +29,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
08B321602D2EE0910034ACDD /* PayViaBankApp in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -113,6 +115,7 @@
);
name = iosApp;
packageProductDependencies = (
08B3215F2D2EE0910034ACDD /* PayViaBankApp */,
);
productName = iosApp;
productReference = 7555FF7B242A565900829871 /* "Pay via Bank App".app */;
Expand Down Expand Up @@ -144,6 +147,7 @@
);
mainGroup = 7555FF72242A565900829871;
packageReferences = (
08B3215E2D2EE0910034ACDD /* XCRemoteSwiftPackageReference "pay-via-bank-app-spm" */,
);
productRefGroup = 7555FF7C242A565900829871 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -328,7 +332,7 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\"";
DEVELOPMENT_TEAM = "${TEAM_ID}";
DEVELOPMENT_TEAM = "";
ENABLE_PREVIEWS = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -359,7 +363,7 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\"";
DEVELOPMENT_TEAM = "${TEAM_ID}";
DEVELOPMENT_TEAM = "";
ENABLE_PREVIEWS = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -404,6 +408,25 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
08B3215E2D2EE0910034ACDD /* XCRemoteSwiftPackageReference "pay-via-bank-app-spm" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/step-up-labs/pay-via-bank-app-spm";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 0.13.0;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
08B3215F2D2EE0910034ACDD /* PayViaBankApp */ = {
isa = XCSwiftPackageProductDependency;
package = 08B3215E2D2EE0910034ACDD /* XCRemoteSwiftPackageReference "pay-via-bank-app-spm" */;
productName = PayViaBankApp;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 7555FF73242A565900829871 /* Project object */;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"originHash" : "57eb09f04601cc988c19a1c5d46b673459c451da9f2f10a17469d6d22e4f995d",
"pins" : [
{
"identity" : "pay-via-bank-app-spm",
"kind" : "remoteSourceControl",
"location" : "https://github.com/step-up-labs/pay-via-bank-app-spm",
"state" : {
"revision" : "5c28fa9ce115e2e538d05bfe67d6f92a2f276c4e",
"version" : "0.13.0"
}
}
],
"version" : 3
}
Binary file not shown.
7 changes: 2 additions & 5 deletions iosApp/iosApp/ContentView.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import shared
import pvba
import SwiftUI

struct ContentView: View {
Expand All @@ -24,10 +24,7 @@ struct ContentView: View {
.padding()

Button(action: {
resolver.payViaBankApp(
spayd: spayd,
navigationParams: NavigationParameters()
)
resolver.payViaBankApp(spayd: spayd, navigationParams: NavigationParameters())
}) {
Label("Pay via bank app", systemImage: "banknote")
.font(.system(.body))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,12 @@ actual class SpaydPayViaBankAppResolver(
*/
actual fun payViaBankApp(
spayd: String,
navigationParams: NavigationParameters
navigationParams: NavigationParameters?
): Result<Unit> {
if (navigationParams == null) {
return Result.failure(Exception("Navigation Parameters has to be specified."))
}

val spaydReceivers = getSpaydReceivers()
val imageReceivers = getImageReceivers()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ expect class SpaydPayViaBankAppResolver {
/**
* Opens a supported bank app with a payment flow or shows a chooser with multiple apps.
*/
fun payViaBankApp(spayd: String, navigationParams: NavigationParameters): Result<Unit>
fun payViaBankApp(spayd: String, navigationParams: NavigationParameters? = null): Result<Unit>
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ actual class SpaydPayViaBankAppResolver {
* Opens a supported bank app with a payment flow or shows a chooser with multiple apps.
*/
@OptIn(ExperimentalForeignApi::class)
actual fun payViaBankApp(spayd: String, navigationParams: NavigationParameters): Result<Unit> {
actual fun payViaBankApp(spayd: String, navigationParams: NavigationParameters?): Result<Unit> {
val qrCode = generateQRCode(spayd as NSString)
val activityItems = listOf(generateActivityItems(qrCode = qrCode))
val activityViewController = UIActivityViewController(
Expand Down

0 comments on commit aba7b97

Please sign in to comment.