Showing
10 changed files
with
88 additions
and
13 deletions
| ... | ... | @@ -14,6 +14,7 @@ |
| 14 | 14 | 190DB9FC2AC450F6000A7BF3 /* RemoveAdvertViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 190DB9FB2AC450F6000A7BF3 /* RemoveAdvertViewController.swift */; }; |
| 15 | 15 | 190DBA002AC45A3C000A7BF3 /* CachingManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 190DB9FF2AC45A3C000A7BF3 /* CachingManager.swift */; }; |
| 16 | 16 | 190DBA0D2AC47701000A7BF3 /* BinaryFloatingPoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 190DBA0C2AC47701000A7BF3 /* BinaryFloatingPoint.swift */; }; |
| 17 | + 1918115E2B17623D00F7CB6F /* NotificationManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1918115D2B17623D00F7CB6F /* NotificationManager.swift */; }; | |
| 17 | 18 | 191BB84F2AC5A9C900A2DEB9 /* TabsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 191BB84E2AC5A9C900A2DEB9 /* TabsView.swift */; }; |
| 18 | 19 | 191BB8522AC5AB4600A2DEB9 /* TabsToolbarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 191BB8512AC5AB4600A2DEB9 /* TabsToolbarView.swift */; }; |
| 19 | 20 | 191BB8542AC5B3CD00A2DEB9 /* TabsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 191BB8532AC5B3CD00A2DEB9 /* TabsViewController.swift */; }; |
| ... | ... | @@ -115,6 +116,7 @@ |
| 115 | 116 | 190DB9FB2AC450F6000A7BF3 /* RemoveAdvertViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemoveAdvertViewController.swift; sourceTree = "<group>"; }; |
| 116 | 117 | 190DB9FF2AC45A3C000A7BF3 /* CachingManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CachingManager.swift; sourceTree = "<group>"; }; |
| 117 | 118 | 190DBA0C2AC47701000A7BF3 /* BinaryFloatingPoint.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BinaryFloatingPoint.swift; sourceTree = "<group>"; }; |
| 119 | + 1918115D2B17623D00F7CB6F /* NotificationManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationManager.swift; sourceTree = "<group>"; }; | |
| 118 | 120 | 191BB84E2AC5A9C900A2DEB9 /* TabsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabsView.swift; sourceTree = "<group>"; }; |
| 119 | 121 | 191BB8512AC5AB4600A2DEB9 /* TabsToolbarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabsToolbarView.swift; sourceTree = "<group>"; }; |
| 120 | 122 | 191BB8532AC5B3CD00A2DEB9 /* TabsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabsViewController.swift; sourceTree = "<group>"; }; |
| ... | ... | @@ -241,6 +243,7 @@ |
| 241 | 243 | 193B3B892ACAF714002161ED /* TabManager.swift */, |
| 242 | 244 | 1907D6962ADE766F00C40E9F /* HistoryDBManager.swift */, |
| 243 | 245 | 1907D6982ADE7E9C00C40E9F /* DateManager.swift */, |
| 246 | + 1918115D2B17623D00F7CB6F /* NotificationManager.swift */, | |
| 244 | 247 | ); |
| 245 | 248 | path = Managers; |
| 246 | 249 | sourceTree = "<group>"; |
| ... | ... | @@ -963,6 +966,7 @@ |
| 963 | 966 | 191BB8642AC6A02300A2DEB9 /* SearchingView.swift in Sources */, |
| 964 | 967 | 190DBA002AC45A3C000A7BF3 /* CachingManager.swift in Sources */, |
| 965 | 968 | 1984BF422AFB907A0050F816 /* PrivacyView.swift in Sources */, |
| 969 | + 1918115E2B17623D00F7CB6F /* NotificationManager.swift in Sources */, | |
| 966 | 970 | 191BB8692AC6A66900A2DEB9 /* SearchingTableViewCell.swift in Sources */, |
| 967 | 971 | 1990C69C2AEFDF89004AF856 /* UICollectionViewCell+convertFrameToScreenCoordinates.swift in Sources */, |
| 968 | 972 | 19FCBF222AC1727800F83A7F /* AppDelegate.swift in Sources */, | ... | ... |
No preview for this file type
| ... | ... | @@ -3,12 +3,13 @@ import UIKit |
| 3 | 3 | @main |
| 4 | 4 | class AppDelegate: UIResponder, UIApplicationDelegate { |
| 5 | 5 | var window: UIWindow? |
| 6 | - | |
| 6 | + | |
| 7 | 7 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { |
| 8 | 8 | let screenRect = UIScreen.main.bounds |
| 9 | 9 | window = UIWindow(frame: screenRect) |
| 10 | 10 | |
| 11 | 11 | if let window = window { |
| 12 | + let notification = NotificationManager() | |
| 12 | 13 | let navigationViewController = NavigationViewController() |
| 13 | 14 | window.rootViewController = navigationViewController |
| 14 | 15 | window.makeKeyAndVisible() | ... | ... |
browser/Managers/NotificationManager.swift
0 → 100644
| 1 | +// | |
| 2 | +// NotificationManager.swift | |
| 3 | +// Pro-Seecurity-VPN | |
| 4 | +// | |
| 5 | +// Created by Artem Talko on 29.11.2023. | |
| 6 | +// | |
| 7 | +import UIKit | |
| 8 | +import UserNotifications | |
| 9 | + | |
| 10 | +final class NotificationManager { | |
| 11 | + private let notificationInterval: TimeInterval = 60 * 4 * 60 | |
| 12 | + | |
| 13 | + init() { | |
| 14 | + chechForPermission() | |
| 15 | + } | |
| 16 | + | |
| 17 | + private func chechForPermission() { | |
| 18 | + let notificationCenter = UNUserNotificationCenter.current() | |
| 19 | + | |
| 20 | + notificationCenter.getNotificationSettings { settings in | |
| 21 | + switch settings.authorizationStatus { | |
| 22 | + case .authorized: | |
| 23 | + self.dispatchNotification() | |
| 24 | + | |
| 25 | + case .notDetermined: | |
| 26 | + notificationCenter.requestAuthorization(options: [.alert, .sound]) { didAllow, error in | |
| 27 | + if didAllow { | |
| 28 | + self.dispatchNotification() | |
| 29 | + } | |
| 30 | + } | |
| 31 | + | |
| 32 | + case .denied: | |
| 33 | + return | |
| 34 | + | |
| 35 | + default: | |
| 36 | + return | |
| 37 | + } | |
| 38 | + } | |
| 39 | + } | |
| 40 | + | |
| 41 | + private func generateRandomNotificationBody() -> String { | |
| 42 | + return StringConstants.notificationMessages.randomElement() ?? "" | |
| 43 | + } | |
| 44 | + | |
| 45 | + private func dispatchNotification() { | |
| 46 | + let identifier = StringConstants.notificationIdentifier | |
| 47 | + let notificationCenter = UNUserNotificationCenter.current() | |
| 48 | + | |
| 49 | + let content = UNMutableNotificationContent() | |
| 50 | + content.title = StringConstants.notificationTitle | |
| 51 | + content.body = generateRandomNotificationBody() | |
| 52 | + content.sound = .default | |
| 53 | + | |
| 54 | + let trigger = UNTimeIntervalNotificationTrigger(timeInterval: notificationInterval, repeats: true) | |
| 55 | + let request = UNNotificationRequest(identifier: identifier, content: content, trigger: trigger) | |
| 56 | + | |
| 57 | + notificationCenter.removePendingNotificationRequests(withIdentifiers: [identifier]) | |
| 58 | + notificationCenter.add(request) | |
| 59 | + } | |
| 60 | +} | ... | ... |
| ... | ... | @@ -66,7 +66,6 @@ final class HistoryViewController: UIViewController { |
| 66 | 66 | |
| 67 | 67 | //MARK: - TableView Extention |
| 68 | 68 | extension HistoryViewController: UITableViewDelegate, UITableViewDataSource { |
| 69 | - | |
| 70 | 69 | func numberOfSections(in tableView: UITableView) -> Int { |
| 71 | 70 | return filteredData.count |
| 72 | 71 | } | ... | ... |
| ... | ... | @@ -61,10 +61,6 @@ final class BrowserHomeViewController: UIViewController { |
| 61 | 61 | init(url: String?, currentTabId: Int?) { |
| 62 | 62 | searchResultViewController = SearchResultViewController(searchLink: String()) |
| 63 | 63 | searchingViewController = SearchingViewController(dataForReq: []) |
| 64 | - | |
| 65 | - | |
| 66 | - | |
| 67 | - | |
| 68 | 64 | subscriptions = [] |
| 69 | 65 | searchRequestURL = URLConstants.googleURL |
| 70 | 66 | |
| ... | ... | @@ -289,19 +285,18 @@ extension BrowserHomeViewController { |
| 289 | 285 | let finalUrl = siteUrl.absoluteString |
| 290 | 286 | let lastVisit = DateManager.shared.currentDate |
| 291 | 287 | let homeViewSnapshot = SnapshotService.shared.makeSnapshot(mainView) |
| 292 | - | |
| 288 | + navigationController?.popViewController(animated: true) | |
| 293 | 289 | TabManager.shared.saveTab(tabTitle: siteTitle, snapshotImage: homeViewSnapshot, tabUrl: finalUrl) |
| 294 | 290 | self.currentTabId = tabsViewController?.getCellIndex().row |
| 295 | 291 | |
| 296 | - tabsViewController?.refreshData() | |
| 297 | 292 | HistoryDBManager.shared.saveToHistory(siteTitle: siteTitle, siteUrl: finalUrl, lastVisit: lastVisit) |
| 298 | - navigationController?.popViewController(animated: true) | |
| 293 | + | |
| 299 | 294 | } else { |
| 300 | 295 | let homeViewSnapshot = SnapshotService.shared.makeSnapshot(mainView) |
| 296 | + navigationController?.popViewController(animated: true) | |
| 301 | 297 | TabManager.shared.saveTab(tabTitle: "Start Page", snapshotImage: homeViewSnapshot, tabUrl: "homeUrl") |
| 302 | - tabsViewController?.refreshData() | |
| 298 | + | |
| 303 | 299 | currentTabId = tabsViewController?.getCellIndex().row |
| 304 | - navigationController?.popViewController(animated: true) | |
| 305 | 300 | } |
| 306 | 301 | } |
| 307 | 302 | ... | ... |
| ... | ... | @@ -10,7 +10,6 @@ import UIKit |
| 10 | 10 | final class SubscriptionTableViewCell: UITableViewCell { |
| 11 | 11 | static let cellID = String(describing: SubscriptionTableViewCell.self) |
| 12 | 12 | |
| 13 | - | |
| 14 | 13 | let advantagesCellLabel: UILabel = { |
| 15 | 14 | let obj = UILabel() |
| 16 | 15 | obj.font = FontConstants.regularFont_14 | ... | ... |
| ... | ... | @@ -55,8 +55,23 @@ struct StringConstants { |
| 55 | 55 | |
| 56 | 56 | static let menuTitle = "Clearing will remove history, cookies and other browsing data. History will be cleared from devices signed into your iCloud Account. Clear from:" |
| 57 | 57 | |
| 58 | - //mainView labels | |
| 58 | + ///mainView labels | |
| 59 | 59 | static let adBlockProtectFrom = "Adblock will protect you from:" |
| 60 | 60 | static let tableViewData = ["Harmful ads", "Phishing sites", "Ads in video"] |
| 61 | + | |
| 62 | + | |
| 63 | + ///notifications | |
| 64 | + static let notificationMessages = [ | |
| 65 | + "Enhance Your Security! Tap to Enable Gotoweb Safe Browsing and Shield Your Data.", | |
| 66 | + "Protect Your Privacy! Open Gotoweb Safe Browser for a Secure Online Journey.", | |
| 67 | + "Safety First! Tap to Browse Anonymously with Gotoweb Safe Browser.", | |
| 68 | + "Stay Anonymous Online! Tap to Activate Gotoweb Safe Browsing and Keep Your Data Safe.", | |
| 69 | + "Gotoweb Alert: Ensure Your Online Safety - Enable Safe Browsing Now!", | |
| 70 | + "Your Privacy Matters! Browse Securely with Gotoweb Safe Browser - Tap to Activate.", | |
| 71 | + "Gotoweb Protection: Keep Your Online Activities Private - Activate Safe Browsing Today!", | |
| 72 | + "Browse Safely with Gotoweb! Activate Privacy Mode Now for a Secure Online Experience." | |
| 73 | + ] | |
| 74 | + static let notificationTitle = "Gotoweb Notification" | |
| 75 | + static let notificationIdentifier = "browser-notification" | |
| 61 | 76 | } |
| 62 | 77 | ... | ... |
Please
register
or
login
to post a comment