club_update
Laurent 1 year ago
parent 4c6b1d8e31
commit b74be29257
  1. 4
      PadelClub.xcodeproj/project.pbxproj
  2. 68
      PadelClub/AppDelegate.swift
  3. 5
      PadelClub/PadelClub.entitlements
  4. 5
      PadelClub/PadelClubApp.swift

@ -7,6 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
C40CD2F32C412681000DBD9A /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40CD2F22C412681000DBD9A /* AppDelegate.swift */; };
C411C9C32BEBA453003017AD /* ServerDataTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C411C9C22BEBA453003017AD /* ServerDataTests.swift */; };
C411C9C92BF219CB003017AD /* UserDataTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C411C9C82BF219CB003017AD /* UserDataTests.swift */; };
C411C9D02BF38F41003017AD /* TokenExemptionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C411C9CF2BF38F41003017AD /* TokenExemptionTests.swift */; };
@ -298,6 +299,7 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
C40CD2F22C412681000DBD9A /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
C411C9C22BEBA453003017AD /* ServerDataTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerDataTests.swift; sourceTree = "<group>"; };
C411C9C82BF219CB003017AD /* UserDataTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDataTests.swift; sourceTree = "<group>"; };
C411C9CC2BF21DAF003017AD /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
@ -660,6 +662,7 @@
FFA6D78A2BB0BEB3003A31F3 /* Info.plist */,
C4EC6F562BE92CAC000CEAB4 /* local.plist */,
C425D4002B6D249D002A7B48 /* PadelClubApp.swift */,
C40CD2F22C412681000DBD9A /* AppDelegate.swift */,
C45BAE3A2BC6DF10002EEC8A /* SyncedProducts.storekit */,
FFD784002B91BF79000F62A6 /* Launch Screen.storyboard */,
C4A47D722B72881500ADC637 /* Views */,
@ -1571,6 +1574,7 @@
FFCFC00E2BBC3D4600B82851 /* PointSelectionView.swift in Sources */,
FF089EB62BB00A3800F0AEC7 /* TeamRowView.swift in Sources */,
FF92680B2BCEE3E10080F940 /* ContactManager.swift in Sources */,
C40CD2F32C412681000DBD9A /* AppDelegate.swift in Sources */,
C49EF0262BD80AE80077B5AA /* SubscriptionInfoView.swift in Sources */,
FFCFC00C2BBC3D1E00B82851 /* EditScoreView.swift in Sources */,
FF7091622B90F04300AB08DA /* TournamentOrganizerView.swift in Sources */,

@ -0,0 +1,68 @@
//
// AppDelegate.swift
// PadelClub
//
// Created by Laurent Morvillier on 12/07/2024.
//
import Foundation
import UIKit
import LeStorage
import UserNotifications
class AppDelegate : NSObject, UIApplicationDelegate, UNUserNotificationCenterDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions:[UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
UIApplication.shared.registerForRemoteNotifications()
UNUserNotificationCenter.current().delegate = self
Logger.log("didFinishLaunchingWithOptions")
return true
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
if StoreCenter.main.hasToken() {
Task {
do {
let services = try StoreCenter.main.service()
try await services.postDeviceToken(deviceToken: deviceToken)
} catch {
Logger.error(error)
}
}
}
// Logger.log("token = \(deviceToken)")
}
func application(_ application: UIApplication,
didFailToRegisterForRemoteNotificationsWithError
error: Error) {
Logger.error(error)
}
// MARK: - UNUserNotificationCenterDelegate
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
// Show the notification as a banner even when the app is in the foreground
completionHandler([.banner, .sound, .badge])
}
// Handle notifications when the user taps on them
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
let userInfo = response.notification.request.content.userInfo
// Handle the notification content here
print("User Info: \(userInfo)")
// Perform your custom actions based on the notification content
completionHandler()
}
static func askPermissions() {
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound]) { success, error in
print("requestAuthorization > success = \(success), error = \(String(describing: error))")
}
}
}

@ -1,5 +1,8 @@
<?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/>
<dict>
<key>aps-environment</key>
<string>development</string>
</dict>
</plist>

@ -17,6 +17,8 @@ struct PadelClubApp: App {
@StateObject var dataStore = DataStore.shared
@State private var registrationError: RegistrationError? = nil
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var presentError: Binding<Bool> {
Binding {
registrationError != nil
@ -137,6 +139,9 @@ struct PadelClubApp: App {
let docURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
Logger.log("doc dir = \(docURL.absoluteString)")
UserDefaults.standard.set(false, forKey: "_UIConstraintBasedLayoutLogUnsatisfiable")
// AppDelegate.askPermissions()
}

Loading…
Cancel
Save