Skip to content

Commit

Permalink
Merge pull request #61 from johnchoi96/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
johnchoi96 authored Dec 31, 2023
2 parents ea5023b + 398ef31 commit 6e499ec
Show file tree
Hide file tree
Showing 18 changed files with 343 additions and 102 deletions.
16 changes: 16 additions & 0 deletions GIT_FLOW.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Git Flow

## Branches
### `main`
* Contains code that is currently deployed to App Store

### `develop`
* Contains code that has the new features implemented but not yet deployed to App Store

### `feature`
* Contains code that are in development and is work in progress.

## Sample Flow
* New features are developed in feature branches.
* Once a feature is complete, it is merged back into the develop branch.
* Periodically, the develop branch is merged into the main branch to create a new release.
26 changes: 18 additions & 8 deletions JCAlerts.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
D2153F732B32665B00F405C8 /* UKNotificationDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2153F722B32665B00F405C8 /* UKNotificationDetailView.swift */; };
D2153F752B32A55F00F405C8 /* FCMTopicDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2153F742B32A55F00F405C8 /* FCMTopicDelegate.swift */; };
D2153F772B32B33600F405C8 /* UIExt.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2153F762B32B33600F405C8 /* UIExt.swift */; };
D21693AB2B3E63F20020BECF /* AppMetadataCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D21693AA2B3E63F20020BECF /* AppMetadataCell.swift */; };
D21693AD2B3EAB470020BECF /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = D21693AC2B3EAB470020BECF /* README.md */; };
D242119F2AE75893005BD72C /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = D242119E2AE75893005BD72C /* Constants.swift */; };
D24211A12AE7589D005BD72C /* StringExt.swift in Sources */ = {isa = PBXBuildFile; fileRef = D24211A02AE7589D005BD72C /* StringExt.swift */; };
D24211A52AE75972005BD72C /* Settings.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D24211A42AE75972005BD72C /* Settings.storyboard */; };
Expand Down Expand Up @@ -61,7 +63,7 @@
D2C660E52AD2073E00CB52BE /* FirebaseMessaging in Frameworks */ = {isa = PBXBuildFile; productRef = D2C660E42AD2073E00CB52BE /* FirebaseMessaging */; };
D2C660EC2ADA881800CB52BE /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = D2C660EB2ADA881800CB52BE /* GoogleService-Info.plist */; };
D2E412DD2B26B3E9003EC53F /* NotificationComment.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E412DC2B26B3E9003EC53F /* NotificationComment.swift */; };
D2E412DF2B26B7FD003EC53F /* UserService.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E412DE2B26B7FD003EC53F /* UserService.swift */; };
D2E412DF2B26B7FD003EC53F /* UserSettingService.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E412DE2B26B7FD003EC53F /* UserSettingService.swift */; };
D2E412E12B26DF28003EC53F /* NotificationCommentsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E412E02B26DF28003EC53F /* NotificationCommentsViewController.swift */; };
D2E412E42B26E2A8003EC53F /* IQKeyboardManagerSwift in Frameworks */ = {isa = PBXBuildFile; productRef = D2E412E32B26E2A8003EC53F /* IQKeyboardManagerSwift */; };
D2E412E72B26E3BD003EC53F /* NotificationCommentTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E412E52B26E3BD003EC53F /* NotificationCommentTableViewCell.swift */; };
Expand All @@ -80,6 +82,9 @@
D2153F722B32665B00F405C8 /* UKNotificationDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UKNotificationDetailView.swift; sourceTree = "<group>"; };
D2153F742B32A55F00F405C8 /* FCMTopicDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FCMTopicDelegate.swift; sourceTree = "<group>"; };
D2153F762B32B33600F405C8 /* UIExt.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIExt.swift; sourceTree = "<group>"; };
D21693AA2B3E63F20020BECF /* AppMetadataCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppMetadataCell.swift; sourceTree = "<group>"; };
D21693AC2B3EAB470020BECF /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
D21693AE2B3EAB830020BECF /* GIT_FLOW.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = GIT_FLOW.md; sourceTree = "<group>"; };
D242119E2AE75893005BD72C /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
D24211A02AE7589D005BD72C /* StringExt.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringExt.swift; sourceTree = "<group>"; };
D24211A42AE75972005BD72C /* Settings.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Settings.storyboard; sourceTree = "<group>"; };
Expand Down Expand Up @@ -113,7 +118,7 @@
D2C660EA2AD2FFEC00CB52BE /* JCAlerts.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = JCAlerts.entitlements; sourceTree = "<group>"; };
D2C660EB2ADA881800CB52BE /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
D2E412DC2B26B3E9003EC53F /* NotificationComment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationComment.swift; sourceTree = "<group>"; };
D2E412DE2B26B7FD003EC53F /* UserService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserService.swift; sourceTree = "<group>"; };
D2E412DE2B26B7FD003EC53F /* UserSettingService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserSettingService.swift; sourceTree = "<group>"; };
D2E412E02B26DF28003EC53F /* NotificationCommentsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationCommentsViewController.swift; sourceTree = "<group>"; };
D2E412E52B26E3BD003EC53F /* NotificationCommentTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationCommentTableViewCell.swift; sourceTree = "<group>"; };
D2E412E62B26E3BD003EC53F /* NotificationCommentTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = NotificationCommentTableViewCell.xib; sourceTree = "<group>"; };
Expand Down Expand Up @@ -160,6 +165,7 @@
children = (
D2153F662B30B2DE00F405C8 /* SettingsViewCell.swift */,
D2153F6D2B30B58D00F405C8 /* NotificationCategoryCell.swift */,
D21693AA2B3E63F20020BECF /* AppMetadataCell.swift */,
);
path = cells;
sourceTree = "<group>";
Expand Down Expand Up @@ -276,14 +282,16 @@
children = (
D24211B32AED548E005BD72C /* FCMTopicService.swift */,
D2984CC92B08436A007B199C /* CloudFirestoreService.swift */,
D2E412DE2B26B7FD003EC53F /* UserService.swift */,
D2E412DE2B26B7FD003EC53F /* UserSettingService.swift */,
);
path = services;
sourceTree = "<group>";
};
D26F6C432AD1FADF00AC1D6F = {
isa = PBXGroup;
children = (
D21693AE2B3EAB830020BECF /* GIT_FLOW.md */,
D21693AC2B3EAB470020BECF /* README.md */,
D26F6C4E2AD1FADF00AC1D6F /* JCAlerts */,
D26F6C4D2AD1FADF00AC1D6F /* Products */,
D2C660E32AD2073E00CB52BE /* Frameworks */,
Expand Down Expand Up @@ -445,6 +453,7 @@
D26F6C5C2AD1FAE100AC1D6F /* Assets.xcassets in Resources */,
D26F6C572AD1FADF00AC1D6F /* Main.storyboard in Resources */,
D24211A52AE75972005BD72C /* Settings.storyboard in Resources */,
D21693AD2B3EAB470020BECF /* README.md in Resources */,
D2984CD52B085321007B199C /* NotificationTableViewCell.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -458,7 +467,7 @@
files = (
D26F6C542AD1FADF00AC1D6F /* AlertsViewController.swift in Sources */,
D26F6C5A2AD1FADF00AC1D6F /* JCAlerts.xcdatamodeld in Sources */,
D2E412DF2B26B7FD003EC53F /* UserService.swift in Sources */,
D2E412DF2B26B7FD003EC53F /* UserSettingService.swift in Sources */,
D24211A82AEB5567005BD72C /* SettingsTableViewCell.swift in Sources */,
D2153F772B32B33600F405C8 /* UIExt.swift in Sources */,
D2984CD12B084A37007B199C /* NotificationPayload.swift in Sources */,
Expand All @@ -482,6 +491,7 @@
D2153F632B30A4D300F405C8 /* SettingsView.swift in Sources */,
D26D5F942AE757B000981481 /* SettingsViewController.swift in Sources */,
D2153F6C2B30B57E00F405C8 /* NotificationCategoriesView.swift in Sources */,
D21693AB2B3E63F20020BECF /* AppMetadataCell.swift in Sources */,
D26F6C522AD1FADF00AC1D6F /* SceneDelegate.swift in Sources */,
D242119F2AE75893005BD72C /* Constants.swift in Sources */,
D2153F672B30B2DE00F405C8 /* SettingsViewCell.swift in Sources */,
Expand Down Expand Up @@ -646,7 +656,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = JCAlerts/JCAlerts.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2023122101;
CURRENT_PROJECT_VERSION = 2023122902;
DEVELOPMENT_TEAM = 2JDGUK4DRH;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = JCAlerts/Info.plist;
Expand All @@ -661,7 +671,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 1.1;
PRODUCT_BUNDLE_IDENTIFIER = io.github.johnchoi96.JCAlerts;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
Expand All @@ -679,7 +689,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = JCAlerts/JCAlerts.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2023122101;
CURRENT_PROJECT_VERSION = 2023122902;
DEVELOPMENT_TEAM = 2JDGUK4DRH;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = JCAlerts/Info.plist;
Expand All @@ -694,7 +704,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 1.1;
PRODUCT_BUNDLE_IDENTIFIER = io.github.johnchoi96.JCAlerts;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
Expand Down
18 changes: 18 additions & 0 deletions JCAlerts/controllers/NotificationDetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class NotificationDetailViewController: UIViewController {
@IBOutlet weak var topicNameLabel: UILabel!
@IBOutlet weak var messageView: UITextView!
@IBOutlet weak var timestampLabel: UILabel!
@IBOutlet weak var fontSizeStepper: UIStepper!

var notificationPayload: NotificationPayload!

Expand All @@ -29,6 +30,11 @@ class NotificationDetailViewController: UIViewController {
messageView.text = notificationPayload.message
}
messageView.layer.cornerRadius = 15
let fontSize = UserSettingService.instance.getTextViewFontSize()
messageView.font = .systemFont(ofSize: CGFloat(fontSize))
fontSizeStepper.minimumValue = 12
fontSizeStepper.maximumValue = 30
fontSizeStepper.value = Double(fontSize)
topicNameLabel.text = notificationPayload.topic.getTopicName()
let timestamp = notificationPayload.timestamp
timestampLabel.text = formatTimestamp(timestamp: timestamp)
Expand All @@ -54,6 +60,18 @@ class NotificationDetailViewController: UIViewController {
performSegue(withIdentifier: K.Segues.notificationDetailToComments, sender: notificationPayload)
}

@IBAction func stepperTapped(_ sender: UIStepper) {
let oldFontSize = UserSettingService.instance.getTextViewFontSize()
if Double(oldFontSize) < fontSizeStepper.value {
UserSettingService.instance.increaseTextViewFontSize()
} else {
UserSettingService.instance.decreaseTextViewFontSize()
}

let newFontSize = UserSettingService.instance.getTextViewFontSize()
messageView.font = .systemFont(ofSize: CGFloat(newFontSize))
}

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == K.Segues.notificationDetailToComments {
let vc = segue.destination as! NotificationCommentsViewController
Expand Down
19 changes: 19 additions & 0 deletions JCAlerts/controllers/PushNotificationDisplayViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import UIKit

class PushNotificationDisplayViewController: UIViewController {

@IBOutlet weak var fontSizeStepper: UIStepper!

static let nib = UINib(nibName: "PushNotificationDisplayViewController", bundle: nil)
static let identifier = K.Nibs.Views.notificationDisplayView

Expand All @@ -25,6 +27,11 @@ class PushNotificationDisplayViewController: UIViewController {
title = "Notification Detail"
textView.text = "Loading..."
textView.layer.cornerRadius = 15
let fontSize = UserSettingService.instance.getTextViewFontSize()
textView.font = .systemFont(ofSize: CGFloat(fontSize))
fontSizeStepper.minimumValue = 12
fontSizeStepper.maximumValue = 30
fontSizeStepper.value = Double(fontSize)
self.view.backgroundColor = UIColor(named: K.Colors.backgroundColor)

cloudFirestoreService.delegate = self
Expand All @@ -35,6 +42,18 @@ class PushNotificationDisplayViewController: UIViewController {
}
}

@IBAction func stepperTapped(_ sender: UIStepper) {
let oldFontSize = UserSettingService.instance.getTextViewFontSize()
if Double(oldFontSize) < fontSizeStepper.value {
UserSettingService.instance.increaseTextViewFontSize()
} else {
UserSettingService.instance.decreaseTextViewFontSize()
}

let newFontSize = UserSettingService.instance.getTextViewFontSize()
textView.font = .systemFont(ofSize: CGFloat(newFontSize))
}

@IBAction func doneTapped(_ sender: UIBarButtonItem) {
self.dismiss(animated: true)
}
Expand Down
16 changes: 9 additions & 7 deletions JCAlerts/delegates/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,20 +131,22 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
-> UNNotificationPresentationOptions {
let userInfo = notification.request.content.userInfo
log.info("Notification Payload: \(userInfo)")
// With swizzling disabled you must let Messaging know about the message, for Analytics
// Messaging.messaging().appDidReceiveMessage(userInfo)
let notificationTopic = userInfo["notification-topic"] as! String
if !FCMTopicService.instance.topicIsSubscribed(topic: notificationTopic) {
return []
}

#if !DEBUG
// NOTE: comment this block for development - #if !DEBUG does not work at the moment
// check if notification is a test notification
let isTestMessage = Bool(userInfo["test-notification"] as! String)!
if isTestMessage {
return []
}
#endif

// With swizzling disabled you must let Messaging know about the message, for Analytics
// Messaging.messaging().appDidReceiveMessage(userInfo)


// Change this to your preferred presentation option
return [[.banner, .sound]]
return [.banner, .sound]
}

func userNotificationCenter(_ center: UNUserNotificationCenter,
Expand Down
7 changes: 6 additions & 1 deletion JCAlerts/models/firebase/fcm/FCMTopic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@

import Foundation

enum FCMTopic: String {
enum FCMTopic: String, CaseIterable {

case ALL = "jc-alerts-all"
case PETFINDER = "jc-alerts-petfinder"
case METALPRICE = "jc-alerts-metalprice"
case CFB = "jc-alerts-cfb"
}

extension FCMTopic {
Expand All @@ -24,6 +25,8 @@ extension FCMTopic {
return "Petfinder"
case .METALPRICE:
return "MetalPrice"
case .CFB:
return "CFB"
}
}

Expand All @@ -38,6 +41,8 @@ extension FCMTopic {
return .PETFINDER
} else if string == FCMTopic.METALPRICE.getTopicName() || string == FCMTopic.METALPRICE.getTopicValue() {
return .METALPRICE
} else if string == FCMTopic.CFB.getTopicName() || string == FCMTopic.CFB.getTopicValue() {
return .CFB
} else {
return nil
}
Expand Down
21 changes: 15 additions & 6 deletions JCAlerts/services/CloudFirestoreService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class CloudFirestoreService: ObservableObject {

private let logger = os.Logger()

private let userService = UserService.instance
private let userService = UserSettingService.instance

var delegate: CloudFirestoreDelegate?

Expand All @@ -41,17 +41,21 @@ class CloudFirestoreService: ObservableObject {
var notifications: [NotificationPayload] = []
var notificationDict: [String: NotificationPayload] = [:]
for document in querySnapshot!.documents {
var topic: FCMTopic
var topic: FCMTopic?
switch (document.get("topic") as! String) {
case FCMTopic.ALL.getTopicValue():
topic = .ALL
case FCMTopic.PETFINDER.getTopicValue():
topic = .PETFINDER
case FCMTopic.METALPRICE.getTopicValue():
topic = .METALPRICE
case FCMTopic.CFB.getTopicValue():
topic = .CFB
default:
self.logger.error("Invalid topic type")
return
}
guard let topic = topic else {
continue
}
// check if current topic is subscribed
if !self.fcmTopicService.topicIsSubscribed(topic: topic) {
Expand All @@ -69,12 +73,13 @@ class CloudFirestoreService: ObservableObject {


let payload = NotificationPayload(id: UUID(), notificationTitle: notificationTitle, notificationSubtitle: notificationSubtitle, notificationId: notificationId, message: message, timestamp: timestamp.utcTimestampToDate(), topic: topic, isHtml: isHtml, isTestMessage: isTestMessage)
#if !DEBUG

// NOTE: comment this block for development - #if !DEBUG does not work at the moment
// if on prod, ignore test messages
if payload.isTestMessage {
continue
}
#endif

notifications.append(payload)
notificationDict[notificationId] = payload
}
Expand Down Expand Up @@ -104,7 +109,7 @@ class CloudFirestoreService: ObservableObject {
let timestamp = document.get("timestamp") as! String
let notificationTitle = document.get("notification-title") as! String
let notificationSubtitle = document.get("notification-body") as! String
var topic: FCMTopic
var topic: FCMTopic?
let isTestMessage = document.get("test-notification") as? Bool ?? false
switch (document.get("topic") as! String) {
case FCMTopic.ALL.getTopicValue():
Expand All @@ -113,8 +118,12 @@ class CloudFirestoreService: ObservableObject {
topic = .PETFINDER
case FCMTopic.METALPRICE.getTopicValue():
topic = .METALPRICE
case FCMTopic.CFB.getTopicValue():
topic = .CFB
default:
self.logger.error("Invalid topic type")
}
guard let topic = topic else {
return
}
let payload = NotificationPayload(id: UUID(), notificationTitle: notificationTitle, notificationSubtitle: notificationSubtitle, notificationId: notificationId, message: message, timestamp: timestamp.utcTimestampToDate(), topic: topic, isHtml: isHtml, isTestMessage: isTestMessage)
Expand Down
10 changes: 10 additions & 0 deletions JCAlerts/services/FCMTopicService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ class FCMTopicService {
return getTopicsAsStrings().contains(topic.getTopicValue())
}

func topicIsSubscribed(topic: String) -> Bool {
return getTopicsAsStrings().contains(topic)
}

func restoreSubscription() {
for topic in getTopicsAsStrings() {
fcmInstance.subscribe(toTopic: topic)
Expand All @@ -97,4 +101,10 @@ class FCMTopicService {
}
UserDefaults.standard.set(topicsList, forKey: TOPIC_KEY)
}

func subscribeToAllTopic() {
FCMTopic.allCases.forEach { topic in
subscribe(toTopic: topic)
}
}
}
Loading

0 comments on commit 6e499ec

Please sign in to comment.