Skip to content

Commit

Permalink
Open lightning url's with Phoenix (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
robbiehanson authored Mar 31, 2021
1 parent 9e7b763 commit 85148bb
Show file tree
Hide file tree
Showing 14 changed files with 643 additions and 303 deletions.
4 changes: 4 additions & 0 deletions phoenix-ios/phoenix-ios.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
DC8107D3255F1FC1002084A3 /* RecoverySeedView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC8107D2255F1FC1002084A3 /* RecoverySeedView.swift */; };
DC81B79F25BF2AA200F5A52C /* MVI.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC81B79E25BF2AA200F5A52C /* MVI.swift */; };
DC89857F25914747007B253F /* UIApplicationState+Phoenix.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC89857E25914747007B253F /* UIApplicationState+Phoenix.swift */; };
DC9473FA261270B4008D7242 /* MVI+Mock.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC9473F9261270B4008D7242 /* MVI+Mock.swift */; };
DC99E90925B78FA800FB20F7 /* EnabledSecurity.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC99E90825B78FA800FB20F7 /* EnabledSecurity.swift */; };
DC99E94025BA141000FB20F7 /* LocalWebView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC99E93F25BA141000FB20F7 /* LocalWebView.swift */; };
DC99E94D25BA258C00FB20F7 /* about.html in Resources */ = {isa = PBXBuildFile; fileRef = DC99E94825BA258C00FB20F7 /* about.html */; };
Expand Down Expand Up @@ -175,6 +176,7 @@
DC8107D2255F1FC1002084A3 /* RecoverySeedView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecoverySeedView.swift; sourceTree = "<group>"; };
DC81B79E25BF2AA200F5A52C /* MVI.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MVI.swift; sourceTree = "<group>"; };
DC89857E25914747007B253F /* UIApplicationState+Phoenix.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIApplicationState+Phoenix.swift"; sourceTree = "<group>"; };
DC9473F9261270B4008D7242 /* MVI+Mock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVI+Mock.swift"; sourceTree = "<group>"; };
DC99E90825B78FA800FB20F7 /* EnabledSecurity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EnabledSecurity.swift; sourceTree = "<group>"; };
DC99E93F25BA141000FB20F7 /* LocalWebView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalWebView.swift; sourceTree = "<group>"; };
DC99E94925BA258C00FB20F7 /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.html; name = Base; path = Base.lproj/about.html; sourceTree = "<group>"; };
Expand Down Expand Up @@ -297,6 +299,7 @@
isa = PBXGroup;
children = (
DC81B79E25BF2AA200F5A52C /* MVI.swift */,
DC9473F9261270B4008D7242 /* MVI+Mock.swift */,
);
path = MVI;
sourceTree = "<group>";
Expand Down Expand Up @@ -754,6 +757,7 @@
C8D7A74B29EAFF2EBD73BC6B /* ConfigurationView.swift in Sources */,
C8D7ABB189B14D3104ABB50D /* AboutView.swift in Sources */,
C8D7AA4B09B32AD99C88BB5E /* DisplayConfigurationView.swift in Sources */,
DC9473FA261270B4008D7242 /* MVI+Mock.swift in Sources */,
C8D7AFF5BC5754DBBEEB2688 /* ElectrumConfigurationView.swift in Sources */,
53BEFBECABE13063AB28A4D6 /* publishers.swift in Sources */,
DC99E94025BA141000FB20F7 /* LocalWebView.swift in Sources */,
Expand Down
8 changes: 6 additions & 2 deletions phoenix-ios/phoenix-ios/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, MessagingDelegate {
private var cancellables = Set<AnyCancellable>()

private var didIncrementDisconnectCount = false

public var externalLightningUrlPublisher = PassthroughSubject<URL, Never>()

override init() {
setenv("CFNETWORK_DIAGNOSTICS", "3", 1);
Expand Down Expand Up @@ -275,10 +277,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate, MessagingDelegate {

func displayLocalNotification(_ payment: Eclair_kmpWalletPayment) {

// We are having problems interacting with the `payment` parameter outside the main thread.
// This might have to do with the goofy Kotlin freezing stuff.
// So let's be safe and always operate on the main thread here.
//
let handler = {(settings: UNNotificationSettings) -> Void in

// We are having problems interacting with the payment instance outside the main thread.

guard settings.authorizationStatus == .authorized else {
return
}
Expand Down
17 changes: 15 additions & 2 deletions phoenix-ios/phoenix-ios/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>CFBundleURLName</key>
<string>co.acinq.phoenix.url.lightning</string>
<key>CFBundleURLSchemes</key>
<array>
<string>lightning</string>
</array>
</dict>
</array>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>FirebaseAppDelegateProxyEnabled</key>
Expand All @@ -24,10 +37,10 @@
<true/>
<key>NSCameraUsageDescription</key>
<string>Phoenix would like to use the camera to scan payment requests.</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>Phoenix would like to save a QR code image to the photo library.</string>
<key>NSFaceIDUsageDescription</key>
<string>Logging in with Face ID.</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>Phoenix would like to save a QR code image to the photo library.</string>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
Expand Down
184 changes: 184 additions & 0 deletions phoenix-ios/phoenix-ios/MVI/MVI+Mock.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
import SwiftUI
import PhoenixShared


extension View {
func mock(_ mock: ChannelsConfiguration.Model) -> some View {
environment(\.controllerFactory, MockControllerFactory(mock))
}
func mock(_ mock: CloseChannelsConfiguration.Model) -> some View {
environment(\.controllerFactory, MockControllerFactory(mock))
}
func mock(_ mock: Configuration.Model) -> some View {
environment(\.controllerFactory, MockControllerFactory(mock))
}
func mock(_ mock: Content.Model) -> some View {
environment(\.controllerFactory, MockControllerFactory(mock))
}
func mock(_ mock: ElectrumConfiguration.Model) -> some View {
environment(\.controllerFactory, MockControllerFactory(mock))
}
func mock(_ mock: Home.Model) -> some View {
environment(\.controllerFactory, MockControllerFactory(mock))
}
func mock(_ mock: Initialization.Model) -> some View {
environment(\.controllerFactory, MockControllerFactory(mock))
}
func mock(_ mock: LogsConfiguration.Model) -> some View {
environment(\.controllerFactory, MockControllerFactory(mock))
}
func mock(_ mock: Receive.Model) -> some View {
environment(\.controllerFactory, MockControllerFactory(mock))
}
func mock(_ mock: RestoreWallet.Model) -> some View {
environment(\.controllerFactory, MockControllerFactory(mock))
}
func mock(_ mock: Scan.Model) -> some View {
environment(\.controllerFactory, MockControllerFactory(mock))
}
}

class MockControllerFactory : ControllerFactory {

let base: ControllerFactory = AppDelegate.get().business.controllers

var mock_channelsConfiguration: ChannelsConfiguration.Model? = nil
init(_ mock: ChannelsConfiguration.Model) {
mock_channelsConfiguration = mock
}
func channelsConfiguration() -> MVIController<ChannelsConfiguration.Model, ChannelsConfiguration.Intent> {
if let mock = mock_channelsConfiguration {
return MVIControllerMock(model: mock)
} else {
return base.channelsConfiguration()
}
}

var mock_closeChannelsConfiguration: CloseChannelsConfiguration.Model? = nil
init(_ mock: CloseChannelsConfiguration.Model) {
mock_closeChannelsConfiguration = mock
}
func closeChannelsConfiguration() -> MVIController<CloseChannelsConfiguration.Model, CloseChannelsConfiguration.Intent> {
if let mock = mock_closeChannelsConfiguration {
return MVIControllerMock(model: mock)
} else {
return base.closeChannelsConfiguration()
}
}

var mock_configuration: Configuration.Model? = nil
init(_ mock: Configuration.Model) {
mock_configuration = mock
}
func configuration() -> MVIController<Configuration.Model, Configuration.Intent> {
if let mock = mock_configuration {
return MVIControllerMock(model: mock)
} else {
return base.configuration()
}
}

var mock_content: Content.Model? = nil
init(_ mock: Content.Model) {
mock_content = mock
}
func content() -> MVIController<Content.Model, Content.Intent> {
if let mock = mock_content {
return MVIControllerMock(model: mock)
} else {
return base.content()
}
}

var mock_electrumConfiguration: ElectrumConfiguration.Model? = nil
init(_ mock: ElectrumConfiguration.Model) {
mock_electrumConfiguration = mock
}
func electrumConfiguration() -> MVIController<ElectrumConfiguration.Model, ElectrumConfiguration.Intent> {
if let mock = mock_electrumConfiguration {
return MVIControllerMock(model: mock)
} else {
return base.electrumConfiguration()
}
}

func forceCloseChannelsConfiguration() -> MVIController<CloseChannelsConfiguration.Model, CloseChannelsConfiguration.Intent> {
if let mock = mock_closeChannelsConfiguration {
return MVIControllerMock(model: mock)
} else {
return base.forceCloseChannelsConfiguration()
}
}

var mock_home: Home.Model? = nil
init(_ mock: Home.Model) {
mock_home = mock
}
func home() -> MVIController<Home.Model, Home.Intent> {
if let mock = mock_home {
return MVIControllerMock(model: mock)
} else {
return base.home()
}
}

var mock_initialization: Initialization.Model? = nil
init(_ mock: Initialization.Model) {
mock_initialization = mock
}
func initialization() -> MVIController<Initialization.Model, Initialization.Intent> {
if let mock = mock_initialization {
return MVIControllerMock(model: mock)
} else {
return base.initialization()
}
}

var mock_logsConfiguration: LogsConfiguration.Model? = nil
init(_ mock: LogsConfiguration.Model) {
mock_logsConfiguration = mock
}
func logsConfiguration() -> MVIController<LogsConfiguration.Model, LogsConfiguration.Intent> {
if let mock = mock_logsConfiguration {
return MVIControllerMock(model: mock)
} else {
return base.logsConfiguration()
}
}

var mock_receive: Receive.Model? = nil
init(_ mock: Receive.Model) {
mock_receive = mock
}
func receive() -> MVIController<Receive.Model, Receive.Intent> {
if let mock = mock_receive {
return MVIControllerMock(model: mock)
} else {
return base.receive()
}
}

var mock_restoreWallet: RestoreWallet.Model? = nil
init(_ mock: RestoreWallet.Model) {
mock_restoreWallet = mock
}
func restoreWallet() -> MVIController<RestoreWallet.Model, RestoreWallet.Intent> {
if let mock = mock_restoreWallet {
return MVIControllerMock(model: mock)
} else {
return base.restoreWallet()
}
}

var mock_scan: Scan.Model? = nil
init(_ mock: Scan.Model) {
mock_scan = mock
}
func scan(firstModel: Scan.Model) -> MVIController<Scan.Model, Scan.Intent> {
if let mock = mock_scan {
return MVIControllerMock(model: mock)
} else {
return base.scan(firstModel: firstModel)
}
}
}
Loading

0 comments on commit 85148bb

Please sign in to comment.