diff --git a/Coinly/Coinly.xcodeproj/project.pbxproj b/Coinly/Coinly.xcodeproj/project.pbxproj index 0709cfa..213dcc3 100644 --- a/Coinly/Coinly.xcodeproj/project.pbxproj +++ b/Coinly/Coinly.xcodeproj/project.pbxproj @@ -6,6 +6,10 @@ objectVersion = 77; objects = { +/* Begin PBXBuildFile section */ + F7DA16952D76075B00FEF25A /* LocalAuthentication.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F7DA16942D76075B00FEF25A /* LocalAuthentication.framework */; }; +/* End PBXBuildFile section */ + /* Begin PBXContainerItemProxy section */ F75D6AD62D75CB060073F403 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; @@ -27,11 +31,25 @@ F75D6AC02D75CB050073F403 /* Coinly.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Coinly.app; sourceTree = BUILT_PRODUCTS_DIR; }; F75D6AD52D75CB060073F403 /* CoinlyTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CoinlyTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; F75D6ADF2D75CB060073F403 /* CoinlyUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CoinlyUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + F7DA16942D76075B00FEF25A /* LocalAuthentication.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = LocalAuthentication.framework; path = System/Library/Frameworks/LocalAuthentication.framework; sourceTree = SDKROOT; }; /* End PBXFileReference section */ +/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */ + F7DA16972D76079A00FEF25A /* Exceptions for "Coinly" folder in "Coinly" target */ = { + isa = PBXFileSystemSynchronizedBuildFileExceptionSet; + membershipExceptions = ( + Info.plist, + ); + target = F75D6ABF2D75CB050073F403 /* Coinly */; + }; +/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */ + /* Begin PBXFileSystemSynchronizedRootGroup section */ F75D6AC22D75CB050073F403 /* Coinly */ = { isa = PBXFileSystemSynchronizedRootGroup; + exceptions = ( + F7DA16972D76079A00FEF25A /* Exceptions for "Coinly" folder in "Coinly" target */, + ); path = Coinly; sourceTree = ""; }; @@ -52,6 +70,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F7DA16952D76075B00FEF25A /* LocalAuthentication.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -78,6 +97,7 @@ F75D6AC22D75CB050073F403 /* Coinly */, F75D6AD82D75CB060073F403 /* CoinlyTests */, F75D6AE22D75CB060073F403 /* CoinlyUITests */, + F7DA16932D76075A00FEF25A /* Frameworks */, F75D6AC12D75CB050073F403 /* Products */, ); sourceTree = ""; @@ -92,6 +112,14 @@ name = Products; sourceTree = ""; }; + F7DA16932D76075A00FEF25A /* Frameworks */ = { + isa = PBXGroup; + children = ( + F7DA16942D76075B00FEF25A /* LocalAuthentication.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -393,12 +421,15 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_ENTITLEMENTS = Coinly/Coinly.entitlements; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_ASSET_PATHS = "\"Coinly/Preview Content\""; DEVELOPMENT_TEAM = DQDRL8F7U2; ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = Coinly/Info.plist; + INFOPLIST_KEY_LSApplicationCategoryType = ""; INFOPLIST_KEY_NSFaceIDUsageDescription = "Coinly uses Face ID to securely access your financial data"; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; @@ -423,12 +454,15 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_ENTITLEMENTS = Coinly/Coinly.entitlements; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_ASSET_PATHS = "\"Coinly/Preview Content\""; DEVELOPMENT_TEAM = DQDRL8F7U2; ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = Coinly/Info.plist; + INFOPLIST_KEY_LSApplicationCategoryType = ""; INFOPLIST_KEY_NSFaceIDUsageDescription = "Coinly uses Face ID to securely access your financial data"; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; diff --git a/Coinly/Coinly.xcodeproj/project.xcworkspace/xcuserdata/vadymsamoilenko.xcuserdatad/UserInterfaceState.xcuserstate b/Coinly/Coinly.xcodeproj/project.xcworkspace/xcuserdata/vadymsamoilenko.xcuserdatad/UserInterfaceState.xcuserstate index 5963058..af1b6cf 100644 Binary files a/Coinly/Coinly.xcodeproj/project.xcworkspace/xcuserdata/vadymsamoilenko.xcuserdatad/UserInterfaceState.xcuserstate and b/Coinly/Coinly.xcodeproj/project.xcworkspace/xcuserdata/vadymsamoilenko.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Coinly/Coinly/App/AppDelegate.swift b/Coinly/Coinly/App/AppDelegate.swift index 8e3a2fd..72274e6 100644 --- a/Coinly/Coinly/App/AppDelegate.swift +++ b/Coinly/Coinly/App/AppDelegate.swift @@ -1,15 +1,8 @@ -// -// AppDelegate.swift -// Coinly -// -// Created by Vadym Samoilenko on 03/03/2025. -// - - import UIKit import UserNotifications class AppDelegate: NSObject, UIApplicationDelegate, UNUserNotificationCenterDelegate { + func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil @@ -20,9 +13,37 @@ class AppDelegate: NSObject, UIApplicationDelegate, UNUserNotificationCenterDele // Set notification delegate UNUserNotificationCenter.current().delegate = self + // Request notification authorization + requestNotificationPermission() + + // Register for remote notifications + application.registerForRemoteNotifications() + return true } + private func requestNotificationPermission() { + UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { success, error in + if success { + print("Notification permission granted") + } else if let error = error { + print("Error requesting notification permission: \(error.localizedDescription)") + } + } + } + + // Handle successful registration of remote notifications + func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { + let tokenParts = deviceToken.map { data in String(format: "%02.2hhx", data) } + let token = tokenParts.joined() + print("Device Token: \(token)") + } + + // Handle failed registration of remote notifications + func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) { + print("Failed to register for remote notifications: \(error)") + } + // MARK: - UNUserNotificationCenterDelegate func userNotificationCenter( _ center: UNUserNotificationCenter, @@ -40,4 +61,4 @@ class AppDelegate: NSObject, UIApplicationDelegate, UNUserNotificationCenterDele // Handle notification response completionHandler() } -} \ No newline at end of file +} diff --git a/Coinly/Coinly/Coinly.entitlements b/Coinly/Coinly/Coinly.entitlements new file mode 100644 index 0000000..0c67376 --- /dev/null +++ b/Coinly/Coinly/Coinly.entitlements @@ -0,0 +1,5 @@ + + + + + diff --git a/Coinly/Coinly/Info.plist b/Coinly/Coinly/Info.plist new file mode 100644 index 0000000..ca9a074 --- /dev/null +++ b/Coinly/Coinly/Info.plist @@ -0,0 +1,10 @@ + + + + + UIBackgroundModes + + remote-notification + + +