From db66ab7c252eedc9b49120e14cd08a893b26d862 Mon Sep 17 00:00:00 2001 From: "jijo.pulikkottil" Date: Thu, 18 Jul 2024 15:57:13 +0530 Subject: [PATCH 1/2] streak widget optimization --- CustomNotification/Info.plist | 2 +- NotificationService/Info.plist | 2 +- Shared/EndPoint.swift | 2 +- StreakWidget/StreakWidget.swift | 86 +++++++++++++------ StreakWidgetHelper/StreakWidgetHelper.swift | 54 +++++++++--- mindLAMP.xcodeproj/project.pbxproj | 66 +++++++------- .../xcshareddata/swiftpm/Package.resolved | 15 ---- .../xcschemes/mindLAMP (Staging).xcscheme | 15 +++- mindLAMP/AppDelegate.swift | 16 +++- mindLAMP/Home/HomeViewController.swift | 33 ++++++- mindLAMP/Info.plist | 17 +++- 11 files changed, 213 insertions(+), 95 deletions(-) delete mode 100644 mindLAMP.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved diff --git a/CustomNotification/Info.plist b/CustomNotification/Info.plist index dd116a6..8967426 100644 --- a/CustomNotification/Info.plist +++ b/CustomNotification/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString $(MARKETING_VERSION) CFBundleVersion - 408 + 424 DASHBOARD_URL $(DASHBOARD_URL) NSExtension diff --git a/NotificationService/Info.plist b/NotificationService/Info.plist index 3506851..5c69ac7 100644 --- a/NotificationService/Info.plist +++ b/NotificationService/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString $(MARKETING_VERSION) CFBundleVersion - 408 + 424 NSExtension NSExtensionPointIdentifier diff --git a/Shared/EndPoint.swift b/Shared/EndPoint.swift index 31c9c24..f76570a 100644 --- a/Shared/EndPoint.swift +++ b/Shared/EndPoint.swift @@ -9,7 +9,7 @@ enum Endpoint: String { case sensor = "/participant/%@/sensor" case getParticipant = "/participant/me" case activity = "/participant/%@/activity?ignore_binary=true" - case activityEvent = "/participant/%@/activity_event" + case activityEvent = "/participant/%@/activity_event"//?ignore_binary=true case getLatestDashboard = "/version/get" diff --git a/StreakWidget/StreakWidget.swift b/StreakWidget/StreakWidget.swift index e4e7d16..3067f2b 100644 --- a/StreakWidget/StreakWidget.swift +++ b/StreakWidget/StreakWidget.swift @@ -23,18 +23,24 @@ struct Provider: TimelineProvider { func getTimeline(in context: Context, completion: @escaping (Timeline) -> ()) { helper.fetchActivityEvents(participantId: UserDefaults.standard.participantIdShared) { dates in - guard let dates else { - return - } - let reslut = (UserDefaults.standard.streakDataCurrentShared, UserDefaults.standard.streakDataMaxShared) - - let entry = SimpleEntry(date: Date(), currentStreak: reslut.0, longestStreak: reslut.1) //Next fetch happens 15 minutes later let nextUpdate = Calendar.current.date( byAdding: DateComponents(hour: 4), to: Date() )! + guard dates != nil else { + let entry = SimpleEntry(date: Date(), currentStreak: 0, longestStreak: 0) + let timeline = Timeline( + entries: [entry], + policy: .after(nextUpdate) + ) + completion(timeline) + return + } + let reslut = (UserDefaults.standard.streakDataCurrentShared, UserDefaults.standard.streakDataMaxShared) + + let entry = SimpleEntry(date: Date(), currentStreak: reslut.0, longestStreak: reslut.1) let timeline = Timeline( entries: [entry], @@ -54,28 +60,56 @@ struct SimpleEntry: TimelineEntry { struct StreakWidgetEntryView : View { var entry: Provider.Entry + @SwiftUI.Environment(\.widgetFamily) var family + @ViewBuilder var body: some View { - VStack(alignment: .center, spacing: 5) { - - Image("logo") - .resizable() - .aspectRatio(contentMode: .fit) - .frame(width: 40) - - let daysText1: String = entry.currentStreak == 1 ? "day" : "days" - Text("Current streak: \(entry.currentStreak) \(daysText1)") - .font(.system(size: 12)) - .fontWeight(.black) - - let daysText: String = entry.longestStreak == 1 ? "day" : "days" - Text("Longest Streak: \(entry.longestStreak) \(daysText)") - .font(.system(size: 12)) - .fontWeight(.black) - - Text("Way To Go!") - .font(.system(size: 14)) - .fontWeight(.bold) + + switch family { + case .systemSmall: + VStack(alignment: .center, spacing: 5) { + + Image("logo") + .resizable() + .aspectRatio(contentMode: .fit) + .frame(width: 36) + + let daysText1: String = entry.currentStreak == 1 ? "day" : "days" + Text("Current streak: \(entry.currentStreak) \(daysText1)") + .font(.system(size: 10)) + .fontWeight(.medium) + + let daysText: String = entry.longestStreak == 1 ? "day" : "days" + Text("Longest Streak: \(entry.longestStreak) \(daysText)") + .font(.system(size: 10)) + .fontWeight(.medium) + + Text("Way To Go!") + .font(.system(size: 11)) + .fontWeight(.medium) + } + default: + VStack(alignment: .center, spacing: 5) { + + Image("logo") + .resizable() + .aspectRatio(contentMode: .fit) + .frame(width: 40) + + let daysText1: String = entry.currentStreak == 1 ? "day" : "days" + Text("Current streak: \(entry.currentStreak) \(daysText1)") + .font(.system(size: 14)) + .fontWeight(.medium) + + let daysText: String = entry.longestStreak == 1 ? "day" : "days" + Text("Longest Streak: \(entry.longestStreak) \(daysText)") + .font(.system(size: 14)) + .fontWeight(.medium) + + Text("Way To Go!") + .font(.system(size: 15)) + .fontWeight(.medium) + } } } } diff --git a/StreakWidgetHelper/StreakWidgetHelper.swift b/StreakWidgetHelper/StreakWidgetHelper.swift index c8790df..bbd9835 100644 --- a/StreakWidgetHelper/StreakWidgetHelper.swift +++ b/StreakWidgetHelper/StreakWidgetHelper.swift @@ -22,35 +22,54 @@ public class StreakWidgetHelper { } } static var cachedEntry:(Int, Int) = (0, 0) + + func longestStreakFor(participantId: String) -> Int { + let dict: [String: Int]? = UserDefaults.standard.object(forKey: "longestActivityStreak") as? [String: Int] + return dict?[participantId] ?? 0 + } + + func setLongestStreak(streak: Int, participantId: String) { + let dict: [String: Int] = [participantId: streak] + UserDefaults.standard.setValue(dict, forKey: "longestActivityStreak") + } + public func fetchActivityEvents(participantId: String?, completion: (([Date]?) -> Void)?) { guard let participantId else { completion?(nil) return } - //todo execute once per day - - //update server - let task = URLSession.shared.dataTask(with: urlRequest(participantId: participantId)) { [weak self] data, response, error in - + let fromDate: Date + if longestStreakFor(participantId: participantId) <= 0 { + fromDate = Calendar.current.date(byAdding: .year, value: -1, to: Date())! + } else { + fromDate = Calendar.current.date(byAdding: .month, value: -3, to: Date())! + } + + let task = URLSession.shared.dataTask(with: urlRequest(participantId: participantId, fromDate: fromDate)) { [weak self] data, response, error in + if let data, let urlResponse = response as? HTTPURLResponse { + + let decoder = JSONDecoder() let formatter = ISO8601DateFormatter() decoder.dateDecodingStrategy = .formatted(formatter) do { let responseData = try decoder.decode(ActivityEventResponse.self, from: data) - let reslut = self?.findCurentAndLongestStreak(dates: responseData.dates ?? []) + + UserDefaults.standard.streakDataCurrentShared = reslut?.0 ?? 0 UserDefaults.standard.streakDataMaxShared = reslut?.1 ?? 0 + + self?.setLongestStreak(streak: reslut?.1 ?? 0, participantId: participantId) if let reslut { StreakWidgetHelper.cachedEntry = reslut } completion?(responseData.dates) - } catch (let err) { completion?(nil) } @@ -87,12 +106,21 @@ public class StreakWidgetHelper { // } } - func urlRequest(participantId: String) -> URLRequest { - + func urlRequest(participantId: String, fromDate: Date) -> URLRequest { + //from to timestamp let endPoint = String(format: Endpoint.activityEvent.rawValue, participantId) - let baseURL = URL(string: LampURL.baseURLString)! - var request = URLRequest(url: baseURL.appendingPathComponent(endPoint)) + let fullurl = baseURL.appendingPathComponent(endPoint) + //https://api-staging.lamp.digital/participant/U2604494105/activity_event?from=1719945000516&to=1720031400516 + var components = URLComponents(string: fullurl.absoluteString)! + + components.queryItems = [ + URLQueryItem(name: "from", value: String(fromDate.timeInMilliSeconds)), + //URLQueryItem(name: "to", value: String(Date().timeInMilliSeconds)), + ] + let url = components.url! + + var request = URLRequest(url: url) request.httpMethod = "GET" var requestHeaders = [String: String]() requestHeaders["Content-Type"] = "application/json" @@ -123,14 +151,12 @@ public class StreakWidgetHelper { var uniqueDaysArray = [Date]() let dateFormatter = DateFormatter() - dateFormatter.timeZone = .current + dateFormatter.timeZone = TimeZone(secondsFromGMT: 0) dateFormatter.locale = Locale(identifier: "en_US_POSIX") dateFormatter.dateFormat = "yyyy-MM-dd" for date in dates { - print("date = \(date)") let dayString = dateFormatter.string(from: date) - print("dayString = \(dayString)") if !uniqueDaysSet.contains(dayString) { uniqueDaysSet.insert(dayString) uniqueDaysArray.append(dateFormatter.date(from: dayString)!) diff --git a/mindLAMP.xcodeproj/project.pbxproj b/mindLAMP.xcodeproj/project.pbxproj index 2b3691f..28ecab6 100644 --- a/mindLAMP.xcodeproj/project.pbxproj +++ b/mindLAMP.xcodeproj/project.pbxproj @@ -263,6 +263,7 @@ B2201C79257FA60500C40183 /* NotificationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationView.swift; sourceTree = ""; }; B2201C85257FADC700C40183 /* HomeView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = ""; }; B22DF5F1250612E800777D2D /* UserAgentExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserAgentExtension.swift; sourceTree = ""; }; + B230E5E72C2BD1A00061DA68 /* LAMP-swift */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = "LAMP-swift"; path = "../../LAMP-Swift/LAMP-swift"; sourceTree = ""; }; B2346CE62599CEDF00EFF347 /* SensorDataModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SensorDataModel.swift; sourceTree = ""; }; B2346CEE2599DE9800EFF347 /* AppInfo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppInfo.swift; sourceTree = ""; }; B238434624B848F300E548E2 /* LMRunningBuffer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LMRunningBuffer.swift; sourceTree = ""; }; @@ -658,6 +659,7 @@ B29639C423BDC28100626E1A = { isa = PBXGroup; children = ( + B230E5E72C2BD1A00061DA68 /* LAMP-swift */, B2657AB92C11B8AF009AFC3B /* StreakWidgetExtension.entitlements */, B2587B49256E23BC00A2A7F2 /* Shared */, B2A15BB22567A8BE00222717 /* SharedToWatchExt */, @@ -1671,7 +1673,7 @@ CODE_SIGN_ENTITLEMENTS = mindLAMP/mindLAMP.entitlements; CODE_SIGN_IDENTITY = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 412; + CURRENT_PROJECT_VERSION = 424; DEVELOPMENT_ASSET_PATHS = "\"mindLAMP/Preview Content\""; DEVELOPMENT_TEAM = S2Y2D4239K; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = S2Y2D4239K; @@ -1684,7 +1686,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2023.8.25; + MARKETING_VERSION = 2024.6.15; ONLY_ACTIVE_ARCH = YES; OTHER_LDFLAGS = "-ObjC"; PRODUCT_BUNDLE_IDENTIFIER = digital.lamp.mindlamp; @@ -1712,7 +1714,7 @@ CODE_SIGN_ENTITLEMENTS = CustomNotification/CustomNotification.entitlements; CODE_SIGN_IDENTITY = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 408; + CURRENT_PROJECT_VERSION = 424; DEVELOPMENT_TEAM = S2Y2D4239K; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = S2Y2D4239K; INFOPLIST_FILE = CustomNotification/Info.plist; @@ -1722,7 +1724,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 2023.8.25; + MARKETING_VERSION = 2024.6.15; PRODUCT_BUNDLE_IDENTIFIER = digital.lamp.mindlamp.CustomNotification; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "mindLAMP2 Custom Notification Extension"; @@ -1745,7 +1747,7 @@ CODE_SIGN_ENTITLEMENTS = NotificationService/NotificationService.entitlements; CODE_SIGN_IDENTITY = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 408; + CURRENT_PROJECT_VERSION = 424; DEVELOPMENT_TEAM = S2Y2D4239K; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = S2Y2D4239K; INFOPLIST_FILE = NotificationService/Info.plist; @@ -1755,7 +1757,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 2023.8.25; + MARKETING_VERSION = 2024.6.15; PRODUCT_BUNDLE_IDENTIFIER = digital.lamp.mindlamp.NotificationService; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "mindLAMP2 Notification Service"; @@ -1781,7 +1783,7 @@ CODE_SIGN_ENTITLEMENTS = "watchkitapp Extension/watchkitapp Extension.entitlements"; CODE_SIGN_IDENTITY = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 412; + CURRENT_PROJECT_VERSION = 424; DEVELOPMENT_TEAM = S2Y2D4239K; "DEVELOPMENT_TEAM[sdk=watchos*]" = S2Y2D4239K; INFOPLIST_FILE = watchkitapp/Info.plist; @@ -1789,7 +1791,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 2023.8.25; + MARKETING_VERSION = 2024.6.15; PRODUCT_BUNDLE_IDENTIFIER = digital.lamp.mindlamp.wearable; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "mindLAMP WatchApp Dev"; @@ -1872,7 +1874,7 @@ CODE_SIGN_ENTITLEMENTS = mindLAMP/mindLAMP.entitlements; CODE_SIGN_IDENTITY = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 412; + CURRENT_PROJECT_VERSION = 424; DEVELOPMENT_ASSET_PATHS = "\"mindLAMP/Preview Content\""; DEVELOPMENT_TEAM = S2Y2D4239K; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = S2Y2D4239K; @@ -1885,7 +1887,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2023.8.25; + MARKETING_VERSION = 2024.6.15; ONLY_ACTIVE_ARCH = YES; OTHER_LDFLAGS = "-ObjC"; PRODUCT_BUNDLE_IDENTIFIER = digital.lamp.mindlamp; @@ -1912,7 +1914,7 @@ CODE_SIGN_ENTITLEMENTS = CustomNotification/CustomNotification.entitlements; CODE_SIGN_IDENTITY = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 408; + CURRENT_PROJECT_VERSION = 424; DEVELOPMENT_TEAM = S2Y2D4239K; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = S2Y2D4239K; INFOPLIST_FILE = CustomNotification/Info.plist; @@ -1922,7 +1924,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 2023.8.25; + MARKETING_VERSION = 2024.6.15; PRODUCT_BUNDLE_IDENTIFIER = digital.lamp.mindlamp.CustomNotification; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "mindLAMP2 Custom Notification Extension"; @@ -1945,7 +1947,7 @@ CODE_SIGN_ENTITLEMENTS = NotificationService/NotificationService.entitlements; CODE_SIGN_IDENTITY = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 408; + CURRENT_PROJECT_VERSION = 424; DEVELOPMENT_TEAM = S2Y2D4239K; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = S2Y2D4239K; INFOPLIST_FILE = NotificationService/Info.plist; @@ -1955,7 +1957,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 2023.8.25; + MARKETING_VERSION = 2024.6.15; PRODUCT_BUNDLE_IDENTIFIER = digital.lamp.mindlamp.NotificationService; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "mindLAMP2 Notification Service"; @@ -1981,7 +1983,7 @@ CODE_SIGN_ENTITLEMENTS = "watchkitapp Extension/watchkitapp Extension.entitlements"; CODE_SIGN_IDENTITY = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 412; + CURRENT_PROJECT_VERSION = 424; DEVELOPMENT_TEAM = S2Y2D4239K; "DEVELOPMENT_TEAM[sdk=watchos*]" = S2Y2D4239K; INFOPLIST_FILE = watchkitapp/Info.plist; @@ -1989,7 +1991,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 2023.8.25; + MARKETING_VERSION = 2024.6.15; PRODUCT_BUNDLE_IDENTIFIER = digital.lamp.mindlamp.wearable; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "mindLAMP WatchApp Dev"; @@ -2283,7 +2285,7 @@ CODE_SIGN_ENTITLEMENTS = "watchkitapp Extension/watchkitapp Extension.entitlements"; CODE_SIGN_IDENTITY = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 412; + CURRENT_PROJECT_VERSION = 424; DEVELOPMENT_TEAM = S2Y2D4239K; "DEVELOPMENT_TEAM[sdk=watchos*]" = S2Y2D4239K; INFOPLIST_FILE = watchkitapp/Info.plist; @@ -2291,7 +2293,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 2023.8.25; + MARKETING_VERSION = 2024.6.15; PRODUCT_BUNDLE_IDENTIFIER = digital.lamp.mindlamp.wearable; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "mindLAMP WatchApp Dev"; @@ -2315,7 +2317,7 @@ CODE_SIGN_ENTITLEMENTS = "watchkitapp Extension/watchkitapp Extension.entitlements"; CODE_SIGN_IDENTITY = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 412; + CURRENT_PROJECT_VERSION = 424; DEVELOPMENT_TEAM = S2Y2D4239K; "DEVELOPMENT_TEAM[sdk=watchos*]" = S2Y2D4239K; INFOPLIST_FILE = watchkitapp/Info.plist; @@ -2323,7 +2325,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 2023.8.25; + MARKETING_VERSION = 2024.6.15; PRODUCT_BUNDLE_IDENTIFIER = digital.lamp.mindlamp.wearable; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "mindLAMP WatchApp Dev"; @@ -2344,7 +2346,7 @@ CODE_SIGN_ENTITLEMENTS = NotificationService/NotificationService.entitlements; CODE_SIGN_IDENTITY = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 408; + CURRENT_PROJECT_VERSION = 424; DEVELOPMENT_TEAM = S2Y2D4239K; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = S2Y2D4239K; INFOPLIST_FILE = NotificationService/Info.plist; @@ -2354,7 +2356,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 2023.8.25; + MARKETING_VERSION = 2024.6.15; PRODUCT_BUNDLE_IDENTIFIER = digital.lamp.mindlamp.NotificationService; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "mindLAMP2 Notification Service"; @@ -2377,7 +2379,7 @@ CODE_SIGN_ENTITLEMENTS = NotificationService/NotificationService.entitlements; CODE_SIGN_IDENTITY = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 408; + CURRENT_PROJECT_VERSION = 424; DEVELOPMENT_TEAM = S2Y2D4239K; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = S2Y2D4239K; INFOPLIST_FILE = NotificationService/Info.plist; @@ -2387,7 +2389,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 2023.8.25; + MARKETING_VERSION = 2024.6.15; PRODUCT_BUNDLE_IDENTIFIER = digital.lamp.mindlamp.NotificationService; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "mindLAMP2 Notification Service"; @@ -2537,7 +2539,7 @@ CODE_SIGN_ENTITLEMENTS = mindLAMP/mindLAMP.entitlements; CODE_SIGN_IDENTITY = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 412; + CURRENT_PROJECT_VERSION = 424; DEVELOPMENT_ASSET_PATHS = "\"mindLAMP/Preview Content\""; DEVELOPMENT_TEAM = S2Y2D4239K; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = S2Y2D4239K; @@ -2550,7 +2552,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2023.8.25; + MARKETING_VERSION = 2024.6.15; ONLY_ACTIVE_ARCH = YES; OTHER_LDFLAGS = "-ObjC"; PRODUCT_BUNDLE_IDENTIFIER = digital.lamp.mindlamp; @@ -2581,7 +2583,7 @@ CODE_SIGN_ENTITLEMENTS = mindLAMP/mindLAMP.entitlements; CODE_SIGN_IDENTITY = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 412; + CURRENT_PROJECT_VERSION = 424; DEVELOPMENT_ASSET_PATHS = "\"mindLAMP/Preview Content\""; DEVELOPMENT_TEAM = S2Y2D4239K; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = S2Y2D4239K; @@ -2594,7 +2596,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 2023.8.25; + MARKETING_VERSION = 2024.6.15; ONLY_ACTIVE_ARCH = YES; OTHER_LDFLAGS = "-ObjC"; PRODUCT_BUNDLE_IDENTIFIER = digital.lamp.mindlamp; @@ -2621,7 +2623,7 @@ CODE_SIGN_ENTITLEMENTS = CustomNotification/CustomNotification.entitlements; CODE_SIGN_IDENTITY = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 408; + CURRENT_PROJECT_VERSION = 424; DEVELOPMENT_TEAM = S2Y2D4239K; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = S2Y2D4239K; INFOPLIST_FILE = CustomNotification/Info.plist; @@ -2631,7 +2633,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 2023.8.25; + MARKETING_VERSION = 2024.6.15; PRODUCT_BUNDLE_IDENTIFIER = digital.lamp.mindlamp.CustomNotification; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "mindLAMP2 Custom Notification Extension"; @@ -2654,7 +2656,7 @@ CODE_SIGN_ENTITLEMENTS = CustomNotification/CustomNotification.entitlements; CODE_SIGN_IDENTITY = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 408; + CURRENT_PROJECT_VERSION = 424; DEVELOPMENT_TEAM = S2Y2D4239K; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = S2Y2D4239K; INFOPLIST_FILE = CustomNotification/Info.plist; @@ -2664,7 +2666,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 2023.8.25; + MARKETING_VERSION = 2024.6.15; PRODUCT_BUNDLE_IDENTIFIER = digital.lamp.mindlamp.CustomNotification; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "mindLAMP2 Custom Notification Extension"; diff --git a/mindLAMP.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/mindLAMP.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved deleted file mode 100644 index 725bc52..0000000 --- a/mindLAMP.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ /dev/null @@ -1,15 +0,0 @@ -{ - "originHash" : "fc48a6bab5016fb028fdd589d5bc4d0270adb311945526b62b6566882c00538d", - "pins" : [ - { - "identity" : "lamp-swift", - "kind" : "remoteSourceControl", - "location" : "https://github.com/BIDMCDigitalPsychiatry/LAMP-swift.git", - "state" : { - "revision" : "10ba053cd95a10d8a5cd11a8f031b8bc77b89b90", - "version" : "2023.12.19" - } - } - ], - "version" : 2 -} diff --git a/mindLAMP.xcodeproj/xcshareddata/xcschemes/mindLAMP (Staging).xcscheme b/mindLAMP.xcodeproj/xcshareddata/xcschemes/mindLAMP (Staging).xcscheme index 9499b48..2bbd3ad 100644 --- a/mindLAMP.xcodeproj/xcshareddata/xcschemes/mindLAMP (Staging).xcscheme +++ b/mindLAMP.xcodeproj/xcshareddata/xcschemes/mindLAMP (Staging).xcscheme @@ -42,9 +42,10 @@ + + + + + + diff --git a/mindLAMP/AppDelegate.swift b/mindLAMP/AppDelegate.swift index 7d3f2f5..8db2529 100755 --- a/mindLAMP/AppDelegate.swift +++ b/mindLAMP/AppDelegate.swift @@ -41,7 +41,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { let homeVC = HomeViewController() self.window?.rootViewController = UINavigationController(rootViewController: homeVC) self.window?.makeKeyAndVisible() - + return true } @@ -65,6 +65,20 @@ class AppDelegate: UIResponder, UIApplicationDelegate { WidgetCenter.shared.reloadAllTimelines() } } + + func application(_ application: UIApplication, willContinueUserActivityWithType userActivityType: String) -> Bool { + + if userActivityType == "StreakWidget" { + if let navController = self.window?.rootViewController as? UINavigationController { + + if let existiWebController = navController.topViewController as? HomeViewController { + existiWebController.tappedWidget() + return true + } + } + } + return true + } } private extension AppDelegate { diff --git a/mindLAMP/Home/HomeViewController.swift b/mindLAMP/Home/HomeViewController.swift index 9a39fea..710672a 100644 --- a/mindLAMP/Home/HomeViewController.swift +++ b/mindLAMP/Home/HomeViewController.swift @@ -18,6 +18,8 @@ class HomeViewController: UIViewController { private lazy var lampAPI: NetworkingAPI = { return NetworkConfig.networkingAPI() }() + + var feedURLToLoad: URL? //var loginSubscriber: AnyCancellable? //var isHomePageLoaded = false //@IBOutlet weak var containerView: UIView! @@ -51,7 +53,31 @@ class HomeViewController: UIViewController { } } + + func tappedWidget() { + + guard let participantId = User.shared.userId else { + return + } + let urlstring = String(format: "https://dashboard-staging.lamp.digital/#/participant/%@/feed", participantId) + + guard isWebpageLoaded == true else { + feedURLToLoad = URL(string: urlstring) + return + } + wkWebView.evaluateJavaScript("window.location.href='\(urlstring)';") { obbj ,error in + self.wkWebView.evaluateJavaScript("window.location.reload()") + } +// guard let pageURL = URL(string: urlstring) else {return} +// wkWebView.endEditing(true) +// indicator.startAnimating() +// view.bringSubviewToFront(indicator) +// DispatchQueue.main.async { +// self.wkWebView.load(URLRequest(url: pageURL)) +// } + } + override func loadView() { super.loadView() self.loadWebView() @@ -172,7 +198,12 @@ private extension HomeViewController { func loadWebPage() { if User.shared.isLogin() == true { - wkWebView.load(URLRequest(url: self.lampDashboardURLwithToken)) + if let feedURL = feedURLToLoad { + wkWebView.load(URLRequest(url: feedURL)) + feedURLToLoad = nil + } else { + wkWebView.load(URLRequest(url: self.lampDashboardURLwithToken)) + } } else { wkWebView.load(URLRequest(url: LampURL.dashboardDigital)) } diff --git a/mindLAMP/Info.plist b/mindLAMP/Info.plist index fcc0c5c..12c0d4d 100755 --- a/mindLAMP/Info.plist +++ b/mindLAMP/Info.plist @@ -34,9 +34,22 @@ CFBundlePackageType $(PRODUCT_BUNDLE_PACKAGE_TYPE) CFBundleShortVersionString - 2023.8.25 + 2024.6.15 + CFBundleURLTypes + + + CFBundleTypeRole + Editor + CFBundleURLName + digital.lamp.mindlamp + CFBundleURLSchemes + + widget-deeplink + + + CFBundleVersion - 412 + 424 DASHBOARD_URL $(DASHBOARD_URL) ITSAppUsesNonExemptEncryption From ad3671f93904c7c78769aa6649fb73bd7bb48b8d Mon Sep 17 00:00:00 2001 From: "jijo.pulikkottil" Date: Wed, 24 Jul 2024 15:23:02 +0530 Subject: [PATCH 2/2] swift package updated --- mindLAMP.xcodeproj/project.pbxproj | 4 +--- .../xcshareddata/swiftpm/Package.resolved | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 mindLAMP.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved diff --git a/mindLAMP.xcodeproj/project.pbxproj b/mindLAMP.xcodeproj/project.pbxproj index 28ecab6..aa023aa 100644 --- a/mindLAMP.xcodeproj/project.pbxproj +++ b/mindLAMP.xcodeproj/project.pbxproj @@ -263,7 +263,6 @@ B2201C79257FA60500C40183 /* NotificationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationView.swift; sourceTree = ""; }; B2201C85257FADC700C40183 /* HomeView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = ""; }; B22DF5F1250612E800777D2D /* UserAgentExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserAgentExtension.swift; sourceTree = ""; }; - B230E5E72C2BD1A00061DA68 /* LAMP-swift */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = "LAMP-swift"; path = "../../LAMP-Swift/LAMP-swift"; sourceTree = ""; }; B2346CE62599CEDF00EFF347 /* SensorDataModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SensorDataModel.swift; sourceTree = ""; }; B2346CEE2599DE9800EFF347 /* AppInfo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppInfo.swift; sourceTree = ""; }; B238434624B848F300E548E2 /* LMRunningBuffer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LMRunningBuffer.swift; sourceTree = ""; }; @@ -659,7 +658,6 @@ B29639C423BDC28100626E1A = { isa = PBXGroup; children = ( - B230E5E72C2BD1A00061DA68 /* LAMP-swift */, B2657AB92C11B8AF009AFC3B /* StreakWidgetExtension.entitlements */, B2587B49256E23BC00A2A7F2 /* Shared */, B2A15BB22567A8BE00222717 /* SharedToWatchExt */, @@ -2770,7 +2768,7 @@ repositoryURL = "https://github.com/BIDMCDigitalPsychiatry/LAMP-swift.git"; requirement = { kind = exactVersion; - version = 2023.12.19; + version = 2024.7.23; }; }; /* End XCRemoteSwiftPackageReference section */ diff --git a/mindLAMP.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/mindLAMP.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 0000000..b1a7150 --- /dev/null +++ b/mindLAMP.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,15 @@ +{ + "originHash" : "fc48a6bab5016fb028fdd589d5bc4d0270adb311945526b62b6566882c00538d", + "pins" : [ + { + "identity" : "lamp-swift", + "kind" : "remoteSourceControl", + "location" : "https://github.com/BIDMCDigitalPsychiatry/LAMP-swift.git", + "state" : { + "revision" : "0123c1599e4216ab3d58ed2b7e86566fbfd2db42", + "version" : "2024.7.23" + } + } + ], + "version" : 3 +}