From 37c1c855dcb0d320d5e77d1357205d35df6fb2fa Mon Sep 17 00:00:00 2001 From: Falk Rismansanj Date: Wed, 30 Jun 2021 03:53:14 +0200 Subject: [PATCH] Changes --- LICENSE | 2 +- blista/EighteenthViewController.swift | 24 ++-- blista/FirstViewController.swift | 171 +++++++++++++++++++------- blista/Info.plist | 2 + blista/Reachability.swift | 0 blista/SixteenViewController.swift | 10 +- 6 files changed, 149 insertions(+), 60 deletions(-) mode change 100755 => 100644 blista/Reachability.swift diff --git a/LICENSE b/LICENSE index 7b9cecb..ee9b75e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2018 Falk Rismansanj +Copyright (c) 2017 Falk Rismansanj Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/blista/EighteenthViewController.swift b/blista/EighteenthViewController.swift index eb86c5b..130a4fe 100644 --- a/blista/EighteenthViewController.swift +++ b/blista/EighteenthViewController.swift @@ -24,17 +24,17 @@ class EighteenthViewController: UIViewController, UIWebViewDelegate { switch reachability.connection { case .wifi: - Answers.logContentView(withName: "Ankündigen", - contentType: "Ankündigen", - contentId: "ankündigen", + Answers.logContentView(withName: "Ankündigungen", + contentType: "Ankündigungen", + contentId: "ankündigungen", customAttributes: [:]) webView18.loadRequest(URLRequest(url: URL(string: "https://css.moodle.blista.study/mod/forum/search.php?id=3&words&phrase¬words&fullwords&timefromrestrict=1&fromday=1&frommonth=1&fromyear=2000&fromhour=0&fromminute=0&hfromday=0&hfrommonth=0&hfromyear=0&hfromhour=0&hfromminute=0&htoday=1&htomonth=1&htoyear=1&htohour=1&htominute=1&forumid&subject&user#maincontent")!)) case .cellular: - Answers.logContentView(withName: "Ankündigen", - contentType: "Ankündigen", - contentId: "ankündigen", + Answers.logContentView(withName: "Ankündigungen", + contentType: "Ankündigungen", + contentId: "ankündigungen", customAttributes: [:]) webView18.loadRequest(URLRequest(url: URL(string: "https://css.moodle.blista.study/mod/forum/search.php?id=3&words&phrase¬words&fullwords&timefromrestrict=1&fromday=1&frommonth=1&fromyear=2000&fromhour=0&fromminute=0&hfromday=0&hfrommonth=0&hfromyear=0&hfromhour=0&hfromminute=0&htoday=1&htomonth=1&htoyear=1&htohour=1&htominute=1&forumid&subject&user#maincontent")!)) @@ -60,17 +60,17 @@ class EighteenthViewController: UIViewController, UIWebViewDelegate { switch reachability.connection { case .wifi: - Answers.logContentView(withName: "Ankündigen", - contentType: "Ankündigen", - contentId: "ankündigen", + Answers.logContentView(withName: "Ankündigungen", + contentType: "Ankündigungen", + contentId: "ankündigungen", customAttributes: [:]) webView18.loadRequest(URLRequest(url: URL(string: "https://css.moodle.blista.study/mod/forum/search.php?id=3&words&phrase¬words&fullwords&timefromrestrict=1&fromday=1&frommonth=1&fromyear=2000&fromhour=0&fromminute=0&hfromday=0&hfrommonth=0&hfromyear=0&hfromhour=0&hfromminute=0&htoday=1&htomonth=1&htoyear=1&htohour=1&htominute=1&forumid&subject&user#maincontent")!)) case .cellular: - Answers.logContentView(withName: "Ankündigen", - contentType: "Ankündigen", - contentId: "ankündigen", + Answers.logContentView(withName: "Ankündigungen", + contentType: "Ankündigungen", + contentId: "ankündigungen", customAttributes: [:]) webView18.loadRequest(URLRequest(url: URL(string: "https://css.moodle.blista.study/mod/forum/search.php?id=3&words&phrase¬words&fullwords&timefromrestrict=1&fromday=1&frommonth=1&fromyear=2000&fromhour=0&fromminute=0&hfromday=0&hfrommonth=0&hfromyear=0&hfromhour=0&hfromminute=0&htoday=1&htomonth=1&htoyear=1&htohour=1&htominute=1&forumid&subject&user#maincontent")!)) diff --git a/blista/FirstViewController.swift b/blista/FirstViewController.swift index 5d44aaa..58bfba7 100644 --- a/blista/FirstViewController.swift +++ b/blista/FirstViewController.swift @@ -9,6 +9,7 @@ import UIKit import Crashlytics import SwiftyJSON +import AppTrackingTransparency class FirstViewController: UIViewController, UIWebViewDelegate { @@ -30,8 +31,7 @@ class FirstViewController: UIViewController, UIWebViewDelegate { public var sku = "" func activateMe() { - - let alert = UIAlertController(title: "Bitte denk über eine Spende nach", message: "Die Entwicklung der blistar-App kostet viel Zeit und Geld. Spende für die blistar-App und sichere die Weiterentwicklung der App oder warte 60 Sekunden.", preferredStyle: .alert) + let alert = UIAlertController(title: "Bitte denk über eine Spende nach", message: "Die Entwicklung der blistar-App kostet viel Zeit und Geld. Spende für die blistar-App und sichere die Weiterentwicklung der App oder warte 10 Sekunden.", preferredStyle: .alert) alert.addAction(UIAlertAction(title: "Spenden", style: .default, handler: { action in let url = URL(string:"https://zitrotec.de/it-service/referenzen/blista/blistar-app-support-plan") @@ -47,6 +47,9 @@ class FirstViewController: UIViewController, UIWebViewDelegate { UIApplication.shared.openURL(url!) } self.present(alert, animated: true) + DispatchQueue.main.asyncAfter(deadline: .now() + 10.0) { + alert.dismiss(animated: true, completion: nil) + } case .cellular: @@ -56,6 +59,9 @@ class FirstViewController: UIViewController, UIWebViewDelegate { UIApplication.shared.openURL(url!) } self.present(alert, animated: true) + DispatchQueue.main.asyncAfter(deadline: .now() + 10.0) { + alert.dismiss(animated: true, completion: nil) + } case .none: let alert3 = UIAlertView() @@ -64,6 +70,9 @@ class FirstViewController: UIViewController, UIWebViewDelegate { alert3.addButton(withTitle: "OK") alert3.show() self.present(alert, animated: true) + DispatchQueue.main.asyncAfter(deadline: .now() + 10.0) { + alert.dismiss(animated: true, completion: nil) + } } })) @@ -78,6 +87,9 @@ class FirstViewController: UIViewController, UIWebViewDelegate { alert2.addAction(UIAlertAction(title: "Abbrechen", style: .cancel, handler: { action in self.present(alert, animated: true) + DispatchQueue.main.asyncAfter(deadline: .now() + 10.0) { + alert.dismiss(animated: true, completion: nil) + } })) alert2.addTextField(configurationHandler: { textField in @@ -98,13 +110,17 @@ class FirstViewController: UIViewController, UIWebViewDelegate { guard let dataResponse = data, error == nil else { print(error?.localizedDescription ?? "Response Error") - UIApplication.shared.isNetworkActivityIndicatorVisible = false DispatchQueue.main.async { + UIApplication.shared.isNetworkActivityIndicatorVisible = false + let alert5 = UIAlertController(title: "Fehler: " + (error?.localizedDescription ?? "Response Error"), message: "Hilfe zu diesem Fehler findest du auf der Spendenseite.", preferredStyle: UIAlertControllerStyle.alert) let action = UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: {(action:UIAlertAction) in self.present(alert, animated: true) + DispatchQueue.main.asyncAfter(deadline: .now() + 10.0) { + alert.dismiss(animated: true, completion: nil) + } }) alert5.addAction(action) @@ -128,6 +144,9 @@ class FirstViewController: UIViewController, UIWebViewDelegate { let action = UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: {(action:UIAlertAction) in self.present(alert, animated: true) + DispatchQueue.main.asyncAfter(deadline: .now() + 10.0) { + alert.dismiss(animated: true, completion: nil) + } }) alert4.addAction(action) @@ -196,7 +215,7 @@ class FirstViewController: UIViewController, UIWebViewDelegate { DispatchQueue.main.async { UIApplication.shared.isNetworkActivityIndicatorVisible = false - let alert7 = UIAlertController(title: "Erfolg: " + (message ?? "null"), message: "Vielen Dank für deine Unterstützung, die 60 Sek. Wartezeit entfällt nun. \n Details: \n" + (UserInfo ), preferredStyle: UIAlertControllerStyle.alert) + let alert7 = UIAlertController(title: "Erfolg: " + (message ?? "null"), message: "Vielen Dank für deine Unterstützung, die 10 Sek. Wartezeit entfällt nun. \n Details: \n" + (UserInfo ), preferredStyle: UIAlertControllerStyle.alert) let action = UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: {(action:UIAlertAction) in // Spark! @@ -232,6 +251,9 @@ class FirstViewController: UIViewController, UIWebViewDelegate { alert2.addAction(UIAlertAction(title: "Abbrechen", style: .cancel, handler: { action in self.present(alert, animated: true) + DispatchQueue.main.asyncAfter(deadline: .now() + 10.0) { + alert.dismiss(animated: true, completion: nil) + } })) alert2.addTextField(configurationHandler: { textField in @@ -252,13 +274,16 @@ class FirstViewController: UIViewController, UIWebViewDelegate { guard let dataResponse = data, error == nil else { print(error?.localizedDescription ?? "Response Error") - UIApplication.shared.isNetworkActivityIndicatorVisible = false DispatchQueue.main.async { + UIApplication.shared.isNetworkActivityIndicatorVisible = false let alert5 = UIAlertController(title: "Fehler: " + (error?.localizedDescription ?? "Response Error"), message: "Hilfe zu diesem Fehler findest du auf der Spendenseite.", preferredStyle: UIAlertControllerStyle.alert) let action = UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: {(action:UIAlertAction) in self.present(alert, animated: true) + DispatchQueue.main.asyncAfter(deadline: .now() + 10.0) { + alert.dismiss(animated: true, completion: nil) + } }) alert5.addAction(action) @@ -283,6 +308,9 @@ class FirstViewController: UIViewController, UIWebViewDelegate { let action = UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: {(action:UIAlertAction) in self.present(alert, animated: true) + DispatchQueue.main.asyncAfter(deadline: .now() + 10.0) { + alert.dismiss(animated: true, completion: nil) + } }) alert4.addAction(action) @@ -351,7 +379,7 @@ class FirstViewController: UIViewController, UIWebViewDelegate { DispatchQueue.main.async { UIApplication.shared.isNetworkActivityIndicatorVisible = false - let alert7 = UIAlertController(title: "Erfolg: " + (message ?? "null"), message: "Vielen Dank für deine Unterstützung, die 60 Sek. Wartezeit entfällt nun. \n Details: \n" + (UserInfo ), preferredStyle: UIAlertControllerStyle.alert) + let alert7 = UIAlertController(title: "Erfolg: " + (message ?? "null"), message: "Vielen Dank für deine Unterstützung, die 10 Sek. Wartezeit entfällt nun. \n Details: \n" + (UserInfo ), preferredStyle: UIAlertControllerStyle.alert) let action = UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: {(action:UIAlertAction) in // Spark! @@ -387,11 +415,33 @@ class FirstViewController: UIViewController, UIWebViewDelegate { })) self.present(alert, animated: true) + DispatchQueue.main.asyncAfter(deadline: .now() + 10.0) { + alert.dismiss(animated: true, completion: nil) + } } override func viewDidLoad() { super.viewDidLoad() - + + if #available(iOS 14, *) { + ATTrackingManager.requestTrackingAuthorization { (status) in + switch status { + case .authorized: + print("Yeah, we got permission :)") + case .denied: + print("Oh no, we didn't get the permission :(") + case .notDetermined: + print("Hmm, the user has not yet received an authorization request") + case .restricted: + print("Hmm, the permissions we got are restricted") + @unknown default: + print("Looks like we didn't get permission") + } + } + } else { + // Nothing to do + } + // Do any additional setup after loading the view, typically from a nib. let defaults = UserDefaults.standard @@ -415,16 +465,12 @@ class FirstViewController: UIViewController, UIWebViewDelegate { print(customDate ?? "null") print(parsed_expire_date) - let launchedBefore = defaults.bool(forKey: "launchedBefore") if launchedBefore { print("Not first launch.") if !active { activateMe() - DispatchQueue.main.asyncAfter(deadline: .now() + 60.0) { - self.dismiss(animated: true, completion: nil) - } } else { if (!parsed_expire_date.isEmpty) { @@ -434,7 +480,7 @@ class FirstViewController: UIViewController, UIWebViewDelegate { defaults.set(false, forKey: "active") defaults.set(true, forKey: "has_expired") - let myMessage = "Dein Spendenschlüssel ist am " + parsed_expire_date + " abgelaufen. Du kannst ihn aber ganz leicht verlängern. Wenn du dies nicht möchtest, tippe einfach auf Spendenschlüssel eingeben und warte 60 Sekunden." + let myMessage = "Dein Spendenschlüssel ist am " + parsed_expire_date + " abgelaufen. Du kannst ihn aber ganz leicht verlängern. Wenn du dies nicht möchtest, tippe einfach auf Spendenschlüssel eingeben und warte 10 Sekunden." let alert8 = UIAlertController(title: "Dein Spendenschlüssel ist abgelaufen", message: myMessage, preferredStyle: UIAlertControllerStyle.alert) @@ -472,9 +518,6 @@ class FirstViewController: UIViewController, UIWebViewDelegate { let action2 = UIAlertAction(title: "Spendenschlüssel eingeben", style: UIAlertActionStyle.default, handler: {(action:UIAlertAction) in self.activateMe() - DispatchQueue.main.asyncAfter(deadline: .now() + 60.0) { - self.dismiss(animated: true, completion: nil) - } }) alert8.addAction(action) @@ -504,35 +547,77 @@ class FirstViewController: UIViewController, UIWebViewDelegate { func loadVPlan () { - let reachability = Reachability()! - - switch reachability.connection { - case .wifi: - - Answers.logContentView(withName: "VPlan Schüler", - contentType: "VPlan Schüler", - contentId: "vplan1", - customAttributes: [:]) - - webView1.loadRequest(URLRequest(url: URL(string: "https://css.moodle.blista.study/mod/resource/view.php?id=39#maincontent")!)) - - case .cellular: - - Answers.logContentView(withName: "VPlan Schüler", - contentType: "VPlan Schüler", - contentId: "vplan1", - customAttributes: [:]) - - webView1.loadRequest(URLRequest(url: URL(string: "https://css.moodle.blista.study/mod/resource/view.php?id=39#maincontent")!)) + if #available(iOS 14, *) { + ATTrackingManager.requestTrackingAuthorization(completionHandler: { [self] status in + + let reachability = Reachability()! + + switch reachability.connection { + case .wifi: + + Answers.logContentView(withName: "VPlan Schüler", + contentType: "VPlan Schüler", + contentId: "vplan1", + customAttributes: [:]) + + DispatchQueue.main.async { + webView1.loadRequest(URLRequest(url: URL(string: "https://css.moodle.blista.study/mod/resource/view.php?id=39#maincontent")!)) + } + + case .cellular: + + Answers.logContentView(withName: "VPlan Schüler", + contentType: "VPlan Schüler", + contentId: "vplan1", + customAttributes: [:]) + + DispatchQueue.main.async { + webView1.loadRequest(URLRequest(url: URL(string: "https://css.moodle.blista.study/mod/resource/view.php?id=39#maincontent")!)) + } + + case .none: + DispatchQueue.main.async { + UIApplication.shared.isNetworkActivityIndicatorVisible = false + activity.stopAnimating() + let alert = UIAlertView() + alert.title = "Du bist Offline" + alert.message = "Bitte stell eine Internetverbindung her, um diesen Inhalt anzuzeigen." + alert.addButton(withTitle: "OK") + alert.show() + } + } + }) + } else { + let reachability = Reachability()! - case .none: - UIApplication.shared.isNetworkActivityIndicatorVisible = false - activity.stopAnimating() - let alert = UIAlertView() - alert.title = "Du bist Offline" - alert.message = "Bitte stell eine Internetverbindung her, um diesen Inhalt anzuzeigen." - alert.addButton(withTitle: "OK") - alert.show() + switch reachability.connection { + case .wifi: + + Answers.logContentView(withName: "VPlan Schüler", + contentType: "VPlan Schüler", + contentId: "vplan1", + customAttributes: [:]) + + webView1.loadRequest(URLRequest(url: URL(string: "https://css.moodle.blista.study/mod/resource/view.php?id=39#maincontent")!)) + + case .cellular: + + Answers.logContentView(withName: "VPlan Schüler", + contentType: "VPlan Schüler", + contentId: "vplan1", + customAttributes: [:]) + + webView1.loadRequest(URLRequest(url: URL(string: "https://css.moodle.blista.study/mod/resource/view.php?id=39#maincontent")!)) + + case .none: + UIApplication.shared.isNetworkActivityIndicatorVisible = false + activity.stopAnimating() + let alert = UIAlertView() + alert.title = "Du bist Offline" + alert.message = "Bitte stell eine Internetverbindung her, um diesen Inhalt anzuzeigen." + alert.addButton(withTitle: "OK") + alert.show() + } } } diff --git a/blista/Info.plist b/blista/Info.plist index 8ebd4a5..4aff73c 100644 --- a/blista/Info.plist +++ b/blista/Info.plist @@ -2,6 +2,8 @@ + NSUserTrackingUsageDescription + Wir verwenden Cookies auf den Internetseiten der blista. Einige sind für den Betrieb der Webseite notwendig. Andere helfen uns, das Informationsangebot benutzerfreundlich zusammenzustellen, sodass Sie und alle weiteren Besucherinnen und Besucher die Antworten auf ihre Fragen schnell und zuverlässig finden. CFBundleDevelopmentRegion deDE CFBundleDisplayName diff --git a/blista/Reachability.swift b/blista/Reachability.swift old mode 100755 new mode 100644 diff --git a/blista/SixteenViewController.swift b/blista/SixteenViewController.swift index daf6fe2..49d1ac7 100644 --- a/blista/SixteenViewController.swift +++ b/blista/SixteenViewController.swift @@ -23,12 +23,13 @@ class SixteenViewController: UIViewController, UIWebViewDelegate { self.navigationItem.rightBarButtonItem = rightBarButton let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String + let build = Bundle.main.infoDictionary?["CFBundleVersion"] as? String let reachability = Reachability()! switch reachability.connection { case .wifi: - UserDefaults.standard.register(defaults: ["UserAgent": "blistar/"+version!]) + UserDefaults.standard.register(defaults: ["UserAgent": "blistar/"+version!+"("+build!+")"]) Answers.logContentView(withName: "Über diese App", contentType: "Über diese App", @@ -37,7 +38,7 @@ class SixteenViewController: UIViewController, UIWebViewDelegate { webView16.loadRequest(URLRequest(url: URL(string: "https://zitrotec.de/blista")!)) case .cellular: - UserDefaults.standard.register(defaults: ["UserAgent": "blistar/"+version!]) + UserDefaults.standard.register(defaults: ["UserAgent": "blistar/"+version!+"("+build!+")"]) Answers.logContentView(withName: "Über diese App", contentType: "Über diese App", @@ -57,12 +58,13 @@ class SixteenViewController: UIViewController, UIWebViewDelegate { super.viewDidAppear(animated) let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String + let build = Bundle.main.infoDictionary?["CFBundleVersion"] as? String let reachability = Reachability()! switch reachability.connection { case .wifi: - UserDefaults.standard.register(defaults: ["UserAgent": "blistar/"+version!]) + UserDefaults.standard.register(defaults: ["UserAgent": "blistar/"+version!+"("+build!+")"]) Answers.logContentView(withName: "Über diese App", contentType: "Über diese App", @@ -71,7 +73,7 @@ class SixteenViewController: UIViewController, UIWebViewDelegate { webView16.loadRequest(URLRequest(url: URL(string: "https://zitrotec.de/blista")!)) case .cellular: - UserDefaults.standard.register(defaults: ["UserAgent": "blistar/"+version!]) + UserDefaults.standard.register(defaults: ["UserAgent": "blistar/"+version!+"("+build!+")"]) Answers.logContentView(withName: "Über diese App", contentType: "Über diese App",