Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
237 changes: 237 additions & 0 deletions Bitkit.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Binary file not shown.
102 changes: 102 additions & 0 deletions Bitkit.xcodeproj/xcshareddata/xcschemes/Bitkit.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1540"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "96FE1F602C2DE6AA006D0C8B"
BuildableName = "Bitkit.app"
BlueprintName = "Bitkit"
ReferencedContainer = "container:Bitkit.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
<Testables>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "96FE1F712C2DE6AC006D0C8B"
BuildableName = "BitkitTests.xctest"
BlueprintName = "BitkitTests"
ReferencedContainer = "container:Bitkit.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "96FE1F7B2C2DE6AC006D0C8B"
BuildableName = "BitkitUITests.xctest"
BlueprintName = "BitkitUITests"
ReferencedContainer = "container:Bitkit.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "96FE1F602C2DE6AA006D0C8B"
BuildableName = "Bitkit.app"
BlueprintName = "Bitkit"
ReferencedContainer = "container:Bitkit.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "96FE1F602C2DE6AA006D0C8B"
BuildableName = "Bitkit.app"
BlueprintName = "Bitkit"
ReferencedContainer = "container:Bitkit.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1540"
wasCreatedForAppExtension = "YES"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "961058DB2C355B5500E1F1D8"
BuildableName = "BitkitNotification.appex"
BlueprintName = "BitkitNotification"
ReferencedContainer = "container:Bitkit.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "96FE1F602C2DE6AA006D0C8B"
BuildableName = "Bitkit.app"
BlueprintName = "Bitkit"
ReferencedContainer = "container:Bitkit.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = ""
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
launchStyle = "1"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "96FE1F602C2DE6AA006D0C8B"
BuildableName = "Bitkit.app"
BlueprintName = "Bitkit"
ReferencedContainer = "container:Bitkit.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES"
askForAppToLaunch = "Yes"
launchAutomaticallySubstyle = "2">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "96FE1F602C2DE6AA006D0C8B"
BuildableName = "Bitkit.app"
BlueprintName = "Bitkit"
ReferencedContainer = "container:Bitkit.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
uuid = "D8732CE1-F7D8-45E3-B42F-449ADAA54018"
type = "1"
version = "2.0">
</Bucket>
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,34 @@
<key>orderHint</key>
<integer>0</integer>
</dict>
<key>BitkitNotification.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>961058DB2C355B5500E1F1D8</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>96FE1F602C2DE6AA006D0C8B</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>96FE1F712C2DE6AC006D0C8B</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>96FE1F7B2C2DE6AC006D0C8B</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
16 changes: 12 additions & 4 deletions Bitkit/Bitkit.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,17 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
<key>aps-environment</key>
<string>development</string>
<key>com.apple.developer.aps-environment</key>
<string>development</string>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.application-groups</key>
<array>
<string>group.bitkit</string>
</array>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
</dict>
</plist>
69 changes: 69 additions & 0 deletions Bitkit/BitkitApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,80 @@

import SwiftUI

//TODO move to util and show in onboarding
func requestPushNotificationPermision(completionHandler: @escaping (Bool, Error?) -> Void) {
let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
UNUserNotificationCenter.current().requestAuthorization(
options: authOptions,
completionHandler: completionHandler
)
UIApplication.shared.registerForRemoteNotifications()
}

class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
UNUserNotificationCenter.current().delegate = self

//Permision is requested on coach view appearance
return true
}

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
Logger.debug(userInfo, context: "push notification received")

completionHandler(UIBackgroundFetchResult.newData)
}
}

@available(iOS 10, *)
extension AppDelegate : UNUserNotificationCenterDelegate {
// Receive displayed notifications for iOS 10 devices.
func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
let userInfo = notification.request.content.userInfo

Logger.debug(userInfo, context: "push notification received")

// Change this to your preferred presentation option
completionHandler([[.banner, .badge, .sound]])
}

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
let token = deviceToken.map { String(format: "%02hhx", $0) }.joined()
Logger.debug(token, context: "push token")
}

func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
Logger.error(error)
}

func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
let userInfo = response.notification.request.content.userInfo

Logger.debug(userInfo, context: "push notification received")

completionHandler()
}
}

@main
struct BitkitApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var delegate

var body: some Scene {
WindowGroup {
ContentView()
.onAppear {
//TODO move this elsewhere
requestPushNotificationPermision { (granted, error) in
if granted {
Logger.info("Push notification permission granted")
} else {
Logger.warn("Push notification permission denied")
}
}
}
}
}
}
16 changes: 11 additions & 5 deletions Bitkit/Constants/Env.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ struct Env {
switch network {
case .regtest:
//cargo run --release --bin electrs -- -vvv --jsonrpc-import --daemon-rpc-addr 127.0.0.1:18443 --cookie polaruser:polarpass
// return "https://jaybird-logical-sadly.ngrok-free.app"
return "http://localhost:3000"
// return "https://jaybird-logical-sadly.ngrok-free.app"
// return "http://127.0.0.1:3000"

return "http://192.168.0.106:3000"
case .bitcoin:
fatalError("Bitcoin network not implemented")
case .testnet:
Expand All @@ -42,8 +44,8 @@ struct Env {
}

static var appStorageUrl: URL {
//TODO move to app group so files can be shared with extensions
guard let documentsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first else {
//App group so files can be shared with extensions
guard let documentsDirectory = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.bitkit") else {
fatalError("Could not find documents directory")
}

Expand Down Expand Up @@ -81,7 +83,11 @@ struct Env {
static var trustedLnPeers: [LnPeer] {
switch network {
case .regtest:
return [.init(nodeId: "021de6ad59a78caf8f376cbd022e8c6ede2a1ef0a4fa035174e8b9c25ad5866584", address: "127.0.0.1:9736")]
return [
.init(nodeId: "03e26fdad23b9e17f6a6b1dd0a019c6fcd9e778a1c2af6ae62a0951c8352efbbc3", address: "192.168.0.106:9735")
// .init(nodeId: "0218ab1da83a4768e154fada54deb5d835199aad116c4212e6844d0dce0f82cab1", address: "192.168.0.106:9737"),
// .init(nodeId: "021de6ad59a78caf8f376cbd022e8c6ede2a1ef0a4fa035174e8b9c25ad5866584", address: "192.168.0.106:9738")
]
case .bitcoin:
return []
case .testnet:
Expand Down
Loading